From 8e28475dc19c48c9721c19c6ef91b1d8668be8bf Mon Sep 17 00:00:00 2001 From: DrMaxNix Date: Tue, 6 Sep 2022 13:58:00 +0200 Subject: [PATCH] :sparkles: create lexer class --- dev/index.php | 1 - src/lexer.js | 20 ++++++++++++++++++++ src/main.js | 21 ++++++++------------- 3 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 src/lexer.js diff --git a/dev/index.php b/dev/index.php index b37e214..5b0fd4a 100644 --- a/dev/index.php +++ b/dev/index.php @@ -97,7 +97,6 @@ document.addEventListener("DOMContentLoaded", function(){ juicescript.parse(juice_program); - juicescript.run(); }); diff --git a/src/lexer.js b/src/lexer.js new file mode 100644 index 0000000..043ac54 --- /dev/null +++ b/src/lexer.js @@ -0,0 +1,20 @@ +class Juicescript_lexer { + /* + CONSTRUCTOR: Return new juicescript lexer for SOURCE with OPTIONS + */ + constructor(source, options){ + // STORE SOURCE // + this.source = source; + + + // STORE IO ADAPTER // + this.io = options.io; + } + + /* + MAIN: Run lexical analysis + */ + scan(){ + /**/this.io.stderr.debug(this.source); + } +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index 4ffb05e..e3425f7 100644 --- a/src/main.js +++ b/src/main.js @@ -26,19 +26,14 @@ class Juicescript { Parse given PROGRAM-STRING and store syntax tree */ parse(program_string){ + // DO SCANNING // + // get lexer + var lexer = new Juicescript_lexer(program_string, { + io: this.io + }); - } - - - - - - // DEBUG STUFFS // - run(){ - this.io.stdout("stdout text"); - this.io.stderr.debug("This debug is a test"); - this.io.stderr.info("This info is a test"); - this.io.stderr.warning("This warning is a test"); - this.io.stderr.error("This error is a test"); + // run lexical analysis + var token_list = lexer.scan(); + /**/console.log(token_list); } } \ No newline at end of file