Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse error #99

Open
wiltchamberian opened this issue Dec 23, 2023 · 1 comment
Open

parse error #99

wiltchamberian opened this issue Dec 23, 2023 · 1 comment

Comments

@wiltchamberian
Copy link

start[ast.Module]: a=expr_stmt* ENDMARKER { ast.Module(body=a or [] }
expr_stmt: a=expr NEWLINE { ast.Expr(value=a, EXTRA) }

expr:
    | l=expr '+' r=term { ast.BinOp(left=l, op=ast.Add(), right=r, EXTRA) }
    | l=expr '-' r=term { ast.BinOp(left=l, op=ast.Sub(), right=r, EXTRA) }
    | term

term:
    | l=term '*' r=factor { ast.BinOp(left=l, op=ast.Mult(), right=r, EXTRA) }
    | l=term '/' r=factor { ast.BinOp(left=l, op=ast.Div(), right=r, EXTRA) }
    | factor

factor:
    | '(' e=expr ')' { e }
    | atom

atom:
    | NAME
    | NUMBER

These codes are copied from : https://we-like-parsers.github.io/pegen/grammar.html
and I use python3.10 to parse but it failed, obvisouly, "ast.Module(body=a or [] " here lacks a ')' and there other issues such as

  File "<unknown>", line 1
    ast . Expr ( value = a , EXTRA )
                                   ^
SyntaxError: positional argument follows keyword argument     
For full traceback, use -v
@0dminnimda
Copy link
Contributor

0dminnimda commented Dec 23, 2023

The docs there seems to be a little outdated, it's probably meant to be LOCATIONS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants