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
|
|
|
|
|
2008-10-01 16:58:43 -04:00
|
|
|
class StringGrammar1(Grammar):
|
2007-10-17 22:44:22 -04:00
|
|
|
rules = [
|
|
|
|
PatternRule(r'escaped', r'\\.'),
|
|
|
|
PatternRule(r'escaped', r'\$\$'),
|
|
|
|
PatternRule(r'variable', r"\$\([a-zA-Z0-9_]+\)"),
|
2008-10-01 16:58:43 -04:00
|
|
|
PatternRule(r'data', r"[^\\']+"),
|
|
|
|
]
|
|
|
|
class StringGrammar2(Grammar):
|
|
|
|
rules = [
|
|
|
|
PatternRule(r'escaped', r'\\.'),
|
|
|
|
PatternRule(r'escaped', r'\$\$'),
|
|
|
|
PatternRule(r'variable', r"\$\([a-zA-Z0-9_]+\)"),
|
|
|
|
PatternRule(r'data', r'[^\\"]+'),
|
2007-10-17 22:44:22 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
class MakeGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
PatternRule(r'comment', r'#.*\n$'),
|
2008-10-01 16:58:43 -04:00
|
|
|
PatternRule(r'spaces', r' +$'),
|
2007-10-17 22:44:22 -04:00
|
|
|
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_]+}'),
|
2008-10-01 16:58:43 -04:00
|
|
|
RegionRule(r'make_string', r'"', StringGrammar2, r'"'),
|
|
|
|
RegionRule(r'make_string', r"'", StringGrammar1, r"'"),
|
|
|
|
PatternRule(r'eol', r'\n$'),
|
2007-10-17 22:44:22 -04:00
|
|
|
]
|
|
|
|
|
2007-10-21 20:55:29 -04:00
|
|
|
class Make(mode.Fundamental):
|
2009-03-17 15:24:10 -04:00
|
|
|
name = 'Make'
|
2007-10-18 17:07:35 -04:00
|
|
|
basenames = ['Makefile']
|
|
|
|
grammar = MakeGrammar
|
2009-02-15 12:06:35 -05:00
|
|
|
commentc = '#'
|
2007-10-18 17:07:35 -04:00
|
|
|
savetabs = True
|
|
|
|
colors = {
|
2008-05-03 13:31:30 -04:00
|
|
|
'targets.start': ('cyan', 'default', 'bold'),
|
|
|
|
'assignment.start': ('yellow', 'default', 'bold'),
|
|
|
|
'make_variable': ('yellow', 'default', 'bold'),
|
|
|
|
'make_string.start': ('green', 'default', 'bold'),
|
|
|
|
'make_string.variable': ('yellow', 'default', 'bold'),
|
|
|
|
'make_string.escaped': ('magenta', 'default', 'bold'),
|
|
|
|
'make_string.null': ('green', 'default', 'bold'),
|
|
|
|
'make_string.end': ('green', 'default', 'bold'),
|
2007-10-17 22:44:22 -04:00
|
|
|
}
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = Make.install
|