[antlr-interest] Noob needs help with: warning "Decision can match input such as X... using multiple alternatives"
cruxic at gmail.com
Mon Apr 16 16:28:04 PDT 2012
Version 4 sounds nice, Kyle, but since I'm new to ANTLR I'd prefer to stick
to the stable version so I'm not debugging and learning at the same time.
Can anybody weigh in on the original warning?
On Mon, Apr 16, 2012 at 4:18 PM, Kyle Ferrio <kferrio at gmail.com> wrote:
> In addition to the examples swirling around the antlr website, have a look
> at the screencasts posted by Scott Stanchfield on vimeo.
> And if you really want to see how easy calculator-like parsing can be and
> you're not afraid of working without a net, try the early access builds of
> antlr v4, aka Honey Badger. Besides making a lot of things dead simple, v4
> has specific features for making algebraic expression parsing a snap. Oh,
> and it can handle direct left recursion. Thanks be to Ter, Benevolent
> ANTLR Dictator for Life!
> On Apr 13, 2012 4:58 PM, "Adam B" <cruxic at gmail.com> wrote:
>> 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
>> 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.
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
More information about the antlr-interest