45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
import color, mode
|
|
from lex import Grammar, PatternRule, RegionRule
|
|
from mode.scheme import SchemeGrammar
|
|
from mode.python import StringGrammar1, StringGrammar2
|
|
|
|
class CommentGrammar(Grammar):
|
|
rules = [PatternRule(r'data', r'(?:[^%]|%[^}])+')]
|
|
|
|
class LilyGrammar(Grammar):
|
|
rules = [
|
|
PatternRule(r'comment', r'%.*$'),
|
|
RegionRule(r'comment', r'%\{', CommentGrammar, r'%\}'),
|
|
|
|
RegionRule(r'string', r'"', StringGrammar2, r'"'),
|
|
|
|
PatternRule(r'delimiter', r'(?:[=(){}\[\];:,.])'),
|
|
|
|
PatternRule(r'note', r"[a-g][sf]?[',]*(?![a-z-])"),
|
|
|
|
PatternRule(r'measure', r'(?:[0-9]+\.)?[0-9]+\\(?:mm|cm|in)'),
|
|
|
|
RegionRule(r'scheme', r'#\(', SchemeGrammar, '\)'),
|
|
PatternRule(r'directive', r'\\[a-zA-Z_][a-zA-Z_0-9]*'),
|
|
PatternRule(r'bareword', r'[a-zA-Z][a-zA-Z_0-9-]*[a-zA-Z0-9]'),
|
|
]
|
|
|
|
class Lily(mode.Fundamental):
|
|
modename = 'lily'
|
|
extensions = ['.ly']
|
|
grammar = LilyGrammar
|
|
commentc = '%'
|
|
colors = {
|
|
'note': ('yellow', 'default'),
|
|
'directive': ('cyan', 'default'),
|
|
'scheme.start': ('magenta', 'default'),
|
|
'scheme.end': ('magenta', 'default'),
|
|
'measure': ('green', 'default'),
|
|
}
|
|
opentokens = ('delimiter',)
|
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
|
closetokens = ('delimiter',)
|
|
closetags = {')': '(', ']': '[', '}': '{'}
|
|
|
|
install = Lily.install
|