mirror of
https://github.com/byteworksinc/ORCA-Pascal.git
synced 2024-10-11 01:23:37 +00:00
1 line
26 KiB
ObjectPascal
1 line
26 KiB
ObjectPascal
|
{$optimize 15}
{---------------------------------------------------------------}
{ }
{ Scanner }
{ }
{---------------------------------------------------------------}
unit Scanner;
{$segment 'Pascal2'}
interface
{$libprefix '0/obj/'}
uses PCommon, CGI;
{---------------------------------------------------------------}
var
{misc}
{----}
debugType: (stop,breakPoint,autoGo); {kind of debugging for this line}
doingInterface: boolean; {compiling an interface?}
partiallist: partialptr; {list of partial compile names}
partial: boolean; {is this a partial compile?}
{returned by InSymbol}
{--------------------}
sy: symbol; {last symbol}
op: operator; {classification of last symbol}
val: valu; {value of last constant}
lgth: integer; {length of last string constant}
id: pString; {last identifier}
ch: char; {last character}
eofl: boolean; {end of file flag}
{---------------------------------------------------------------}
procedure InSymbol; extern;
{ read the next token from the source stream }
procedure Match (sym: symbol; ern: integer); extern;
{ insure that the next symbol is the one requested }
{ }
{ parameters: }
{ sym - symbol expected }
{ ern - error number; used if the symbol is not correct }
procedure OpenUses;
{ copies the contents of a uses file }
procedure Scanner_Init; extern;
{ initialize the scanner }
procedure Scanner_Fini;
{ shut down the scanner }
procedure Skip (fsys: setofsys);
{ skip input string until relavent symbol found }
{ }
{ parameters: }
{ fsys - symbol kind to skip to }
{---------------------------------------------------------------}
implementation
type
copyFilePtr = ^copyFileRecord; {copied file chain}
copyFileRecord = record
fnext: copyFilePtr; {next copied file record}
fname: gsosOutString; {file name}
fpos: longint; {disp in file}
fuses: boolean; {doing uses?}
flineCount: integer; {line count}
end;
var
{misc}
{----}
didKeep: boolean; {have we found a $keep directive?}
doingOption: boolean; {compiling an option?}
eofDisable: boolean; {disable end of file error check?}
eol: boolean; {end of line flag}
fHeadGS: copyFilePtr; {copied file chain}
langNum: integer; {language number}
listFixed: boolean; {was the list option specified on the cl?}
lString: pString; {last string}
usesLength: longint; {# bytes in current uses buffer}
usesPtr: ptr; {ptr to next byte in uses buffer}
{- Private subroutines -----------------------------------------}
procedure EndOfLine; extern;
{ Read in the next source line }
procedure FakeInsymbol; extern;
{ install the uses file InSymbol patch }
procedure GetPartialNames;
{ Form a linked list of partial compile names }
function GetName: boolean;
{ Read a name from subsGS }
{ }
{ Returns: false if there are no more names, else true }
var
i: unsigned; {loop/index variable}
pn: partialptr; {new partial compile entry}
pname: pStringPtr; {work string}
function GetCh: char;
{ Get a character }
{ }
{ returns: next character from subsGS }
var
ch: char; {work character}
begin {GetCh}
if subsGS.theString.size = 0 then
GetCh := chr(0)
else begin
ch := subsGS.theString.theString[1];
if ch in ['a'..'z'] then
ch := chr(ord(ch)-ord('a')+ord('A'));
GetCh := ch;
end; {else}
end; {GetCh}
procedure NextCh;
{ Remove the next character from subsGS }
var
i: unsigned; {loop/index variable}
begin {NextCh}
with subsGS.theString do
if size <> 0 then begin
for i := 2 to size do
theString[i-1] := theString[i];
size := size-1;
end;
|