aboutsummaryrefslogtreecommitdiff
path: root/src/lexer.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer.l')
-rw-r--r--src/lexer.l25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/lexer.l b/src/lexer.l
index 39c9443..5317966 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -25,7 +25,7 @@
yylloc.last_column = 1; \
} while (false) \
-extern bool interactive;
+extern bool interactive, utf8;
extern const char *current_file;
%}
@@ -77,12 +77,27 @@ ws [ \t]
offending token but instead on the next line typed by the user. */
. {
char ch = *yytext;
+
+ static const char *quotes[][2] = {
+ {"`", "'"},
+ {"‘", "’"},
+ };
+
+ const char *lquot = quotes[utf8][0],
+ *rquot = quotes[utf8][1];
+
if (ch == '&') {
- user_error("%s:%d:%d: Unrecognized character ‘%c’, did you mean ‘%c%c’?",
- current_file, yylloc.first_line, yylloc.first_column, ch, ch, ch);
+ user_error("%s:%d:%d: Unrecognized character %s&%s, did you mean %s&&%s?",
+ current_file, yylloc.first_line, yylloc.first_column,
+ lquot, rquot, lquot, rquot);
+ } else if (ch == '^') {
+ user_error("%s:%d:%d: Unrecognized character %s^%s, did you mean %s~%s?",
+ current_file, yylloc.first_line, yylloc.first_column,
+ lquot, rquot, lquot, rquot);
} else {
- user_error("%s:%d:%d: Unrecognized character ‘%c’",
- current_file, yylloc.first_line, yylloc.first_column, ch);
+ user_error("%s:%d:%d: Unrecognized character %s%c%s",
+ current_file, yylloc.first_line, yylloc.first_column,
+ lquot, ch, rquot);
}
BEGIN(error);
return YYerror;