[antlr-interest] Noob needs help with: warning "Decision can match input such as X... using multiple alternatives"

Adam B cruxic at gmail.com
Fri Apr 13 16:58:26 PDT 2012

Hello all,

I'm learning antlr in hopes of creating a DSL.  To this end I need to
define a rule for nested "expressions" like:


After working around the left-recursion limitation I came up with something
like this (simplified for clarity):

    grammar help;


    prog: expr EOF;

        : INT (binary_op^ expr)*
        | '('! expr ')'! (binary_op^ expr)*

        : '+'
        | '-'
        | '*'
        | '/'

    INT:    '0'..'9'+;

This creates a beautiful AST with one problem.  ANTLRWorks spits out this

    [16:47:14] warning(200): help.g:11:24:
    Decision can match input such as "'*'..'/'" using multiple
alternatives: 1, 2

    As a result, alternative(s) 2 were disabled for that input

What am I doing wrong?

Any help you could offer would be greatly appreciated!
- Adam B.

More information about the antlr-interest mailing list