✨ make compare use strict typing
This commit is contained in:
parent
7b967b2e59
commit
e23418cf6f
@ -107,14 +107,10 @@ if|ifl <cond>
|
||||
$1 # same as `$1 == true`
|
||||
!$1 # same as `$1 != true`
|
||||
|
||||
# loosely typed compare
|
||||
# strongly typed compare
|
||||
$1 == $2
|
||||
$1 != $2
|
||||
|
||||
# strongly typed compare
|
||||
$1 === $2
|
||||
$1 !== $2
|
||||
|
||||
# numerical / alphabetical compare
|
||||
$1 < $2
|
||||
$1 <= $2
|
||||
|
10
src/lexer.js
10
src/lexer.js
@ -78,15 +78,13 @@ class Juicescript_lexer {
|
||||
|
||||
// OPERATORS //
|
||||
case "!":
|
||||
if (!this.match("=")) this.token_add({type: Juicescript.token_type.NOT});
|
||||
else if (!this.match("=")) this.token_add({type: Juicescript.token_type.NOT_EQUAL});
|
||||
else this.token_add({type: Juicescript.token_type.STRICT_NOT_EQUAL});
|
||||
if (this.match("=")) this.token_add({type: Juicescript.token_type.NOT_EQUAL});
|
||||
else this.token_add({type: Juicescript.token_type.NOT});
|
||||
break;
|
||||
|
||||
case "=":
|
||||
if (!this.match("=")) this.token_add({type: Juicescript.token_type.EQUAL});
|
||||
else if (!this.match("=")) this.token_add({type: Juicescript.token_type.EQUAL});
|
||||
else this.token_add({type: Juicescript.token_type.STRICT_EQUAL});
|
||||
if (this.match("=")) this.token_add({type: Juicescript.token_type.EQUAL});
|
||||
else this.warning("unexpected character '" + char + "'");
|
||||
break;
|
||||
|
||||
case "<":
|
||||
|
@ -15,7 +15,6 @@ class Juicescript {
|
||||
// operators
|
||||
"NOT",
|
||||
"EQUAL", "NOT_EQUAL",
|
||||
"STRICT_EQUAL", "STRICT_NOT_EQUAL",
|
||||
"GREATER", "GREATER_EQUAL",
|
||||
"LESS", "LESS_EQUAL",
|
||||
|
||||
|
Reference in New Issue
Block a user