[antlr-interest] Attribute in Tree grammar. Semantic predicates with Alternative clause Problem
Петров Александр
gmdidro at gmail.com
Thu Oct 30 15:45:50 PDT 2008
Hello,
I'm using semantic predicates in tree grammar:
//deviceID is a rule
deviceFuncID
: ^(NODE1 ^(NODE2 ^(NODE3 deviceID)))
(
{
//IsID function has signature: bool IsID(string id)
IsID(
$deviceID.text,
)
}?
-> oneTemplate(...)
|-> otherTemplate(...)
);
deviceID : 'this'->{%{"this"}}
But when I try to compile generated C# code (antlr 3.1.1)I have many
errors like that:
---- The name 'deviceID25' does not exist in the current context
In antlr 3.0.1 such grammar produce compilable code.
If I rewrite that code as (remove brackets)
deviceFuncID
: ^(CCALL ^(CSYNCCALL ^(OBJECTNAME deviceID)))
{
IsID(
$deviceID.text,
)
}?
-> oneTemplate(...)
// |-> otherTemplate(...)
Then all right, but I want to have alternative clause for semantic predicate.
If I uncomment alternative clause, then I have:
---- error(201): The following alternatives can never be matched: 2
What should I do ? What is the cause of such errors ?
Thank you
More information about the antlr-interest
mailing list