from mode import Fundamental from point import Point from lex import Grammar, PatternRule, RegionRule, OverridePatternRule from mode.lisp import Lisp, LispTabber class StringGrammar(Grammar): rules = [ PatternRule('octal', r'\\[0-7]{3}'), PatternRule('escaped', r'\\.'), PatternRule('data', r'[^\\"]+'), ] # TODO: a lot of these rules need fixing chr1 = '[a-zA-Z_]' chr2 = '[a-zA-Z0-9-_]' symb = chr1 + chr2 + '*' class ELispGrammar(Grammar): rules = [ PatternRule('comment', ';.*$'), PatternRule('delimiter', '[()]'), PatternRule('spaces', ' +'), PatternRule('eol', r'\n'), PatternRule('elisp_reserved', r'(?:t|nil)(?![^\"\' \t()])'), PatternRule('keyword', r'(?:while|when|unless|setq-default|setq|setcar|require|provide|or|not|mapcar|list|let\*|let|lambda|if|exists|equal|defvar|defun|defstruct|defface|defalias|count|cons|c[ad]+r|apply|and)(?![^\"\' \t()])'), PatternRule('elisp_symbol', "'" + symb), PatternRule('delimiter', r"'"), PatternRule('elisp_type', ":" + symb), PatternRule('attribute', "&" + symb), PatternRule("integer", r"(?