summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compiler.c12
-rw-r--r--lexer.c16
-rw-r--r--lexer.h3
3 files changed, 13 insertions, 18 deletions
diff --git a/compiler.c b/compiler.c
index d978f38..4f20be0 100644
--- a/compiler.c
+++ b/compiler.c
@@ -60,7 +60,8 @@ uc_compiler_parse_rules[TK_ERROR + 1] = {
[TK_NUMBER] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_DOUBLE] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_STRING] = { uc_compiler_compile_constant, NULL, P_NONE },
- [TK_BOOL] = { uc_compiler_compile_constant, NULL, P_NONE },
+ [TK_TRUE] = { uc_compiler_compile_constant, NULL, P_NONE },
+ [TK_FALSE] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_NULL] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_THIS] = { uc_compiler_compile_constant, NULL, P_NONE },
[TK_REGEXP] = { uc_compiler_compile_constant, NULL, P_NONE },
@@ -1455,9 +1456,12 @@ uc_compiler_compile_constant(uc_compiler *compiler, bool assignable)
uc_compiler_emit_insn(compiler, compiler->parser->prev.pos, I_LNULL);
break;
- case TK_BOOL:
- uc_compiler_emit_insn(compiler, compiler->parser->prev.pos,
- ucv_boolean_get(compiler->parser->prev.uv) ? I_LTRUE : I_LFALSE);
+ case TK_TRUE:
+ uc_compiler_emit_insn(compiler, compiler->parser->prev.pos, I_LTRUE);
+ break;
+
+ case TK_FALSE:
+ uc_compiler_emit_insn(compiler, compiler->parser->prev.pos, I_LFALSE);
break;
case TK_STRING:
diff --git a/lexer.c b/lexer.c
index 0d0b9b0..a066118 100644
--- a/lexer.c
+++ b/lexer.c
@@ -152,8 +152,8 @@ static const struct keyword reserved_words[] = {
{ TK_BREAK, "break", 5, { 0 } },
{ TK_CATCH, "catch", 5, { 0 } },
{ TK_CONST, "const", 5, { 0 } },
- { TK_BOOL, "false", 5, { .b = false } },
- { TK_BOOL, "true", 4, { .b = true } },
+ { TK_FALSE, "false", 5, { 0 } },
+ { TK_TRUE, "true", 4, { 0 } },
{ TK_ELIF, "elif", 4, { 0 } },
{ TK_ELSE, "else", 4, { 0 } },
{ TK_THIS, "this", 4, { 0 } },
@@ -726,7 +726,6 @@ parse_label(uc_lexer *lex)
{
const struct token *tok = lex->tok;
const struct keyword *word;
- uc_token *rv;
char *ptr;
size_t i;
@@ -739,16 +738,7 @@ parse_label(uc_lexer *lex)
if (lex->lookbehind && lex->lookbehindlen == word->plen && !strncmp(lex->lookbehind, word->pat, word->plen)) {
lookbehind_reset(lex);
- switch (word->type) {
- case TK_BOOL:
- rv = emit_op(lex, lex->source->off - word->plen, word->type, ucv_boolean_new(word->u.b));
- break;
-
- default:
- rv = emit_op(lex, lex->source->off - word->plen, word->type, NULL);
- }
-
- return rv;
+ return emit_op(lex, lex->source->off - word->plen, word->type, NULL);
}
}
}
diff --git a/lexer.h b/lexer.h
index 96cdff8..9f26beb 100644
--- a/lexer.h
+++ b/lexer.h
@@ -96,7 +96,8 @@ typedef enum {
TK_ARROW,
TK_DOT,
TK_RBRACK,
- TK_BOOL,
+ TK_TRUE,
+ TK_FALSE,
TK_NUMBER,
TK_DOUBLE,
TK_STRING,