🧑💻 move some syntax checks to parser
This commit is contained in:
parent
b730713c0c
commit
46f60b6f9d
25
src/lexer.js
25
src/lexer.js
@ -184,15 +184,7 @@ class Juicescript_lexer {
|
|||||||
// SPECIAL CHARS //
|
// SPECIAL CHARS //
|
||||||
// ampersand
|
// ampersand
|
||||||
case "&":
|
case "&":
|
||||||
// only if there's a dollar sign after it
|
this.token_add({type: Juicescript.token_type.AMPERSAND});
|
||||||
if(this.peek() === "$"){
|
|
||||||
// add token
|
|
||||||
this.token_add({type: Juicescript.token_type.AMPERSAND});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ignore with error
|
|
||||||
this.error("unexpected character '" + this.char + "'");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// question mark
|
// question mark
|
||||||
@ -365,21 +357,6 @@ class Juicescript_lexer {
|
|||||||
let variable = this.source.substring(this.start + 1, this.end);
|
let variable = this.source.substring(this.start + 1, this.end);
|
||||||
|
|
||||||
|
|
||||||
// CHECK IF THERE EVEN IS A NAME //
|
|
||||||
if(variable.length <= 0){
|
|
||||||
// has curly bracket after it?
|
|
||||||
if(this.peek() === "{"){
|
|
||||||
// add token without value
|
|
||||||
this.token_add({type: Juicescript.token_type.VARIABLE});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ignore with error
|
|
||||||
this.error("unexpected character '" + this.source.charAt(this.start) + "'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ADD TOKEN //
|
// ADD TOKEN //
|
||||||
this.token_add({type: Juicescript.token_type.VARIABLE, value: variable});
|
this.token_add({type: Juicescript.token_type.VARIABLE, value: variable});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user