![]() ![]() Or, at least, the input does not conform to the grammar. Most of the time, when p_error is called, the input contains a syntax error. In other words, there is only one lexical anslyser, and as far as you have tested, it's working just fine. ![]() ![]() That could mean the token has not been correctly recognised, but we know that's not the case here the lexical analyser identifies the token, and ply.yacc uses ply.lex to split the input into tokens. Ply's parser calls p_error when it is unable to find an appropriate action for the lookahead token. The error message is, at best, misleading. With all due respect, this is not a reliable diagnostic tool. Your evidence for the claim that Ply's parser component ( ply.yacc) is not correctly recognising = as the ASSIGN token is a message which you yourself produce, in the p_error method. I've tried moving the token regex definitions thinking maybe there was some prioritization happening between EQUALS AND ASSIGN to no avail. Print ("Line %s, illegal token %s" % (p.lineno, p.value)) However when parsing as follows (excluding unrelated definitions) def p_assign(p):Īssign : ID array_assign ASSIGN expression SEMICOLON I'm using ply and defined my tokens as reserved = I get the expected tokens LexToken(MAIN,'main',1,0)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |