2007-10-21 20:55:29 -04:00
|
|
|
import color, mode
|
2009-04-08 00:21:29 -04:00
|
|
|
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
|
|
|
from mode.sh import ShGrammar, Sh, StringGrammar1, StringGrammar2
|
2007-10-17 22:44:22 -04:00
|
|
|
|
2009-04-08 00:21:29 -04:00
|
|
|
class StanzaGrammar(Grammar): pass
|
|
|
|
StanzaGrammar.rules = [
|
|
|
|
PatternMatchRule('x', r'^( +)([\-@]*)', 'spaces', 'modifier'),
|
|
|
|
PatternRule('spaces', r' +'),
|
|
|
|
PatternRule('continuation', r'\\\n$'),
|
|
|
|
PatternRule('make.extvariable', r'\$\$\{.+?\}'),
|
|
|
|
PatternRule('make.extvariable', r'\$\$[a-zA-Z0-9_]+'),
|
|
|
|
PatternRule('escaped', r'\$\$'),
|
|
|
|
RegionRule('eval', '`', StanzaGrammar, '`'),
|
|
|
|
PatternRule('make.variable', r'\$[?@]'),
|
|
|
|
PatternRule('make.variable', r'\$[a-zA-Z0-9_]+'),
|
|
|
|
PatternRule('make.variable', r'\$\(.+?\)'),
|
|
|
|
PatternRule('make.variable', r'\$\{.+?\}'),
|
|
|
|
PatternRule('escaped', r'\\.'),
|
|
|
|
PatternRule('word', r'[a-zA-Z0-9_]+'),
|
|
|
|
]
|
2007-10-17 22:44:22 -04:00
|
|
|
|
|
|
|
class MakeGrammar(Grammar):
|
|
|
|
rules = [
|
2009-04-08 00:21:29 -04:00
|
|
|
PatternRule('spaces', ' +'),
|
|
|
|
PatternRule('eol', r'\n'),
|
|
|
|
PatternRule('make.macro', '[^ :=]+(?= *=)'),
|
|
|
|
PatternRule('make.target', '[^ :=]+(?= *:)'),
|
|
|
|
PatternRule('comment', r'#.*\n$'),
|
|
|
|
RegionRule('make.macro', '=', StanzaGrammar, '^(?=[^ ])'),
|
|
|
|
RegionRule('make.target', ':', StanzaGrammar, '^(?=[^ ])'),
|
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 = {
|
2009-04-08 00:21:29 -04:00
|
|
|
'make.macro': ('yellow', 'default', 'bold'),
|
|
|
|
'make.macro.start': ('default', 'default'),
|
|
|
|
'make.macro.word': ('default', 'default'),
|
|
|
|
'make.macro.null': ('default', 'default'),
|
|
|
|
|
|
|
|
'make.macro.eval.start': ('cyan', 'default', 'bold'),
|
|
|
|
'make.macro.eval.word': ('cyan', 'default', 'bold'),
|
|
|
|
'make.macro.eval.null': ('cyan', 'default', 'bold'),
|
|
|
|
'make.macro.eval.end': ('cyan', 'default', 'bold'),
|
|
|
|
|
|
|
|
'make.target': ('magenta', 'default', 'bold'),
|
|
|
|
'make.target.modifier': ('green', 'default', 'bold'),
|
|
|
|
'make.target.data': ('green', 'default', 'bold'),
|
|
|
|
|
|
|
|
'make.target.eval.start': ('cyan', 'default', 'bold'),
|
|
|
|
'make.target.eval.word': ('cyan', 'default', 'bold'),
|
|
|
|
'make.target.eval.null': ('cyan', 'default', 'bold'),
|
|
|
|
'make.target.eval.end': ('cyan', 'default', 'bold'),
|
|
|
|
|
|
|
|
'make.extvariable': ('blue', 'default', 'bold'),
|
|
|
|
'make.variable': ('yellow', 'default', 'bold'),
|
2007-10-17 22:44:22 -04:00
|
|
|
}
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = Make.install
|