From 111bd2546c9e3017edd72f414bbeed746fbf58a8 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Wed, 6 Oct 2010 17:17:41 -0400 Subject: [PATCH 1/4] improved type grammar slightly, and add 'to' keyword --HG-- branch : pmacs2 --- mode/rst.py | 4 ++-- mode/scala.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mode/rst.py b/mode/rst.py index 70fde25..eb7746c 100644 --- a/mode/rst.py +++ b/mode/rst.py @@ -24,8 +24,8 @@ class RSTGrammar(Grammar): RegionRule(r'strong_emphasis', r'\*\*', RSTString1, r'\*\*'), RegionRule(r'emphasis', r'\*', RSTString1, r'\*'), - RegionRule(r'inline_literal', r'``', RSTString2, r'``'), - RegionRule(r'interpreted', r'`', RSTString2, r'`_?'), + #RegionRule(r'inline_literal', r'``', RSTString2, r'``'), + #RegionRule(r'interpreted', r'`', RSTString2, r'`_?'), PatternRule(r'anonymous', r'[a-zA-Z]+__'), PatternRule(r'reference', r'[a-zA-Z]+_(?![a-zA-Z0-9_])'), diff --git a/mode/scala.py b/mode/scala.py index 7224bf4..6c0e2d0 100644 --- a/mode/scala.py +++ b/mode/scala.py @@ -50,6 +50,7 @@ class ScalaGrammar(Grammar): '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'\]'), @@ -65,7 +66,7 @@ class ScalaGrammar(Grammar): PatternRule('scala.pseudo', '(?:true|null|false)'), - PatternRule('scala.reserved', '(?:yield|with|while|var|val|until|type|true|try|trait|throw|this|super|sealed|return|protected|private|package|override|object|null|new|match|lazy|import|implicit|if|forSome|for|finally|final|false|extends|else|do|def|class|catch|case|abstract)(?!%s)' % word), + PatternRule('scala.reserved', '(?:yield|with|while|var|val|until|type|true|try|trait|throw|to|this|super|sealed|return|protected|private|package|override|object|null|new|match|lazy|import|implicit|if|forSome|for|finally|final|false|extends|else|do|def|class|catch|case|abstract)(?!%s)' % word), PatternRule('scala.integer', '-?(?:0|[1-9])[0-9]*[Ll]?'), PatternRule('scala.integer', '-?0x[0-9A-Fa-f]+[Ll]?'), From 7f02011b88947bdc471134dfd3c93baff637bcb8 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Sat, 16 Oct 2010 11:03:34 -0400 Subject: [PATCH 2/4] improvements to nasm mode --HG-- branch : pmacs2 --- lex.py | 4 ++-- mode/nasm.py | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lex.py b/lex.py index bd41af8..93f4c0a 100755 --- a/lex.py +++ b/lex.py @@ -351,8 +351,8 @@ class RegionRule(Rule): if self.pairs[i][1]: try: stopre = re.compile(self.pairs[i][1] % matchd, self.reflags) - except: - raise Exception, "%r\n%r\n%r" % (self.pairs[i][1], matchd, self.reflags) + except Exception, e: + raise Exception, "%r\n%r\n%r\n%r" % (e, self.pairs[i][1], matchd, self.reflags) else: stopre = None if i == len(self.pairs) - 1: diff --git a/mode/nasm.py b/mode/nasm.py index 73faf78..c7060de 100644 --- a/mode/nasm.py +++ b/mode/nasm.py @@ -11,15 +11,19 @@ word = chr1 + chr2 + '*' class NasmGrammar(Grammar): rules = [ + PatternRule('comment', ';.*$'), + RegionRule('comment', '%if +0', Grammar, r'%%endif'), + # for use with ndisasm files - PatternRule('nasm.address', '^[0-9a-fA-F]+ +[0-9a-fA-F]+'), + PatternMatchRule('x', '^([0-9a-fA-F]{8})( )([0-9a-fA-F]+)', 'nasm.integer', 'spaces', 'nasm.address'), + PatternRule('nasm.address', '^[0-9a-fA-F]{8} [0-9a-fA-F]+'), PatternRule('spaces', ' +'), PatternRule("nasm.integer", "(0[xX][0-9a-fA-F]+|0|[1-9][0-9]*|0[0-7]+)[lL]?"), PatternRule('nasm.register', "(?:eax|ebx|ecx|edx|ax|ah|al|bx|bh|bl|bp|cx|ch|cl|cmpsb|dh|di|dl|ds|dx|esi|es|edi|esp|ebp|si|sp|stosd)(?!" + chr2 + ")"), PatternRule('nasm.pseudo', "(?:a16|a32|byte|db|dd|do|dq|dt|dword|qword|tword|fs|gs|near|o16|o32|short)(?!" + chr2 + ")"), PatternRule('nasm.instruction', "(?:jg|jeq|jecxz|jne|ja|jmp|push|pushad|pushfd|call|ret|sub|adc|add|popad|popaw|popa|popfd|pop|call|and|arpl|bound|cwd|cdq|clc|cld|cli|cmp|cmpxchg|cpuid|das|dec|divpd|div|enter|leave|fadd|fld|fmul|fsqrt|fsub|fs|hlt|imul|inc|insb|insd|insw|ins|int|int3|in|jcxz|jc|jna|jnc|jnz|jo|js|jz|lea|lldt|loadsb|lock|loopne|movzx|movd|mov|mul|neg|not|nop|or|outsb|outsd|outsw|repe|retf|rol|sal|sar|sbb|scasw|shl|shr|shld|shrd|sldt|syscall|sysenter|sysexit|test|xchg|xadd|xor)(?!" + chr2 + ")"), - PatternRule('nasm.macro', "%(?:define|undef|assign|strlen|macro|endmacro|if|elif|else|endif|ifdef|ifndef|include|push|pop|stacksize)(?!" + chr2 + ")"), + PatternRule('nasm.macro', "\%(?:define|undef|assign|strlen|macro|endmacro|if|elif|else|endif|ifdef|ifndef|include|push|pop|stacksize)(?!" + chr2 + ")"), PatternRule('nasm.keyword', "(?:section|global|extern)(?!" + chr2 + ")"), PatternRule('nasm.prefix', "(?:dword|word|lock)(?!" + chr2 + ")"), PatternMatchRule('x', '(' + word + ')(:)', 'nasm.label', 'delimiter'), @@ -30,7 +34,6 @@ class NasmGrammar(Grammar): RegionRule('string', "'''", StringGrammar3, "'''"), RegionRule('string', '"', StringGrammar2, '"'), RegionRule('string', "'", StringGrammar1, "'"), - PatternRule('comment', ';.*$'), PatternRule('eol', '\n'), PatternRule('continuation', r'\\\n$'), ] From 42b97aaf40eaefbd5f37aab880b0948fdf6130e3 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Sat, 16 Oct 2010 11:10:39 -0400 Subject: [PATCH 3/4] not about future bug fixing --HG-- branch : pmacs2 --- mode/nasm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mode/nasm.py b/mode/nasm.py index c7060de..c4c4f4d 100644 --- a/mode/nasm.py +++ b/mode/nasm.py @@ -30,9 +30,10 @@ class NasmGrammar(Grammar): PatternRule("nasm.identifier", r'\$?' + word), PatternRule("nasm.float", r"[0-9]+\.[0-9]*|\.[0-9]+|([0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+"), PatternRule('delimiter', r'(?://|%%|<<|>>|[~!\.\*/%\-\+\(\)\[\],\|\^\&])'), + # TODO: nasm strings seem like they are single-line only RegionRule('string', '"""', StringGrammar4, '"""'), RegionRule('string', "'''", StringGrammar3, "'''"), - RegionRule('string', '"', StringGrammar2, '"'), + RegionRule('string', '"', StringGrammar2, '"'), RegionRule('string', "'", StringGrammar1, "'"), PatternRule('eol', '\n'), PatternRule('continuation', r'\\\n$'), From a63e076bfc3e090edc4876e5ced36963d0868842 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Tue, 19 Oct 2010 16:56:38 -0400 Subject: [PATCH 4/4] improve type highlighting --HG-- branch : pmacs2 --- mode/scala.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mode/scala.py b/mode/scala.py index 6c0e2d0..ef358a1 100644 --- a/mode/scala.py +++ b/mode/scala.py @@ -39,10 +39,14 @@ class ScalaGrammar(Grammar): RegionRule('scala.comment', r'/\*', NestedCommentGrammar, r'\*/'), RegionRule('scala.script', r'#!.+$', ShGrammar, r'!#'), - PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)([a-zA-Z0-9_]+)', + PatternMatchRule('x', r'(:)([a-zA-Z0-9_]+)', 'delimiter', 'scala.type'), - PatternMatchRule('x', r'(?<=[a-zA-Z0-9_ ])(:)( +)([a-zA-Z0-9_]+)', + 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'),