__init__(self,
rules_list)
(Constructor)
By now lexer is kept as simple as possible, so order is really
essential: i.e. if a keyword is substring of another its rule must
appear after the larger keyword for the obvious reasons...
-
- Parameters:
rules_list -
contains pairs (re,funct,op?) where:
re : is an uncompiled python regular
expression
funct : the name of a funcion that returns the
pair (TOKEN, SPECIAL_VALUE) , where
TOKEN is the token to be used by the parser and
SPECIAL_VALUE an eventual associated value. The
argument is the matched string. If funct equals
"" the token is ignored. This can be used
for delimiters.
op : if present, is a tuple with operador
information: (TOKEN,PRECEDENCE,ASSOC) where
PRECEDENCE is an integer and ASSOC the
string 'left' or 'right'.
|