The order of alternatives in a "|" alternation construction _definitely_ 
matters, and always has, and matters for any PEG based grammar, for 
sure, part of how a PEG works. And yeah, the order of alternatives in an 
alternation construction ("|") is basically the (only) way to try and 
set 'precedence' in a PEG.

The order of the rules themselves does not (generally? I think ever?) 
make a difference in the parsing.

On 9/22/2012 1:59 PM, Joey Coyle wrote:
> Hi,
>
> Using 1.4
>
> The following doesn't work, but in the :number rule, if I invert integer and 
> decimal, then it does work.  The odd thing, is I have seen examples, like on 
> the powerpoint presentation from the main website where they put integer 
> first.  Has Parslet changed since that presentation was made?
>
> thanks,
> joey
>
> class Mini < Parslet::Parser
>   rule(:integer)        { match('[0-9]').repeat(1) }
>   rule(:decimal)        { integer >> str('.') >> integer }
>   rule(:number)         { integer | decimal }
>   root :number
> end
>
> puts Mini.new.parse("13.2432")
>

Reply via email to