can't parse chained unary operators #2

Closed
osa1 opened this Issue Dec 1, 2012 · 2 comments

Comments

Projects
None yet
1 participant
@osa1
Owner

osa1 commented Dec 1, 2012

The parser cannot parse chained unary operator chains. For example, this works:

ghci> parseText exp  "not false"
Right (Unop Not (Bool False))

But this fails:

ghci> parseText exp  "not not false"
Left "lua" (line 1, column 5):
unexpected (`not`,AlexPn 4 1 5)
expecting `nil`, `true`, `false`, number, string, `...`, `function`, ident, `(` or `{`

This is because exp' parser doesn't have opExp as a choice, and adding that causes exp parser to never return because of left-recursive parsing.

@osa1

This comment has been minimized.

Show comment
Hide comment
@osa1

osa1 Jan 30, 2013

Owner

This looks like a limitation of Parsec's expression parser:

Prefix and postfix operators of the same precedence can only occur once (i.e. --2 is not allowed if - is prefix negate).

Writing an expression parser with operator precedence is too much work for me now. Maybe I can find a workaround and go with Parsec's expr. parser.

Owner

osa1 commented Jan 30, 2013

This looks like a limitation of Parsec's expression parser:

Prefix and postfix operators of the same precedence can only occur once (i.e. --2 is not allowed if - is prefix negate).

Writing an expression parser with operator precedence is too much work for me now. Maybe I can find a workaround and go with Parsec's expr. parser.

@osa1

This comment has been minimized.

Show comment
Hide comment
@osa1

osa1 Jan 19, 2015

Owner

This is slightly improved with 25ec271 but the general solution(for mixing different operators, unary and binaries in same expressions etc.) is still not in sight.

Owner

osa1 commented Jan 19, 2015

This is slightly improved with 25ec271 but the general solution(for mixing different operators, unary and binaries in same expressions etc.) is still not in sight.

@osa1 osa1 closed this in b4bebe3 Jan 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment