summaryrefslogtreecommitdiffhomepage
path: root/lexer.h
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-04-28 23:52:37 +0200
committerJo-Philipp Wich <jo@mein.io>2021-04-29 00:10:56 +0200
commite66b2ad400203c27d7a17edea2b9952f110e9020 (patch)
treeb3ed1d3e4e8141dd215ac3b116a0440bc93b5cbe /lexer.h
parente29b5744132d7dfb2989c70d4255840126d6ad19 (diff)
compiler, lexer: improve lexical state handling
- Instead of disambiguating division operator vs. regexp literal by looking at the preceeding token, raise a "no regexp" flag within the appropriate parser states to tell the lexer how to treat a forward slash when parsing the next token - Introduce another "no keyword" flag which disables parsing labels into keywords when reading the next token and set it in the appropriate parser states. This allows using reserved names in object declarations and property access expressions Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lexer.h')
-rw-r--r--lexer.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/lexer.h b/lexer.h
index 069e9e0..60f6ce0 100644
--- a/lexer.h
+++ b/lexer.h
@@ -132,6 +132,8 @@ typedef struct {
uc_source *source;
uint8_t eof:1;
uint8_t is_escape:1;
+ uint8_t no_regexp:1;
+ uint8_t no_keyword:1;
size_t buflen;
char *buf, *bufstart, *bufend;
size_t lookbehindlen;
@@ -160,7 +162,7 @@ typedef struct {
void uc_lexer_init(uc_lexer *lex, uc_parse_config *config, uc_source *source);
void uc_lexer_free(uc_lexer *lex);
-uc_token *uc_lexer_next_token(uc_lexer *lex, bool no_regexp);
+uc_token *uc_lexer_next_token(uc_lexer *lex);
bool utf8enc(char **out, int *rem, int code);