[antlr-interest] unknown parameter
Corno Schraverus
antlr-interest at schraverus.com
Thu Nov 8 06:51:03 PST 2007
> Corno -
> I believe that it's a conceptual issue. What happens if the
> parameter that is passed is used in a semantic predicate to allow/
> disallow a particular parse path? The parse tree is then dependent
> on the parameter. I have tried, with some success (not fully yet, I
> believe, but that may be inexperience), the following:
>
> bar[Bar myBar]
> : (foo[null])=> foo[myBar]
> ;
> or whatever. If the parse is not dependent on the parameter then the
> syntactic predicate should work correctly.
>
> Hope this helps -- and I hope I'm not wildly off-base.
>
> Peace
> - John
>
John, Jim,
I'm not using the parameters in semantic predicates so I could solve my
problem by adjusting the generated C-code. I don't know if I can expect
problems later on but it does the trick and maybe it could be of interest to
more people.
What I did is the following;
-For every rule, a second function is generated, one that has no extra
parameters.
-For those second functions and the fragment functions (they are both
without parameters), I have defined a macro (#define WITHOUT_PARAMETERS just
before and #undef just after the function).
-at the places where calls to functions are being made, or where actions are
written I check if WITHOUT_PARAMETERS is defined, and if it is then the
extra parameters / action block are skipped.
greetings,
Corno
More information about the antlr-interest
mailing list