Related articles |
---|
How to parse C-programs without communication between parser and lexer sodtke@infbssts.ips.cs.tu-bs.de (Detlef Sodtke) (1996-08-15) |
Re: How to parse C-programs without communication between parser and l henry@zoo.toronto.edu (Henry Spencer) (1996-08-16) |
Re: How to parse C-programs without communication between parser and l scooter@mccabe.com (Scott Stanchfield) (1996-08-19) |
How to parse C-programs without communication between parser and lexer ig@estar.msk.su (Ilfak Guilfanov) (1996-08-27) |
From: | Ilfak Guilfanov <ig@estar.msk.su> |
Newsgroups: | comp.compilers |
Date: | 27 Aug 1996 23:53:51 -0400 |
Organization: | Compilers Central |
Keywords: | C, parse |
Hello,
Thursday August 15 1996, Detlef Sodtke writes to All:
> The main problem is to distinguish the typedefnames from the normal
> identifiers. The common way is, that the parser writes in a hashtable the
> typedefnames and the lexer reads from it.
I introduce an additional layer:
token_t *get_token() {
token_t *t = get_token_from_lex();
if ( is_typedef(t) ) return convert_to_typedef(t);
else return t;
}
The parser calls 'get_token' function and gets a 'typedef' token when
there is one.
get_token_from_lex() simply returns a typedef name as an identifier.
> In our implementation we can't do it this way. We have to lex the whole
> C-program before the parser starts to work. So the parser is not able to
> write in a hashtable.
The lexer can be run as a separate pass.
bye
Ilfak
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.