summaryrefslogtreecommitdiff
path: root/prolog/lexer.py
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2014-07-02 15:39:16 +0200
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:00 +0200
commit77cdeccc9f277054f4276521ff486f5c7639cba0 (patch)
tree716d2bb39498d89b692241d48bc06a6f052e1e71 /prolog/lexer.py
parent284ddd268604175bd8712804a85bc2c431aa2927 (diff)
Lexer: increase priority for t_comment
Multiline comments were not lexed correctly because /* was interpreted as an operator.
Diffstat (limited to 'prolog/lexer.py')
-rwxr-xr-xprolog/lexer.py12
1 files changed, 5 insertions, 7 deletions
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()
-
-