aboutsummaryrefslogtreecommitdiff
path: root/boot/lexer.ll
diff options
context:
space:
mode:
Diffstat (limited to 'boot/lexer.ll')
-rw-r--r--boot/lexer.ll22
1 files changed, 17 insertions, 5 deletions
diff --git a/boot/lexer.ll b/boot/lexer.ll
index faae3d7..e84af85 100644
--- a/boot/lexer.ll
+++ b/boot/lexer.ll
@@ -17,7 +17,19 @@ along with GCC; see the file COPYING3. If not see
%{
#define YY_NO_UNISTD_H
-#define YY_USER_ACTION this->location.columns(yyleng);
+#define YY_USER_ACTION do { \
+ for (int i = 0; i < yyleng; i++) \
+ { \
+ if (yytext[i] == '\n') \
+ { \
+ this->location.lines(1); \
+ } \
+ else \
+ { \
+ this->location.columns(1); \
+ } \
+ } \
+} while (0);
#include <sstream>
#include "parser.hh"
@@ -47,7 +59,6 @@ BIGIT [01]
[^*\n]+ ; /* Eat comment in chunks. */
\* ; /* Eat the lone star. */
\n+ {
- this->location.lines(yyleng);
this->location.step();
}
}
@@ -56,7 +67,6 @@ BIGIT [01]
this->location.step();
}
\n+ {
- this->location.lines(yyleng);
}
if {
return yy::parser::make_IF(this->location);
@@ -220,20 +230,22 @@ of {
return yy::parser::make_FLOAT(result, this->location);
}
}
-'[[:print:]]+' {
+'([[:print:]]{-}['\\]|[[:blank:]]|\n|\r|\\.|\\\n)+' {
std::optional<std::string> result = escape_string(yytext);
if (!result.has_value() || result.value().size() != 1)
{
REJECT;
}
+ normalize_newlines(result.value());
return yy::parser::make_CHARACTER(result.value(), this->location);
}
-\"[[:print:]]*\" {
+\"([[:print:]]{-}[\"\\]|[[:blank:]]|\n|\r|\\.|\\\n)*\" {
std::optional<std::string> result = escape_string(yytext);
if (!result.has_value())
{
REJECT;
}
+ normalize_newlines(result.value());
return yy::parser::make_STRING(result.value(), this->location);
}
\( {