yacc statement recognition

Slafs slafs.e at gmail.com
Thu Jan 1 18:21:18 EST 2009


Hi ALL!

I have to write in yacc an acceptor of files with lines matching this
regexp:
'[0-9],[0-9]'
and I don't know what I am doing wrong beacuse this:

--------
tokens = (
   'NUMBER',
    )
literals = [',']

t_NUMBER = r'\d'

...

def p_statement_exp(p):
    '''statement :  NUMBER ',' NUMBER
    '''
    print "OK!"
    sys.exit()
-------

also accepts lines like 2,abcdef3 which of
could someone please tell me what's wrong in my code?

full source on http://paste-it.net/public/vba22d5/



More information about the Python-list mailing list