diff options
Diffstat (limited to 'src/lexer.l')
-rw-r--r-- | src/lexer.l | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lexer.l b/src/lexer.l index 8715932..3b4a2e2 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -1,10 +1,17 @@ %{ #include <err.h> +#include <stdbool.h> #include <stdlib.h> #include "parser.h" #include "pinocchio.h" +#define YY_USER_INIT \ + do { \ + if (!interactive) \ + BEGIN(linecont); \ + } while (false); + #define YY_USER_ACTION \ do { \ yylloc.first_column = yylloc.last_column; \ @@ -16,8 +23,9 @@ } else \ yylloc.last_column++; \ } \ - } while (0); + } while (false); +extern bool interactive; extern const char *current_file; %} @@ -28,6 +36,7 @@ extern const char *current_file; ws [ \t] %x error +%s linecont %% @@ -43,8 +52,11 @@ ws [ \t] \\ { return '\\'; } \n { return EOL; } - /* Allow line-continuation when the newline is suffixed by a backslash */ -\n{ws}*\\ ; + /* Allow line-continuation when the newline is suffixed by a + backslash, but not in interactive mode! Interactive usage should + have this functionality disabled so that you get instant feedback + after hitting the enter key. */ +<linecont>\n{ws}*\\ ; [a-zA-Z] { yylval.ch = *yytext; |