From ca265fd05474d925e20cb84682f2bb95d582aac3 Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 7 Dec 2008 05:02:28 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- application.py | 2 +- mode/lua.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 mode/lua.py diff --git a/application.py b/application.py index 2294640..c606613 100755 --- a/application.py +++ b/application.py @@ -111,7 +111,7 @@ class Application(object): 'latex', 'insertmini', 'conf', 'haskell', 'erlang', 'iperl', 'iperlmini', 'ipython', 'ipythonmini', 'awk', 'shell', 'shellmini', 'fstab', 'yacc', 'pipe', - 'mbox', 'error', + 'mbox', 'error', 'lua', ) for name in names: exec("import mode.%s; mode.%s.install(self)" % (name, name)) diff --git a/mode/lua.py b/mode/lua.py new file mode 100644 index 0000000..7938c19 --- /dev/null +++ b/mode/lua.py @@ -0,0 +1,58 @@ +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"(?