From 77cdeccc9f277054f4276521ff486f5c7639cba0 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 2 Jul 2014 15:39:16 +0200 Subject: Lexer: increase priority for t_comment Multiline comments were not lexed correctly because /* was interpreted as an operator. --- prolog/lexer.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'prolog') diff --git a/prolog/lexer.py b/prolog/lexer.py index 008051c..971e8a6 100755 --- a/prolog/lexer.py +++ b/prolog/lexer.py @@ -62,6 +62,11 @@ t_UREAL = r'[0-9]+\.[0-9]+([eE][-+]?[0-9]+)?|inf|nan' t_VARIABLE = r'(_|[A-Z])[a-zA-Z0-9_]*' t_STRING = r'"(""|\\.|[^\"])*"' +# no support for nested comments yet +def t_comment(t): + r'(/\*(.|\n)*?\*/)|(%.*)' + pass + def t_NAME(t): r"'(''|\\.|[^\\'])*'|[a-z][a-zA-Z0-9_]*|[-+*/\\^<>=~:.?@#$&]+|!|;|," if t.lexer.lexpos >= len(t.lexer.lexdata) or t.lexer.lexdata[t.lexer.lexpos] != '(': @@ -70,11 +75,6 @@ def t_NAME(t): t_ignore = ' \t' -# no support for nested comments yet -def t_comment(t): - r'(/\*(.|\n)*?\*/)|(%.*)' - pass - def t_newline(t): r'\n+' t.lexer.lineno += len(t.value) @@ -88,5 +88,3 @@ def t_error(t): return t lexer = lex.lex() - - -- cgit v1.2.1