narke
narke

Reputation: 103

Parsing: Why a rule I defined isn't matched?

I'm writing a trans-compiler whith PLY, in python, which aims to translate mythryl into neko.

The thing is when parsing code like:

fun not 1 => 0;
    not 0 => 1;
end;

This example is at: https://github.com/narke/my2neko/blob/master/test_cases/ex1.my

The parser doesn't match the rule which applies to the reserved word 'fun', represented by FUN_T, of course the rule exists, the last one:

def p_declaration(p):
'''declaration : MY_T vb
    | dot_exp ARROW pattern
    | FIELD_T MY_T fields
    | RECURSIVE_T MY_T rvb
    | FUN_T fun_decls

The parser is at: https://github.com/narke/my2neko/blob/master/my2neko.py

The error I got is like:

State  : 0
Illegal character 'f'
Illegal character 'u'
Illegal character 'n'
Illegal character 'i'
Illegal character 'n'
Stack  : . LexToken(LOWERCASE_ID,'c',1,6)
Action : Shift and goto state 80

To reproduce it: ./my2neko.py test_cases/ex4.my f.neko

Can you please point me what I missed? Thanks in advance.

Here is the project: https://github.com/narke/my2neko

Upvotes: 0

Views: 247

Answers (1)

narke
narke

Reputation: 103

OK, I found what was wrong. I ommitted to handle reserved words. See 4.3 Specification of tokens at http://www.dabeaz.com/ply/ply.html.

Upvotes: 1

Related Questions