Related articles |
---|
UCS: Isolated scanner mtrofimov@glas.apc.org (1998-05-15) |
From: | mtrofimov@glas.apc.org (Michael Trofimov) |
Newsgroups: | comp.compilers |
Date: | 15 May 1998 22:39:09 -0400 |
Organization: | Compilers Central |
Keywords: | lex, practice |
UCS: Isolated scanner
-------------
Usually, in classical compilers with recursive parsing, a lexical
scanner is called from different places of the parser. For example,
something like :
procedure expression;
procedure term;
procedure factor;
begin
if symbol = leftSy {"("}
then
begin
getSymbol (symbol);
expression;
end
else...........
end; {factor}
begin {term}
factor;
while symbol = mulSy {"*"} do
begin
getSymbol (symbol);
factor;
.................................
In contrast, in the MT2 Universal Compiler Shell (MT2UCS; please,
see <http://www.glasnet.ru/~mtrofimov/> for more info ...) I
implemented "an isolated scanner":
procedure compile;
begin
while not eof do
begin
getSymbol (symbol); {only one call here}
if testError then exit (compile);
parse (symbol); {there is no call of getSymbol in the parser}
end;
end; {compile}
This architecture looks like much more suitable for lexical errors
handing, for debugging and for optimization.
What do you think about? Do you know another examples of similar
architecture?
Thanks,
________________________________________________________________
Michael I. Trofimov
Russian Academy of Sci. Moscow, Russia
email: mtrofimov@glas.apc.org
http://www.glasnet.ru/~mtrofimov/
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.