better bds

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-04-24 18:52:32 +00:00
parent 9d916a29ad
commit 27b2b3db3a
1 changed files with 20 additions and 12 deletions

View File

@ -17,18 +17,22 @@ tbbid = r'[A-Z]{2}\d{3}-\d{3}-\d{3}'
class BDSGrammar(Grammar): class BDSGrammar(Grammar):
rules = [ rules = [
PatternRule(r'comment', r'#.*$'), PatternRule('eol', r'\n'),
PatternRule(r'bds.section', r'section(?= *\()'), PatternRule('spaces', r' +'),
PatternRule(r'bds.component', tbbid + r"(?= *\()"), PatternRule('comment', r'#.*$'),
PatternRule(r'bds.attr_name', r"[a-z_]+(?==)"), PatternRule('delimiter', r'(?:\|\||&&|[!<>=:\{\}\(\)\[\]])'),
RegionRule(r'bds.attr_value', r"(?<=)'", StringGrammar1, r"'"), PatternRule('bds.section', r'section(?= *\()'),
RegionRule(r'bds.attr_value', r'(?<=)"', StringGrammar2, r'"'), PatternRule('bds.component', tbbid + r"(?= *\()"),
PatternRule(r'bds.num', r"-?(?:[0-9][0-9\.]*[0-9]|[0-9])"), PatternRule('bds.attr_name', r"[a-z_]+(?==)"),
PatternRule(r'bds.alias', r"[a-z0-9]+(?=:" + tbbid + ")"), RegionRule('bds.attr_value', r"(?<=)'", StringGrammar1, r"'"),
PatternRule(r'bds.id', tbbid), RegionRule('bds.attr_value', r'(?<=)"', StringGrammar2, r'"'),
PatternRule(r'bds.func', r"[a-zA-Z0-9_]+(?= *\()"), PatternRule('bds.num', r"-?(?:[0-9][0-9\.]*[0-9]|[0-9])"),
RegionRule(r'bds.string', r"'", StringGrammar1, r"'"), PatternRule('bds.alias', r"[a-z0-9]+(?=:" + tbbid + ")"),
RegionRule(r'bds.string', r'"', StringGrammar2, r'"'), PatternRule('bds.id', tbbid),
PatternRule('bds.func', r"[a-zA-Z0-9_]+(?= *\()"),
RegionRule('bds.string', r"'", StringGrammar1, r"'"),
RegionRule('bds.string', r'"', StringGrammar2, r'"'),
PatternRule('bds.bareword', r'[a-zA-Z0-9_]+'),
] ]
class BDS(Fundamental): class BDS(Fundamental):
@ -52,6 +56,10 @@ class BDS(Fundamental):
'bds.string.null': ('red', 'default', 'bold'), 'bds.string.null': ('red', 'default', 'bold'),
'bds.string.end': ('red', 'default', 'bold'), 'bds.string.end': ('red', 'default', 'bold'),
} }
opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
_bindings = { _bindings = {
'close-paren': (')'), 'close-paren': (')'),
'close-bracket': (']'), 'close-bracket': (']'),