Re: [go-nuts] Re: Parsing ambiguity?

2016-09-16 Thread Jan Mercl
On Fri, Sep 16, 2016 at 4:13 PM adonovan via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> The grammar is indeed ambiguous, but the ambiguity is (implicitly)
resolved by favoring the leftmost derivation, which is what you get from an
LL(k) parser. By the same token (hah!), the grammar expresses that unary
operations have higher precedence than binary ones. For example, -x + y is
parsed as (-x)+y, not -(x+y). If you want a derivation other than the
leftmost one, you need to use parentheses.

Thank you as well. This information is valuable for fixing the issue.

-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Parsing ambiguity?

2016-09-16 Thread adonovan via golang-nuts
On Friday, 16 September 2016 06:43:38 UTC-4, Jan Mercl wrote:
>
> Which rule selects the first parse? Can anybody please enlighten me? 
> Thanks in advance.
>

The grammar is indeed ambiguous, but the ambiguity is (implicitly) resolved 
by favoring the leftmost derivation, which is what you get from an LL(k) 
parser.  By the same token (hah!), the grammar expresses that unary 
operations have higher precedence than binary ones.  For example, -x + y is 
parsed as (-x)+y, not -(x+y).   If you want a derivation other than the 
leftmost one, you need to use parentheses.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.