42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
import color, mode
|
|
from lex import Grammar, PatternRule, RegionRule, PatternGroupRule
|
|
from mode.sh import ShGrammar, Sh
|
|
|
|
class StringGrammar(Grammar):
|
|
rules = [
|
|
PatternRule(r'escaped', r'\\.'),
|
|
PatternRule(r'escaped', r'\$\$'),
|
|
PatternRule(r'variable', r"\$\([a-zA-Z0-9_]+\)"),
|
|
]
|
|
|
|
class MakeGrammar(Grammar):
|
|
rules = [
|
|
PatternRule(r'comment', r'#.*\n$'),
|
|
PatternRule(r'continuation', r'\\\n$'),
|
|
PatternRule(r'targets', r'^[^:= ]+(?= *:)'),
|
|
RegionRule(r'assignment', r'^[^:= ]+ *=', ShGrammar, r'\n'),
|
|
RegionRule(r'actions', r'^ ', ShGrammar, r'\n'),
|
|
PatternRule(r'make_variable', r'\$\([a-zA-Z0-9_]+\)'),
|
|
PatternRule(r'make_variable', r'\${[a-zA-Z0-9_]+}'),
|
|
RegionRule(r'make_string', r'"', StringGrammar, r'"'),
|
|
RegionRule(r'make_string', r"'", StringGrammar, r"'"),
|
|
]
|
|
|
|
class Make(mode.Fundamental):
|
|
modename = 'Make'
|
|
basenames = ['Makefile']
|
|
grammar = MakeGrammar
|
|
savetabs = True
|
|
colors = {
|
|
'targets.start': ('cyan', 'default'),
|
|
'assignment.start': ('yellow', 'default'),
|
|
'make_variable': ('yellow', 'default'),
|
|
'make_string.start': ('green', 'default'),
|
|
'make_string.variable': ('yellow', 'default'),
|
|
'make_string.escaped': ('magenta', 'default'),
|
|
'make_string.null': ('green', 'default'),
|
|
'make_string.end': ('green', 'default'),
|
|
}
|
|
|
|
install = Make.install
|