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

View File

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

View File

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

View File

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