From ad8d67413f915b1379b3e5ea113a3a7ecfc82f29 Mon Sep 17 00:00:00 2001 From: DrMaxNix Date: Wed, 7 Sep 2022 17:09:03 +0200 Subject: [PATCH] :sparkles: add scanner for variables prefixed with ampersand --- src/lexer.js | 14 ++++++++++++++ src/main.js | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/lexer.js b/src/lexer.js index 1923b89..13a293e 100644 --- a/src/lexer.js +++ b/src/lexer.js @@ -173,6 +173,20 @@ class Juicescript_lexer { break; + // AMPERSAND // + case "&": + // only if there's a dollar sign after it + if(this.peek() === "$"){ + // add token + this.token_add({type: Juicescript.token_type.AMPERSAND}); + break; + } + + // ignore with warning + this.warning("unexpected character '" + char + "'"); + break; + + // EVERYTHING ELSE // default: // numbers diff --git a/src/main.js b/src/main.js index 8dcd378..f5d3d44 100644 --- a/src/main.js +++ b/src/main.js @@ -23,6 +23,9 @@ class Juicescript { "BRACKET_SQUARE_OPEN", "BRACKET_SQUARE_CLOSE", "BRACKET_CURLY_OPEN", "BRACKET_CURLY_CLOSE", + // special chars + "AMPERSAND", + // meta stuff "EOF" );