0
0

create lexer class

This commit is contained in:
DrMaxNix 2022-09-06 13:58:00 +02:00
parent 83419929e4
commit 8e28475dc1
3 changed files with 28 additions and 14 deletions

View File

@ -97,7 +97,6 @@
document.addEventListener("DOMContentLoaded", function(){ document.addEventListener("DOMContentLoaded", function(){
juicescript.parse(juice_program); juicescript.parse(juice_program);
juicescript.run();
}); });
</script> </script>
</head> </head>

20
src/lexer.js Normal file
View File

@ -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);
}
}

View File

@ -26,19 +26,14 @@ class Juicescript {
Parse given PROGRAM-STRING and store syntax tree Parse given PROGRAM-STRING and store syntax tree
*/ */
parse(program_string){ parse(program_string){
// DO SCANNING //
// get lexer
var lexer = new Juicescript_lexer(program_string, {
io: this.io
});
} // run lexical analysis
var token_list = lexer.scan();
/**/console.log(token_list);
// 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");
} }
} }