SCANNER MODULE Scans IP Pascal tolkens from a file and returns them. Does nothing with "uses" files, and has no error recovery. The scanner module is a general purpose version of the scanner built in to the general compiler. It is usefull for program analisis tasks, such as symbols/crossreference generators, and convertion tasks, such as a prettyprinter. The scanner buffers up its input in terms of lines. This is required because some of the tolkens require backtracking to recognise. No ANSI status is recognized. The scanner allways works in full IP mode. There are two calls for the scanner module: iniscn(var f: text); Initalizes the scanner and reads the first line from the input file. The caller may check if the file is null (eof) before the call. gettlk(var f: text); Gets the next tolken from the input, and places that in the next tolken buffers, as follows: nxttlk Returns the next tolken code. This is one of the tolkens from the "tolken" type. nxtlab Returns the next label, if the tolken is a symbol, or the next string, if the next tolken is a string. Strings have their enclosing quotes removed. Other tolkens will also have their equivalent forms placed in the nxtlab buffer, including integers and reals. nxtlen Returns the length of a string for a string tolken. nxtint Returns an integer if the next tolken is an integer. nxtflt Returns a floating point if the next tolken is a real.

Modules

uses spctbl
uses restbl
uses tolkens
uses strings

Constants

maxstr
maxlin
maxexp

Types

lininx
linbuf
fcbptr
fcbrec
labinx
errcod

Fixed

Variables

fansi: boolean
deftbl: array
ci: subrange
ri: subrange
li: subrange

Procedures and Functions

procedure error
function hash: (unknown)
procedure getlin
function endlin: (unknown)
function seof: (unknown)
function chkchr: (unknown)
procedure getchr
procedure skpspc
procedure conchr
procedure lookup
procedure parnum
function pwrten: (unknown)
procedure getchrb
procedure parstr
procedure parlabr
procedure parchr
function hash: (unknown)
procedure search
procedure partlk
procedure gettlk
procedure opnscn
procedure clsscn

Detail

maxstr (constant)

Type: integer

symbols hash table
maxlin (constant)

Type: integer

maximum length of string/symbol
lininx (type)

Type: subrange

maximum size of input line
linbuf (type)

Type: array

index for text line
fcbptr (type)

Type: pointer

a text line
fcbrec (type)

Type: record

next real
fansi (variable)

Type: boolean

maxexp (constant)

Type: integer

standard Pascal mode
labinx (type)

Type: subrange

maximum exponent of real
errcod (type)

Type: scalar

Invalid symbol/character
deftbl (variable)

Type: array

Unterminated comment
ci (variable)

Type: subrange

tolken definition strings
ri (variable)

Type: subrange

li (variable)

Type: subrange

procedure error
Process scanner error
Prints an error by code, then halts the program.
Definition at line 134 of file scanner.pas
Called By
gettlkparstrgetlin
function hash: (unknown)
return hash
Returns
(unknown)
Definition at line 179 of file scanner.pas
Calls
hashlcase
Called By
parchrparlabr
procedure getlin
file control block
Definition at line 204 of file scanner.pas
Calls
lenerrorreads
Called By
opnscnskpspc
function endlin: (unknown)
end of line status
Returns
(unknown)
Definition at line 236 of file scanner.pas
Calls
endlin
Called By
gettlkparstrskpspcchkchrseof
function seof: (unknown)
file control block
Returns
(unknown)
Definition at line 253 of file scanner.pas
Calls
endlinseof
Called By
gettlkpartlkskpspc
function chkchr: (unknown)
current input character
Returns
(unknown)
Definition at line 273 of file scanner.pas
Calls
chkchrendlin
Called By
gettlkpartlkparlabrparstrskpspc
procedure getchr
file control block
Definition at line 296 of file scanner.pas
Called By
gettlkpartlkparlabrparstrskpspc
procedure skpspc
file control block
Definition at line 316 of file scanner.pas
Calls
chkchrseofgetlinendlingetchr
Called By
gettlkpartlkparstr
procedure conchr
control character
Definition at line 341 of file scanner.pas
Called By
parstr
procedure lookup
attempt lookup of memnonic
Definition at line 349 of file scanner.pas
procedure parnum
real number search flag
Definition at line 466 of file scanner.pas
Calls
pwrten
Called By
partlkparstr
function pwrten: (unknown)
find power of ten effciently
Returns
(unknown)
Definition at line 482 of file scanner.pas
Called By
parnum
procedure getchrb
move character to output buffer
Definition at line 504 of file scanner.pas
procedure parstr
file to read from
Definition at line 639 of file scanner.pas
Calls
errorgetchrchkchrconchrparnumendlinskpspc
Called By
partlk
procedure parlabr
Parse label/reserved word
Parses a label, which is:

'_'/'a'..'z' ['_', '0'..'9', 'a'..'z']...

After parsing, the label is checked against the reserved list, and returned as a reserved tolken if so.
Definition at line 710 of file scanner.pas
Calls
compphashgetchrchkchr
Called By
partlk
procedure parchr
Parse special character sequence
Parses a 1 or 2 character special sequence. These are arbitrary characters, with any kind of termination.
Definition at line 777 of file scanner.pas
Calls
hashlcase
Called By
partlk
function hash: (unknown)
Find hash function
Returns
(unknown)
Definition at line 784 of file scanner.pas
Calls
hashlcase
Called By
parchrparlabr
procedure search
search label
Definition at line 803 of file scanner.pas
procedure partlk
file to read from
Definition at line 868 of file scanner.pas
Calls
parchrparnumchkchrgetchrparlabrparstrseofskpspc
Called By
gettlk
procedure gettlk
file to read from
Definition at line 921 of file scanner.pas
Calls
partlkgetchrendlinerrorseofchkchrskpspc
Called By
opnscn
procedure opnscn
Open scanner file
Allocates the file control block, opens the file, then loads the first tolken.
Definition at line 997 of file scanner.pas
Calls
gettlkgetlincopy
procedure clsscn
Close scanner file
Closes the file, and frees the fcb.
Definition at line 1019 of file scanner.pas

Cross-Reference

maxstr: 828 731(parlabr) 720(parlabr) 715(parlabr) 710(parlabr) 475(parnum) 103 80
maxlin: 68
lininx: 69
linbuf: 75
fcbptr: 1017(clsscn) 995(opnscn) 919(gettlk) 866(partlk) 775(parchr) 708(parlabr) 637(parstr) 463(parnum) 338(conchr) 314(skpspc) 294(getchr) 270(chkchr) 250(seof) 233(endlin) 202(getlin) 132(error) 93(gettlk) 92(clsscn) 91(opnscn)
fcbrec:
fansi: 1150 755(parlabr) 717(parlabr) 691(parstr) 653(parstr)
maxexp: 598 598
labinx: 778(parchr) 122
errcod: 132(error)
deftbl: 1146 1145 1144 1143 1142 1141 1140 1139 1138 1137 1136 1135 1134 1133 1132 1131 1130 1129 1128 1127 1126 1125 1124 1123 1122 1121 1120 1119 1118 1117 1116 1115 1114 1113 1112 1111 1110 1109 1108 1107 1106 1105 1104 1103 1102 1101 1100 1099 1098 1097 1096 1095 1094 1093 1092 1091 1090 1089 1088 1087 1086 1085 1084 1083 1082 1081 1080 1079 1078 1077 1076 1075 1074 1073 1072 1071 1070 1069 1068 1067 1066 1065 1064 1063 1062 1061 1060 1059 1058 1057 1056 1055 1054 1053 1052 1051 1050 1049 1048 1047 1046 1045 1044 1043 1042 1041 980(gettlk)
ci: 816 815 814 814 814 813 809 808 807
ri: 750(parlabr) 749(parlabr) 748(parlabr) 748(parlabr) 748(parlabr) 747(parlabr) 743(parlabr) 742(parlabr) 741(parlabr) 740(parlabr)
li:
error: 950(gettlk) 845 691(parstr) 688(parstr) 661(parstr) 648(parstr) 599 594 570 569 546 540 531 212(getlin)
hash: 807 795(parchr) 740(parlabr) 190(hash)
getlin: 1004(opnscn) 322(skpspc)
endlin: 954(gettlk) 650(parstr) 322(skpspc) 321(skpspc) 277(chkchr) 256(seof) 238(endlin)
seof: 949(gettlk) 946(gettlk) 934(gettlk) 874(partlk) 324(skpspc) 256(seof)
chkchr: 946(gettlk) 941(gettlk) 933(gettlk) 890(partlk) 886(partlk) 883(partlk) 881(partlk) 879(partlk) 877(partlk) 827 825 734(parlabr) 728(parlabr) 723(parlabr) 717(parlabr) 679(parstr) 669(parstr) 656(parstr) 652(parstr) 648(parstr) 594 591 587 578 575 572 570 564 564 558 539 538 538 536 533 532 531 530 528 525 522 506 408 407 324(skpspc) 321(skpspc) 280(chkchr)
getchr: 954(gettlk) 947(gettlk) 944(gettlk) 940(gettlk) 888(partlk) 838 826 737(parlabr) 726(parlabr) 683(parstr) 681(parstr) 678(parstr) 670(parstr) 655(parstr) 649(parstr) 508 409 321(skpspc)
skpspc: 939(gettlk) 873(partlk) 646(parstr) 516
conchr: 666(parstr)
lookup: 420 416 412
parnum: 893(partlk) 882(partlk) 660(parstr) 597
pwrten: 602 601 496(parnum)
getchrb: 593 589 581 563 552 529 526 523
parstr: 878(partlk)
parlabr: 880(partlk)
parchr: 904(partlk)
hash: 807 795(parchr) 740(parlabr) 190(hash)
search: 844 831
partlk: 955(gettlk) 926(gettlk)
gettlk: 1005(opnscn)
opnscn:
clsscn:

External Modules

spctbl

Symbol hash table

Constants

chrmax
chroff
spcmax

Types

chrinx
chrstr

Variables

spctbl: array

restbl

Reserved word hash table

Constants

resmax
hashoff

Types

resinx

Variables

restbl: array

tolkens

Scanner tolkens

Types

tolken

strings

STRING HANDLING LIBRARY

Procedures and Functions

function lcase: (unknown)
function lcase: (unknown)
procedure clears
function len: (unknown)
function len: (unknown)
procedure copy
procedure copy
function copy: (unknown)
function copy: (unknown)
procedure copy
function compp: (unknown)
procedure reads
procedure reads
procedure reads
procedure reads
procedure reads
procedure reads
procedure reads
procedure reads