Re: Compiler compiler that supports dynamic keywords?

Chris F Clark <world!>
16 Sep 1999 01:56:42 -0400

          From comp.compilers

Related articles
Compiler compiler that supports dynamic keywords? (Ramon M. Felciano) (1999-09-10)
Re: Compiler compiler that supports dynamic keywords? world! (Chris F Clark) (1999-09-16)
Re: Compiler compiler that supports dynamic keywords? (Quinn Tyler Jackson) (1999-10-13)
| List of all articles for this month |

From: Chris F Clark <world!>
Newsgroups: comp.compilers
Date: 16 Sep 1999 01:56:42 -0400
Organization: The World Public Access UNIX, Brookline, MA
References: 99-09-033
Keywords: parse

> I'm interested in building a parser that dynamically determines the
> lexical structure of particular rule element at runtime. For example,
> consider the following rule (in JavaCC pseudocode):
> "Hello" (
> <nameType1> RuleForRestOfSentenceType1()
> |
> <nameType2> RuleForRestOfSentenceType2()
> )
> The key is that the definition of <nameType1> and <nameType2> needs
> tobe changeable at runtime. . . .

Yes, this is a known solved problem. As you guess, essentially it is
a variation on the keywords problem. The solution is to intervene
between the lexer and the parser with a phase called a "screener".
[Frank De Remer coined the term. (Please excuse me if I have
mispelled the last name slightly. I recall it as one word, but a
reference I have cites him as shown.)]

The screener looks up words in a (set of) dictionary(ies) and finds
"token types" for those words to replace the default token type.
There are more details on the technique in the June 99 SIGPLAN

There are also parser generators that encourage this model of
organizing ones lexing and parsing by building it into their framework
(Anagram(outputs C) and Yacc++(outputs C++)). However, I am not aware
of any that support the model and produce Java as output. I'm
currently aware of 4 Java parser generators, ANTLR, CUP, JavaCC, and

Hope this helps,

Chris Clark Internet :
Compiler Resources, Inc. CompuServe : 74252,1375
3 Proctor Street voice : (508) 435-5016
Hopkinton, MA 01748 USA fax : (508) 435-4847 (24 hours)
Web Site in Progress: Web Site :

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.