diff options
author | David Corbett <corbett.dav@husky.neu.edu> | 2014-05-11 12:27:08 -0400 |
---|---|---|
committer | David Corbett <corbett.dav@husky.neu.edu> | 2014-05-11 12:27:08 -0400 |
commit | f7bd44802ad0abdc116b9dfc30c179cd0addecfe (patch) | |
tree | 21740e723a8a72fc098eeb5467ddee403cf19d86 /pygments/lexers/dalvik.py | |
parent | 191a42e86e634f0822fba3bf30eef185adf4dc7b (diff) | |
download | pygments-f7bd44802ad0abdc116b9dfc30c179cd0addecfe.tar.gz |
Distinguish between Jasmin and Smali
Diffstat (limited to 'pygments/lexers/dalvik.py')
-rw-r--r-- | pygments/lexers/dalvik.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pygments/lexers/dalvik.py b/pygments/lexers/dalvik.py index 901b7c5a..4f250b02 100644 --- a/pygments/lexers/dalvik.py +++ b/pygments/lexers/dalvik.py @@ -9,6 +9,8 @@ :license: BSD, see LICENSE for details. """ +import re + from pygments.lexer import RegexLexer, include, bygroups from pygments.token import Keyword, Text, Comment, Name, String, Number, \ Punctuation @@ -102,3 +104,21 @@ class SmaliLexer(RegexLexer): (r'#.*?\n', Comment), ], } + + def analyse_text(text): + if not re.search(r'^\s*\.class\s', text, re.MULTILINE): + return 0 + if re.search(r'(\.(catchall|epilogue|restart local|prologue)|' + r'\b(array-data|class-change-error|declared-synchronized|' + r'(field|inline|vtable)@0x[0-9a-fA-F]|generic-error|' + r'illegal-class-access|illegal-field-access|' + r'illegal-method-access|instantiation-error|no-error|' + r'no-such-class|no-such-field|no-such-method|' + r'packed-switch|sparse-switch))\b', text, re.MULTILINE): + return 1 + if re.search(r'\b(check-cast|instance-of|throw-verification-error)\b|' + r'\b(-to|add|[ais]get|[ais]put|and|cmpl|const|div|if|' + r'invoke|move|mul|neg|not|or|rem|return|rsub|shl|shr|sub|' + r'ushr)[-/]|{|}', text, re.MULTILINE): + return 0.8 + return 0.5 |