SmaCC Question

Colin Putney cputney at wiresong.ca
Mon May 24 00:48:57 UTC 2004


Hi folks,

A question for the SmaCC gurus out there. I'm trying to build a parser 
that will be versioned in Monticello, so I want to keep the code in the 
parser class as much as possible, and out of the grammar. If I read the 
tutorial correctly, this ought to be possible. From the tutorial:

"Each production consists of a sequence of non-terminal symbols, 
tokens, or keywords followed by some optional Smalltalk code enclosed 
in curly brackets, {}."

and:

"The Smalltalk code is evaluated whenever that production is matched. 
If the code is a zero or a one argument symbol, then that method is 
performed. For a one argument symbol, the argument is an 
OrderedCollection that contains one element for each item in the 
production. If the code isn't a zero or one argument symbol, then the 
code is executed and whatever is returned by the code is the result of 
the production."

So in theory I should be able to replace this production rule:

Node: <token> NonTerminal1 NonTerminal2 {self doSomethingWith: '1' and: 
'2' and: '3'};

with this one:

Node: <token> NonTerminal1 NonTerminal2 {doSomething:};


But this causes a parse error in the grammar. Looking around in the 
parser generator source, I can't see any code that would handle the 
second case above.

What I'd like is for #doSomething: to be put into the parser's reduce 
table, but I can't figure out how to have the parser generator do that. 
Is there some thing I'm missing, or is this just a disconnect between 
the documentation and the actual code?

Thanks,

Colin




More information about the Squeak-dev mailing list