0
0

make compare use strict typing

This commit is contained in:
DrMaxNix 2022-09-08 13:50:37 +02:00
parent 7b967b2e59
commit e23418cf6f
3 changed files with 5 additions and 12 deletions

View File

@ -107,14 +107,10 @@ if|ifl <cond>
$1 # same as `$1 == true` $1 # same as `$1 == true`
!$1 # same as `$1 != true` !$1 # same as `$1 != true`
# loosely typed compare # strongly typed compare
$1 == $2 $1 == $2
$1 != $2 $1 != $2
# strongly typed compare
$1 === $2
$1 !== $2
# numerical / alphabetical compare # numerical / alphabetical compare
$1 < $2 $1 < $2
$1 <= $2 $1 <= $2

View File

@ -78,15 +78,13 @@ class Juicescript_lexer {
// OPERATORS // // OPERATORS //
case "!": case "!":
if (!this.match("=")) this.token_add({type: Juicescript.token_type.NOT}); if (this.match("=")) this.token_add({type: Juicescript.token_type.NOT_EQUAL});
else if (!this.match("=")) this.token_add({type: Juicescript.token_type.NOT_EQUAL}); else this.token_add({type: Juicescript.token_type.NOT});
else this.token_add({type: Juicescript.token_type.STRICT_NOT_EQUAL});
break; break;
case "=": case "=":
if (!this.match("=")) this.token_add({type: Juicescript.token_type.EQUAL}); 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.warning("unexpected character '" + char + "'");
else this.token_add({type: Juicescript.token_type.STRICT_EQUAL});
break; break;
case "<": case "<":

View File

@ -15,7 +15,6 @@ class Juicescript {
// operators // operators
"NOT", "NOT",
"EQUAL", "NOT_EQUAL", "EQUAL", "NOT_EQUAL",
"STRICT_EQUAL", "STRICT_NOT_EQUAL",
"GREATER", "GREATER_EQUAL", "GREATER", "GREATER_EQUAL",
"LESS", "LESS_EQUAL", "LESS", "LESS_EQUAL",