2007-10-21 20:55:29 -04:00
|
|
|
import color, mode
|
2007-10-21 20:52:48 -04:00
|
|
|
from lex import Grammar, PatternRule, RegionRule, PatternGroupRule
|
2007-10-17 22:44:22 -04:00
|
|
|
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'),
|
2008-03-16 01:23:14 -04:00
|
|
|
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"'"),
|
2007-10-17 22:44:22 -04:00
|
|
|
]
|
|
|
|
|
2007-10-21 20:55:29 -04:00
|
|
|
class Make(mode.Fundamental):
|
2007-10-18 17:07:35 -04:00
|
|
|
modename = 'Make'
|
|
|
|
basenames = ['Makefile']
|
|
|
|
grammar = MakeGrammar
|
|
|
|
savetabs = True
|
|
|
|
colors = {
|
2008-04-18 23:32:08 -04:00
|
|
|
'targets.start': ('cyan', 'default'),
|
|
|
|
'assignment.start': ('yellow', 'default'),
|
|
|
|
'make_variable': ('yellow', 'default'),
|
2008-03-16 01:23:14 -04:00
|
|
|
'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'),
|
2007-10-17 22:44:22 -04:00
|
|
|
}
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = Make.install
|