// // File: GRSCN.RF // // Project: GR // // // e.Tokens = { e.Token }. // e.Token = Key s.Key | Name s.Name | Char s.Char. // s.Key = s.Word. // s.Name = s.Word. // $use Box; $use Class; $use Convert; $use Dos; $use StdIO; $func ScanToken s.Chl e.Line = s.TokenKey s.TokenInfo (e.Line1); $func ScanIdRest (e.IdChars) e.Chars = s.TokenKey s.Word (e.Rest); $func ScanComment s.Chl e.Line = s.TokenKey s.TokenInfo (e.Line1); $func? IsComment s.Char e.Line = e.Rest; $func? IsBlank s.Char = ; $func? IsOneCharToken s.Char = ; $func? IsCompoundToken s.Char e.Line = s.Word e.Rest; $box ScanChl ScanLine; InitScanner s.Chl = , ; TermScanner = , ; ReadToken = : s.Chl, :: e.Line, :: s.TokenKey s.TokenInfo (e.Line), , = s.TokenKey s.TokenInfo; ScanToken s.Chl e.Line = e.Line : { = { :: e.Line = ; = Key Eof (); }; s.Char e.Rest = { :: e.Rest = ; = ; = ; = Key (e.Rest); :: s.Word e.Rest = Key s.Word (e.Rest); = Char s.Char (e.Rest); }; }; ScanComment s.Chl e.Line = { e.Line : e '*/' e.Rest = ; = { :: e.Line = ; = , , Key Eof (); }; }; ScanIdRest (e.IdChars) e.Rest = { e.Rest : s.Char e.Rest1, \{ ; ; s.Char : '_'; } = ; = Name (e.Rest); }; IsBlank s.Char = ' \n\t' : e s.Char e; IsOneCharToken s.Char = ':|;' : e s.Char e; IsCompoundToken \{ '%%' e.Rest = "%%" e.Rest; '%token' e.Rest = "%token" e.Rest; }; IsComment '/*' e.Rest = e.Rest;