-
Notifications
You must be signed in to change notification settings - Fork 768
Description
The code for HaxeLexer.analyse_text is:
def analyse_text(text):
if re.match(r'\w+\s*:\s*\w', text):
return 0.3
I believe this was meant to be re.search instead of re.match. The problem with re.match is that it only checks at the beginning of the text.
Haxe files usually start with comments or package imports, so checking this regex at the beginning of the text doesn't make much sense. See for instance the example files.
Note that the return 0.3 might conflict with other lexers if this is fixed. For instance, test_guess_carbon_lexer has an example Carbon code on which CarbonLexer.analyse_text returns 0.2, whereas HaxeLexer.analyse_text would return 0.3. So maybe this 0.3 should be lowered to something like 0.09. After all, lots of languages have the pattern r'\w+\s*:\s*\w'. Even a python dict comprehension matches this pattern. So its score should be pretty low.
In addition, ActionScript3 also has the exact same issue: ActionScript3Lexer.analyse_text