python - Where is the ambiguity in my grammar? -


i have following ambiguous grammar capital letter rules simple lexical tokens:

program : function | function program function : fn id arrow type invariants dash block fn_call : id l_paren constant r_paren   invariants : invariant | invariant invariants invariant : type id colon invariant_tests invariant_tests : test | test comma invariant_tests test : operator constant | star   block : expression | expression block expression : loop | fn_call | assignment | def | constant loop : def in constant colon block assignment : id assign constant | id assign id def : type assignment 

i receive 8 shift/reduce errors (when using python 2.7 , ply).

is ambiguity result of how define "one or more", eg. block : expression | expression block?

as previous speaker said, must differentiate between "block usages". example, try:

loop : def in constant colon block end 

Comments