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 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

View File

@ -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)