import commands import color, mode, method, tab from lex import Grammar, PatternRule, RegionRule, OverridePatternRule from mode.python import StringGrammar1, StringGrammar2 class LuaGrammar(Grammar): rules = [ PatternRule(r'comment', r'--.*$'), PatternRule(r'spaces', r' +'), PatternRule(r'eol', r'\n'), RegionRule(r'string', r"'", StringGrammar1, r"'"), RegionRule(r'string', r'"', StringGrammar2, r'"'), PatternRule(r'keyword', r'(?:while|until|true|then|return|repeat|or|not|nil|local|in|if|function|for|false|end|elseif|else|do|break|and)(?![a-zA-Z0-9_])'), #PatternRule(r'function', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'), PatternRule(r'function', r'(?<=function )[a-zA-Z_][a-zA-Z0-9_]*'), #PatternRule(r'identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'), PatternRule(r'lua_identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'), PatternRule(r'delimiter', r'(?:[=(){}\[\];:,.])'), PatternRule(r'operator', r'(?:\.\.\.|\.\.|==|~=|<=|>=|<|>)'), PatternRule(r"integer", r"(?