[antlr-interest] Passing arguments to rules
Hendrik Maryns
qwizv9b02 at sneakemail.com
Fri Oct 31 02:41:26 PDT 2008
Hi,
I have a rule as follows:
firstOrderAtomic returns [Formula result] :
firstOrderAtomicHead[$first.result, $second.result] { $result =
$firstOrderAtomicHead.result;}
first=firstOrderVariable
second=firstOrderVariable ;
I hoped the rule firstOrderAtomicHead would receive the results from
first and second, but looking at the produced code, it doesn’t. How
would I do this to be able to pass the two variables to the head. I am
still working on a Lisp-like language, where this rule would e.g. match
(= x y)
and should produce new FirstOrderEquality(varX, varY), where varX and
varY are retrieved from a variable map or created if not present.
I think probably moving to an AST instead of trying to do this directly
in the parser would be a solution, but you probably can judge this
better, so that’s why I’m asking…
TIA, H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 257 bytes
Desc: OpenPGP digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081031/a7c3eaa1/attachment.bin
More information about the antlr-interest
mailing list