diff --git a/lex2_python.py b/lex2_python.py index 63486fa..48bd203 100755 --- a/lex2_python.py +++ b/lex2_python.py @@ -19,15 +19,11 @@ class StringGrammar(Grammar): class PythonGrammar(Grammar): rules = [ PatternRule( - name=r'import', - pattern=r'(?:^|(?<= ))import(?= |$)', - ), - PatternRule( - name=r'methodname', + name=r'functiondef', pattern=r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*', ), PatternRule( - name=r'classname', + name=r'classdef', pattern=r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*', ), PatternRule( @@ -39,13 +35,18 @@ class PythonGrammar(Grammar): pattern=r'(?:yield|while|try|return|raise|print|pass|or|not|lambda|is|in|import|if|global|from|for|finally|exec|except|else|elif|del|def|continue|class|break|assert|as|and)(?![a-zA-Z0-9_])', ), PatternRule( - name=r"builtin_method", + name=r"builtin", pattern=r'(?|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%", ), + PatternRule( name=r"integer", pattern=r"(?