Question

I'm constructing an English-like domain specific language with ANTLR. Its keywords are context-sensitive. (I know it sounds dirty, but it makes a lot of sense for the non-programmer target users.) For example, the usual logical operators such as or and not are to be treated as identifiers when surrounded in brackets, [like this and this]. My current approach looks like this:

bracketedStatement
    : '[' bracketedWord+ ']'
    ;

bracketedWord
    :   (~(']')+
    ;

This, when combined with lexical definitions such as the following:

AND: 'and' ;
OR: 'or' ;

Produces the warning"Decision can match input such as "{AND..PROCESS, RPAREN..'with'}" using multiple alternatives: 1, 2". I'm clearly creating ambiguity for ANTLR, but I don't know how to resolve it. How do I fix this?

Was it helpful?

Solution

For anyone who finds this, check out this stack overflow question. It clarifies how to use the negation symbol correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top