from tab import StackTabber2 from mode import Fundamental from lex import Grammar, PatternRule, RegionRule, PatternMatchRule from mode.sh import ShGrammar from mode.xml import XMLGrammar from mode.pipe import Pipe from method.shell import Interact from method import Method, arg import default import urllib2 import os chr1 = '[a-zA-Z_]' chr2 = '[a-zA-Z_0-9]' word = chr1 + chr2 + '*' class NestedCommentGrammar(Grammar): pass NestedCommentGrammar.rules = [ RegionRule('comment', r'/\*', NestedCommentGrammar, r'\*/'), PatternRule('data', r'(?:[^\*]|\*(?!/))+'), ] class StringGrammar(Grammar): rules = [ PatternRule('escaped', r"\\u[0-9A-Fa-f]{4}|\\[0-7]{1,3}|\\[btnfr\"'\\]"), PatternRule('data', r'[^\\"]+'), ] class SubTypeGrammar(Grammar): pass SubTypeGrammar.rules = [ RegionRule('sub', r'\[', SubTypeGrammar, r'\]'), PatternRule('scala.type', '[a-zA-Z0-9_]+'), PatternRule('spaces', ' +'), ] class ScalaGrammar(Grammar): rules = [ PatternRule('scala.comment', '//.*$'), RegionRule('scala.comment', r'/\*', NestedCommentGrammar, r'\*/'), RegionRule('scala.script', r'#!.+$', ShGrammar, r'!#'), PatternMatchRule('x', r'(:)([a-zA-Z0-9_]+)', 'delimiter', 'scala.type'), PatternMatchRule('x', r'(:)( +)([a-zA-Z0-9_]+)', 'delimiter', 'spaces', 'scala.type'), #PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)([a-zA-Z0-9_]+)', # 'delimiter', 'scala.type'), #PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)( +)([a-zA-Z0-9_]+)', # 'delimiter', 'spaces', 'scala.type'), PatternMatchRule('x', r'(extends)( +)([a-zA-Z0-9_]+)', 'scala.reserved', 'spaces', 'scala.type'), PatternMatchRule('x', r'(with)( +)([a-zA-Z0-9_]+)', 'scala.reserved', 'spaces', 'scala.type'), #PatternRule('delimiter', r'(?:;|{|}|\[|\]|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'), RegionRule('sub', r'(?<=:)\(', SubTypeGrammar, r'\)'), PatternRule('delimiter', r'(?:;|{|}|\(|\)|,|\.|<(?![a-zA-Z_])|>|:|/|\+|-|\*|=)'), RegionRule('sub', r'\[', SubTypeGrammar, r'\]'), RegionRule('scala.inline', r'(?:^| )(?=<[a-zA-Z_])', XMLGrammar, '^[ \t]*$'), PatternRule('spaces', r'(?:\t| )+'), PatternRule('eol', r'\n'), PatternRule('scala.def', '(?<=(?