|no reserved words email@example.com (1998-03-08)|
|Re: no reserved words firstname.lastname@example.org (Chris F Clark) (1998-03-12)|
|Re: no reserved words email@example.com (Jerry Leichter) (1998-03-13)|
|Re: no reserved words firstname.lastname@example.org (William D Clinger) (1998-03-15)|
|Re: no reserved words email@example.com (Stephen P Spackman) (1998-03-18)|
|Re: no reserved words firstname.lastname@example.org (Sandeep Dutta) (1998-03-18)|
|From:||William D Clinger <email@example.com>|
|Date:||15 Mar 1998 00:19:53 -0500|
|Keywords:||yacc, parse, comment|
When parsing a language with no reserved words, the following trick
might allow you to use Lex and Yacc or similar tools.
Use Lex to define a token (e.g. IF, THEN, CALL) for each syntactic
keyword of the language. Also define a token NONKEYWORD for
identifiers that are not also reserved words.
Use yacc to define a nonterminal identifier as follows:
identifier : NONKEYWORD
Then use the nonterminal identifier wherever you want to allow any
identifier, and use the specific tokens IF, THEN, et cetera wherever a
specific syntactic keyword must go.
You might have to resolve a lot of shift-reduce and reduce-reduce
conflicts, but those conflicts are sort of intrinsic to the grammar of
your language; you'll have to resolve them somehow no matter what
tools you use.
[See subsequent message about ambiguity problems. -John]
Return to the
Search the comp.compilers archives again.