> Should the grammar allow one to construct the example statement > above? It should not. Please note that the grammar allows a number of other things, e.g. a+b = c (pass this to parser.suite to see details) > If not, I'm not sure how to fix the grammar. The central problem is that it allows testlist on the LHS of an augassign or '=', whereas the languages only allows a small subset in that position. It is not possible to restrict the grammar in itself, as that will necessarily produce a conflict - you only know that the '+' was incorrect when you see the '='. > I suppose the compiler should detect that the list comp is misplaced I think there should be a well-formedness pass in-between. I.e. after the AST has been build, a single pass should descend through the tree, looking for an expr_statement with more than a single testlist. Once it finds one, it should confirm that this really is a well-formed lvalue (in C speak). In this case, the test should be that each term is a an atom without factors. If the parser itself performs such checks, the compiler could be simplified in many places, I guess. Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4