diff options
-rw-r--r-- | pygments/lexers/dalvik.py | 19 | ||||
-rw-r--r-- | pygments/lexers/jvm.py | 13 |
2 files changed, 17 insertions, 15 deletions
diff --git a/pygments/lexers/dalvik.py b/pygments/lexers/dalvik.py index 4f250b02..f77a74d6 100644 --- a/pygments/lexers/dalvik.py +++ b/pygments/lexers/dalvik.py @@ -106,8 +106,14 @@ class SmaliLexer(RegexLexer): } def analyse_text(text): - if not re.search(r'^\s*\.class\s', text, re.MULTILINE): - return 0 + score = 0 + if re.search(r'^\s*\.class\s', text, re.MULTILINE): + score += 0.5 + if re.search(r'\b((check-cast|instance-of|throw-verification-error' + r')\b|(-to|add|[ais]get|[ais]put|and|cmpl|const|div|' + r'if|invoke|move|mul|neg|not|or|rem|return|rsub|shl|' + r'shr|sub|ushr)[-/])|{|}', text, re.MULTILINE): + score += 0.3 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|' @@ -115,10 +121,5 @@ class SmaliLexer(RegexLexer): 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 + score += 0.6 + return score diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py index f0fe6a50..87bf3ff4 100644 --- a/pygments/lexers/jvm.py +++ b/pygments/lexers/jvm.py @@ -1507,12 +1507,13 @@ class JasminLexer(RegexLexer): } def analyse_text(text): - if not re.search(r'^\s*\.class\s', text, re.MULTILINE): - return 0 + score = 0 + if re.search(r'^\s*\.class\s', text, re.MULTILINE): + score += 0.5 + if re.search(r'^\s*[a-z]+_[a-z]+\b', text, re.MULTILINE): + score += 0.3 if re.search(r'^\s*\.(attribute|bytecode|debug|deprecated|enclosing|' r'inner|interface|limit|set|signature|stack)\b', text, re.MULTILINE): - return 1 - if re.search(r'^\s*[a-z]+_[a-z]+\b', text, re.MULTILINE): - return 0.8 - return 0.5 + score += 0.6 + return score |