remove dead code; add string literals

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2011-12-16 11:54:32 -05:00
parent 87e96d3ed1
commit 7961b689bc
2 changed files with 8 additions and 43 deletions

View File

@ -1,30 +1,23 @@
from mode import Fundamental from mode import Fundamental
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
name = '[a-zA-Z0-9_$.]+'
class JavapGrammar(Grammar): class JavapGrammar(Grammar):
rules = [ 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)( )(.+)$', PatternMatchRule('x', '^(package)( )(.+)$',
'javap.keyword', 'spaces', 'javap.package'), 'javap.keyword', 'spaces', 'javap.package'),
PatternRule('javap.keyword', '(?:static|public|protected|private|final|abstract)'), PatternRule('javap.keyword', '(?:static|public|protected|private|final|abstract)'),
# pseudo keywords
PatternMatchRule('x', '(--class)( +)([^ ]+)', PatternMatchRule('x', '(--class)( +)([^ ]+)',
'javap.pseudo', 'spaces', 'javap.type'), 'javap.pseudo', 'spaces', 'javap.type'),
PatternMatchRule('x', '(--field)( +)([^ ]+)( +)([^ ]+)', PatternMatchRule('x', '(--field)( +)([^ ]+)( +)([^ ]+)',
'javap.pseudo', 'spaces', 'javap.type', 'spaces', 'javap.type'), 'javap.pseudo', 'spaces', 'javap.type', 'spaces', 'javap.type'),
PatternRule('javap.pseudo', '--(?:method|iface|string|field)'), PatternRule('javap.pseudo', '--(?:method|iface|string|field)'),
# parse type args
PatternMatchRule('x', '([^ ]+)( +)(\()', PatternMatchRule('x', '([^ ]+)( +)(\()',
'javap.type', 'spaces', 'javap.delim'), 'javap.type', 'spaces', 'javap.delim'),
PatternMatchRule('x', '(class|extends|implements)( )([^ ]+)', PatternMatchRule('x', '(class|extends|implements)( )([^ ]+)',
'javap.keyword', 'spaces', 'javap.type'), 'javap.keyword', 'spaces', 'javap.type'),
@ -37,32 +30,14 @@ class JavapGrammar(Grammar):
PatternMatchRule('x', '([^ ]+)(\))', PatternMatchRule('x', '([^ ]+)(\))',
'javap.type', 'javap.delim'), '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+)( +)([^ ]+)', PatternMatchRule('x', '^( +)(\d+)( +)([^ ]+)',
'spaces', 'javap.byte', 'spaces', 'javap.ins'), 'spaces', 'javap.byte', 'spaces', 'javap.ins'),
RegionRule('javap.string', r'"', None, r'"'),
PatternRule('javap.const', r'#\d+'), PatternRule('javap.const', r'#\d+'),
PatternRule('javap.int', 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('spaces', r' +'),
PatternRule('eol', r'\n'), PatternRule('eol', r'\n'),
] ]
@ -103,25 +78,15 @@ class Javap(Fundamental):
name = 'Javap' name = 'Javap'
grammar = JavapGrammar() grammar = JavapGrammar()
colors = { colors = {
###'javap.string': ('green', 'default'),
##'javap.label': ('blue', 'default', 'bold'),
#'javap.class': ('cyan', 'default', 'bold'),
'javap.package': hi_yellow, 'javap.package': hi_yellow,
'javap.type': hi_cyan, 'javap.type': hi_cyan,
'javap.method': hi_blue, 'javap.method': hi_blue,
##'javap.abbrev': ('green', 'default', 'bold'),
#'javap.name': ('yellow', 'default', 'bold'),
#'javap.linenum': ('green', 'default', 'bold'),
'javap.byte': lo_orange, 'javap.byte': lo_orange,
'javap.ins': hi_orange, 'javap.ins': hi_orange,
#'javap.cls': ('cyan', 'default', 'bold'),
#'javap.int': ('green', 'default', 'bold'),
'javap.const': hi_yellow, 'javap.const': hi_yellow,
'javap.keyword': hi_magenta, 'javap.keyword': hi_magenta,
'javap.pseudo': hi_magenta, 'javap.pseudo': hi_magenta,
} }
_bindings = { _bindings = {}
'ipython-start': ('M-e',),
}
install = Javap.install install = Javap.install

View File

@ -208,7 +208,7 @@ class ScalaDecompile(Method):
return "class " + self._abbrev(name) return "class " + self._abbrev(name)
elif line.startswith('String'): elif line.startswith('String'):
return 'string' return 'string "%s"' % line
elif line.startswith('Field'): elif line.startswith('Field'):
m = self.field_re.match(line) m = self.field_re.match(line)