Hi,

I have a problem with using semantic predicates in my grammar. I have certain 
rules to identify simple, basic sentences of a natural language (English). In 
addition I want to restrict the language to a set of keywords. Those keywords 
are adaptively generated from an external c++ routine, meaning I cannot put 
them statically into my ANTLR code. Therefore, within one rule of my grammar, 
I'm comparing the actual token to an array of keywords. If a keyword is found, 
I'm setting an ANTLR variable to true. At the end of the rule it shall be 
evaluted if this varible is true and if so, the token shall be accepted. If the 
variable is false, it mustn't be accepted.

Here is the sample:
rule:    {C++ routine assigning value to $sentence::adjective_recognized}
           {$sentence::adjective_recognized}? ID ;

In my case $sentence::adjective_recognized is set to true when an adjective is 
found that is a keyword. The problem that I have is that the routine to set 
this variable is not evaluated at the beginning of the parsing. I have to 
initialize this variable to true in order to make the parser accept the whole 
sentence. If I'm initializing this variable to false the parser cannot map the 
input sentence to the grammar. I'm supposing the parser is trying to map the 
input sentence (look ahead)  in advance before actually going through all the 
rule actions? Is there a way to tell the parser to evaluate the variable i.e. 
my routine every time? Thank you very much for your help.

Yours, Dagi

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to