From e23418cf6f22d07f75a308c20c7110ae4b3e1ee8 Mon Sep 17 00:00:00 2001 From: DrMaxNix Date: Thu, 8 Sep 2022 13:50:37 +0200 Subject: [PATCH] :sparkles: make compare use strict typing --- doc/concept.sh | 6 +----- src/lexer.js | 10 ++++------ src/main.js | 1 - 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/doc/concept.sh b/doc/concept.sh index 35d11cc..026560f 100644 --- a/doc/concept.sh +++ b/doc/concept.sh @@ -107,14 +107,10 @@ if|ifl $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 diff --git a/src/lexer.js b/src/lexer.js index a4efd78..4455aea 100644 --- a/src/lexer.js +++ b/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 "<": diff --git a/src/main.js b/src/main.js index 47fb636..9b9cfdf 100644 --- a/src/main.js +++ b/src/main.js @@ -15,7 +15,6 @@ class Juicescript { // operators "NOT", "EQUAL", "NOT_EQUAL", - "STRICT_EQUAL", "STRICT_NOT_EQUAL", "GREATER", "GREATER_EQUAL", "LESS", "LESS_EQUAL",