0
0

tokenize newline and ; as delimiters

This commit is contained in:
DrMaxNix 2022-09-08 13:36:00 +02:00
parent ad8d67413f
commit 7b967b2e59
4 changed files with 15 additions and 3 deletions

View File

@ -2,7 +2,6 @@
# one-line comments (from prefix to EOL) # one-line comments (from prefix to EOL)
mov $1 42 # comment mov $1 42 # comment
mov $1 42 // comment mov $1 42 // comment
mov $1 42 ; comment
# block comments # block comments
/* /*
@ -14,6 +13,11 @@ mov $1 42 ; comment
mov /* Inline block comment */ $1 42 mov /* Inline block comment */ $1 42
## DELIMITERS ##
# `;` acts like a fake newline
mov $1 42; typ $1; echo $1
## ESCAPE SEQUENCES AND INTEGER PREFIXES ## ## ESCAPE SEQUENCES AND INTEGER PREFIXES ##
# quote escaping # quote escaping
"Here comes a quote: \"Lorem ipsum\". This had to be escaped!" "Here comes a quote: \"Lorem ipsum\". This had to be escaped!"

View File

@ -63,8 +63,15 @@ class Juicescript_lexer {
break; break;
// DELIMITER //
case ";":
this.token_add({type: Juicescript.token_type.DELIMITER});
break;
// NEWLINE // // NEWLINE //
case "\n": case "\n":
this.token_add({type: Juicescript.token_type.DELIMITER});
this.line++; this.line++;
break; break;
@ -113,7 +120,6 @@ class Juicescript_lexer {
// COMMENTS // // COMMENTS //
case "#": case "#":
case ";":
case "/": case "/":
// block comment // block comment
if(char === "/" && this.match("*")){ if(char === "/" && this.match("*")){

View File

@ -26,6 +26,9 @@ class Juicescript {
// special chars // special chars
"AMPERSAND", "AMPERSAND",
// delimiters
"DELIMITER",
// meta stuff // meta stuff
"EOF" "EOF"
); );

View File

@ -1,6 +1,5 @@
mov $1 42 # comment mov $1 42 # comment
mov $1 42 // comment mov $1 42 // comment
mov $1 42 ; comment
# block comments # block comments
/* /*