pmacs3/mode/make.py

53 lines
1.7 KiB
Python
Raw Normal View History

2007-10-17 22:44:22 -04:00
import color, mode2
from lex3 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'assignment', r'^[^:= ]+(?= *=)'),
PatternRule(r'targets', r'^[^:= ]+(?= *:)'),
RegionRule(r'assignment', r'^[^:= ]+ *=', ShGrammar, r'\n'),
#RegionRule(r'targets', r'^[^:= ]+ *:', Grammar, r';|\n', ShGrammar, r'\n'),
RegionRule(r'actions', r'^ ', ShGrammar, r'\n'),
PatternRule(r'variable', r'\$\([a-zA-Z0-9_]+\)'),
PatternRule(r'variable', r'\${[a-zA-Z0-9_]+}'),
RegionRule(r'string', r'"', StringGrammar, r'"'),
RegionRule(r'string', r"'", StringGrammar, r"'"),
]
class Make(mode2.Fundamental):
2007-10-18 17:07:35 -04:00
modename = 'Make'
basenames = ['Makefile']
grammar = MakeGrammar
savetabs = True
colors = {
2007-10-17 22:44:22 -04:00
'comment': ('red', 'default'),
'continuation': ('red', 'default'),
'targets.start': ('cyan', 'default'),
'assignment.start': ('yellow', 'default'),
#'targets': ('cyan', 'default'),
#'assignment': ('yellow', 'default'),
'variable': ('yellow', 'default'),
'string.start': ('green', 'default'),
'string.variable': ('yellow', 'default'),
'string.escaped': ('magenta', 'default'),
'string.null': ('green', 'default'),
'string.end': ('green', 'default'),
}
colors.update(Sh.colors)