Problem when reading backslash in Prolog
Posted
by Jerry
on Stack Overflow
See other posts from Stack Overflow
or by Jerry
Published on 2010-05-15T20:36:12Z
Indexed on
2010/05/15
20:44 UTC
Read the original article
Hit count: 228
swi-prolog
|escape-character
I'm writing a lexer in Prolog which will be used as a part of functional language interpreter. Language spec allows expressions like for example let \x = x + 2;
to occur. What I want lexer to do for such input is to "return":
[tokLet, tokLambda, tokVar(x), tokEq, tokVar(x), tokPlus, tokNumber(2), tokSColon]
and the problem is, that Prolog seems to ignore the \
character and "returns" the line written above except for tokLambda
.
One approach to solve this would be to somehow add second backslash before/after every occurrence of one in the program code (because everything works fine if I change the original input to let \\x = x + 2;
) but I don't really like it.
Any ideas?
© Stack Overflow or respective owner