Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

epsilon productions in Java CUP?

525 views
Skip to first unread message

Smith, Doug

unread,
Dec 15, 2001, 12:42:08 AM12/15/01
to
I'm looking for information on how to specify epsilon productions in Java
CUP. For example if one wanted to specify the grammar of valid balanced
parenthesis they would use the production:

S -> (S)S | p

where "|" means alternation and p is an epsilon or null production.

In CUP one would specify the terminals and non-terminals, the precedence and
then the grammar as above. But how does CUP understand the concept or
meaning of a null production?

I've searched every web page with every search engine I could find on Java
CUP and while there are one or two good tutorials out there I don't seem to
be able to find what I'm looking for. This is needed as part of a larger
grammar specification so any help would be greatly appreciated.

Luiz Lau

unread,
Dec 20, 2001, 12:40:29 AM12/20/01
to
I'm not sure the following lines will help, but if we have the following:
non terminal EndOrElse, SeqCmds
terminal END, ELSE

Consider the following production:

EndOrElse ::= END {: RESULT = null; :}
| ELSE SeqCmds:cmd END {: RESULT = cmd; :};

the null or epsilon production is achieved in CUP by assigning the value
"null" to the Result.
The above production is intended to avoid the dangling if -then - else
problem.

-- lee
.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.

"Smith, Doug" <sm...@sjfc.edu> wrote in message news:<01-1...@comp.compilers>...

0 new messages