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