summaryrefslogtreecommitdiff
path: root/pygments/lexers/modula2.py
diff options
context:
space:
mode:
authorMatthäus G. Chajdas <dev@anteru.net>2020-09-22 20:40:58 +0200
committerMatthäus G. Chajdas <dev@anteru.net>2020-09-22 20:40:58 +0200
commitf0d31da6b26e7057dc488d8ee04e06b1a448a49c (patch)
treebb01aa5da7a5f4aa4e3e2a4836b040c535ea977d /pygments/lexers/modula2.py
parent07f596dbb9357c1ec2077bdc4319f594d287ae15 (diff)
downloadpygments-git-task/add-analyze-text.tar.gz
Improve various analyse_text methods.task/add-analyze-text
* Make Perl less confident in presence of :=. * Improve brainfuck check to not parse the whole input. * Improve Unicon by matching \self, /self * Fix Ezhil not matching against the input text
Diffstat (limited to 'pygments/lexers/modula2.py')
-rw-r--r--pygments/lexers/modula2.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pygments/lexers/modula2.py b/pygments/lexers/modula2.py
index c4b95b38..05144222 100644
--- a/pygments/lexers/modula2.py
+++ b/pygments/lexers/modula2.py
@@ -1563,9 +1563,20 @@ class Modula2Lexer(RegexLexer):
def analyse_text(text):
"""Not much we can go by. (* for comments is our best guess."""
result = 0
+
+ is_pascal_like = 0
if '(*' in text and '*)' in text:
- result += 0.01
+ is_pascal_like += 0.5
if ':=' in text:
- result += 0.01
+ is_pascal_like += 0.5
+
+ if is_pascal_like == 1:
+ # Procedure is in Modula2
+ if re.search(r'\bPROCEDURE\b', text):
+ result += 0.6
+
+ # FUNCTION is only valid in Pascal, but not in Modula2
+ if re.search(r'\bFUNCTION\b', text):
+ result = 0.0
return result