From 7961b689bc6855174b26d412c8dd87ff1c947cf5 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Fri, 16 Dec 2011 11:54:32 -0500 Subject: [PATCH] remove dead code; add string literals --HG-- branch : pmacs2 --- mode/javap.py | 49 +++++++------------------------------------------ mode/scala.py | 2 +- 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/mode/javap.py b/mode/javap.py index c82bd52..8a39949 100644 --- a/mode/javap.py +++ b/mode/javap.py @@ -1,30 +1,23 @@ from mode import Fundamental from lex import Grammar, PatternRule, RegionRule, PatternMatchRule -name = '[a-zA-Z0-9_$.]+' - class JavapGrammar(Grammar): rules = [ - #PatternMatchRule('x', r'^( )(\d+:)([ \t]+)([a-z0-9_]+)', - # 'spaces', 'javap.linenum', 'spaces', 'javap.ins'), - #PatternMatchRule('x', r'^( )(\d+:)([ \t]+)([a-z0-9_]+)', - # 'spaces', 'javap.linenum', 'spaces', 'javap.ins'), - #PatternMatchRule('x', r'^( )(\d+:)([ \t]+)([a-z0-9_]+)', - # 'spaces', 'javap.linenum', 'spaces', 'javap.ins'), - PatternMatchRule('x', '^(package)( )(.+)$', 'javap.keyword', 'spaces', 'javap.package'), PatternRule('javap.keyword', '(?:static|public|protected|private|final|abstract)'), + + # pseudo keywords PatternMatchRule('x', '(--class)( +)([^ ]+)', 'javap.pseudo', 'spaces', 'javap.type'), PatternMatchRule('x', '(--field)( +)([^ ]+)( +)([^ ]+)', 'javap.pseudo', 'spaces', 'javap.type', 'spaces', 'javap.type'), PatternRule('javap.pseudo', '--(?:method|iface|string|field)'), + # parse type args PatternMatchRule('x', '([^ ]+)( +)(\()', 'javap.type', 'spaces', 'javap.delim'), - PatternMatchRule('x', '(class|extends|implements)( )([^ ]+)', 'javap.keyword', 'spaces', 'javap.type'), @@ -37,32 +30,14 @@ class JavapGrammar(Grammar): PatternMatchRule('x', '([^ ]+)(\))', 'javap.type', 'javap.delim'), - #PatternMatchRule('x', '(//class )(.+)', 'javap.zcomment', 'javap.class'), - #PatternMatchRule('x', '(//InterfaceMethod )([^:]+)(:)(.+)', - # 'javap.zcomment', 'javap.method', 'javap.zcomment', 'javap.sig'), - #PatternMatchRule('x', '(//Method )([^:]+)(:)(.+)', - # 'javap.zcomment', 'javap.method', 'javap.zcomment', 'javap.sig'), - PatternMatchRule('x', '^( +)(\d+)( +)([^ ]+)', 'spaces', 'javap.byte', 'spaces', 'javap.ins'), + + RegionRule('javap.string', r'"', None, r'"'), + PatternRule('javap.const', r'#\d+'), PatternRule('javap.int', r'\d+'), - #PatternRule('javap.zcomment', r'^Compiled from .*$'), - #PatternRule('javap.zcomment', r'Code:'), - - #PatternMatchRule('x', r'(class)( )(' + name + ')', 'javap.zkeyword', 'spaces', 'javap.class'), - #PatternMatchRule('x', r'(extends)( )(' + name + ')', 'javap.zkeyword', 'spaces', 'javap.class'), - #PatternMatchRule('x', r'(public)( )(static)( )(' + name + ')( )(' + name + ')', - # 'javap.zkeyword', 'spaces', 'javap.zkeyword', 'spaces', - # 'javap.class', 'spaces', 'javap.method'), - - #PatternRule(r'javap.zkeyword', r'(?:static|public|protected|private|extends|class|abstract)'), - #PatternRule(r'javap.cls', r'L[^;]+'), - #PatternRule(r'javap.cls2', r'B|C|D|F|I|J|S|Z|\['), - #PatternRule(r'javap.ins', r'(?<= )\d+:'), - #PatternRule(r'javap.class', name), - PatternRule('spaces', r' +'), PatternRule('eol', r'\n'), ] @@ -103,25 +78,15 @@ class Javap(Fundamental): name = 'Javap' grammar = JavapGrammar() colors = { - ###'javap.string': ('green', 'default'), - ##'javap.label': ('blue', 'default', 'bold'), - #'javap.class': ('cyan', 'default', 'bold'), 'javap.package': hi_yellow, 'javap.type': hi_cyan, 'javap.method': hi_blue, - ##'javap.abbrev': ('green', 'default', 'bold'), - #'javap.name': ('yellow', 'default', 'bold'), - #'javap.linenum': ('green', 'default', 'bold'), 'javap.byte': lo_orange, 'javap.ins': hi_orange, - #'javap.cls': ('cyan', 'default', 'bold'), - #'javap.int': ('green', 'default', 'bold'), 'javap.const': hi_yellow, 'javap.keyword': hi_magenta, 'javap.pseudo': hi_magenta, } - _bindings = { - 'ipython-start': ('M-e',), - } + _bindings = {} install = Javap.install diff --git a/mode/scala.py b/mode/scala.py index a98e075..1766854 100644 --- a/mode/scala.py +++ b/mode/scala.py @@ -208,7 +208,7 @@ class ScalaDecompile(Method): return "class " + self._abbrev(name) elif line.startswith('String'): - return 'string' + return 'string "%s"' % line elif line.startswith('Field'): m = self.field_re.match(line)