Related articles |
---|
problems with identifiers and keywords... micha-1@fantasymail.de (Micha) (2004-10-21) |
Re: problems with identifiers and keywords... cfc@shell01.TheWorld.com (Chris F Clark) (2004-10-23) |
Re: problems with identifiers and keywords... gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-10-24) |
Re: problems with identifiers and keywords... clint@0lsen.net (Clint Olsen) (2004-10-25) |
Re: problems with identifiers and keywords... cfc@shell01.TheWorld.com (Chris F Clark) (2004-11-02) |
Re: problems with identifiers and keywords... gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-11-06) |
Re: problems with identifiers and keywords... wclodius@lanl.gov (2004-11-06) |
[23 later articles] |
From: | Micha <micha-1@fantasymail.de> |
Newsgroups: | comp.compilers |
Date: | 21 Oct 2004 22:21:56 -0400 |
Organization: | - |
Keywords: | parse, question, comment |
Posted-Date: | 21 Oct 2004 22:21:56 EDT |
Hi,
I'm helping a friend to write a parser for his project and I'm now
facing a problem with identifiers and keywords of his describing
language (which is rather natural not really like a computer
language).
I'm using lex and yacc for this, but not sure how to solve this two
problems:
Identifiers may be the same as keywords. To get this right, I am now
setting a global flag in the parser-action and if the scanner finds
the flag set it doesn't look in the symbol-table to get the
keyword-code but returns an Identifier-ID. Is this the correct way to
handle this?
The second problem is, that there are (at some positions) special
"words" allowed, which can consist of nearly all (printable)
characters except spaces. To get this I wanted to switch the
lexer-function for the next token in a parser-action, but that does
not work all the time (I think because of the look-ahead, which is
scanned with the wrong lexer). How can I get this switch right? Or is
this a completly wrong way of handling this?
thanks for answering,
Michael
[I've never found a better solution to this problem than the lexical
kludges you're using. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.