parent
baacddfa88
commit
3362f81c96
28
mode/lua.py
28
mode/lua.py
|
@ -9,25 +9,28 @@ from mode.pipe import Pipe
|
||||||
from method.shell import Interact
|
from method.shell import Interact
|
||||||
|
|
||||||
chr1 = '[a-zA-Z_]'
|
chr1 = '[a-zA-Z_]'
|
||||||
chr2 = '[a-zA-Z_0-9]'
|
chr2 = '[a-zA-Z_0-9_]'
|
||||||
word = chr1 + chr2 + '*'
|
word = '[a-zA-Z_]' + chr2 + '*'
|
||||||
|
|
||||||
|
capword = '[a-zA-Z]' + chr2 + '*'
|
||||||
|
|
||||||
class LuaGrammar(Grammar):
|
class LuaGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
RegionRule('comment', r'--\[(?P<level>=*)\[', Grammar, r'\]%(level)s\]'),
|
RegionRule('comment', r'--\[\[', Grammar, r'\]\]'),
|
||||||
#RegionRule('comment', r'--\[\[', Grammar, r'\]\]'),
|
|
||||||
PatternRule('comment', '--.*$'),
|
PatternRule('comment', '--.*$'),
|
||||||
PatternRule('spaces', ' +'),
|
PatternRule('spaces', ' +'),
|
||||||
PatternRule('eol', r'\n'),
|
PatternRule('eol', r'\n'),
|
||||||
|
|
||||||
RegionRule('lua.string', "'", StringGrammar1, "'"),
|
RegionRule('lua.string', "'", StringGrammar1, "'"), #fixme
|
||||||
RegionRule('lua.string', '"', StringGrammar2, '"'),
|
RegionRule('lua.string', '"', StringGrammar2, '"'), #fixme
|
||||||
RegionRule('lua.string', '\[\[', Grammar, '\]\]'),
|
|
||||||
|
|
||||||
PatternMatchRule('x', '(function)( +)(' + word + ')',
|
PatternMatchRule('', '(function)( +)([A-Za-z_][A-Za-z0-9_]*)(:)([A-Za-z_][A-Za-z0-9_]*)', 'lua.keyword', 'spaces', 'lua.class', 'delimiter', 'lua.function'),
|
||||||
'lua.keyword', 'spaces', 'lua.function'),
|
PatternMatchRule('', '(function)( +)([A-Za-z_][A-Za-z0-9_]*)', 'lua.keyword', 'spaces', 'lua.function'),
|
||||||
PatternRule('lua.keyword', '(?:while|until|true|then|return|repeat|or|not|nil|local|in|if|function|for|false|end|elseif|else|done|do|break|and)(?!' + chr2 + ')'),
|
|
||||||
|
PatternRule('lua.keyword', '(?:while|until|then|return|repeat|or|not|local|in|if|function|for|end|elseif|else|done|do|break|and)(?!' + chr2 + ')'),
|
||||||
|
PatternRule('lua.reserved', '(?:true|false|nil|self)(?![a-zA-Z0-9_])'),
|
||||||
PatternRule('lua.internal', '_[A-Z]+'),
|
PatternRule('lua.internal', '_[A-Z]+'),
|
||||||
|
PatternRule('lua.class', '[A-Z][a-zA-Z0-9_]*'),
|
||||||
PatternRule('lua.identifier', word),
|
PatternRule('lua.identifier', word),
|
||||||
|
|
||||||
PatternRule('delimiter', r'(?:[=(){}\[\];:,.])'),
|
PatternRule('delimiter', r'(?:[=(){}\[\];:,.])'),
|
||||||
|
@ -75,7 +78,10 @@ class Lua(Fundamental):
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
closetokens = ('delimiter',)
|
closetokens = ('delimiter',)
|
||||||
closetags = {')': '(', ']': '[', '}': '{'}
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
colors = {}
|
colors = {
|
||||||
|
'lua.class': ('blue225', 'default'),
|
||||||
|
'lua.reserved': ('magenta505', 'default'),
|
||||||
|
}
|
||||||
actions = [LuaCheckSyntax, LuaStart, LuaLoadFile]
|
actions = [LuaCheckSyntax, LuaStart, LuaLoadFile]
|
||||||
_bindings = {
|
_bindings = {
|
||||||
'close-paren': (')',),
|
'close-paren': (')',),
|
||||||
|
|
Loading…
Reference in New Issue