From 9100bf06962c98d2f62617afed87cd85f71dc319 Mon Sep 17 00:00:00 2001 From: belliash Date: Thu, 16 Aug 2018 16:32:28 +0200 Subject: [PATCH] Treat 'import' as a special keyword. --- engine/lexer.c | 1 + engine/parser.c | 2 +- include/ph7int.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/lexer.c b/engine/lexer.c index c90b4a9..69e22b9 100644 --- a/engine/lexer.c +++ b/engine/lexer.c @@ -610,6 +610,7 @@ static sxu32 KeywordCode(const char *z, int n) { {"eval", PH7_KEYWORD_EVAL}, {"do", PH7_KEYWORD_DO}, {"exit", PH7_KEYWORD_EXIT}, + {"import", PH7_KEYWORD_IMPORT}, {"implements", PH7_KEYWORD_IMPLEMENTS}, {"include", PH7_KEYWORD_INCLUDE}, {"empty", PH7_KEYWORD_EMPTY}, diff --git a/engine/parser.c b/engine/parser.c index 05d6687..d1d63fd 100644 --- a/engine/parser.c +++ b/engine/parser.c @@ -327,7 +327,7 @@ PH7_PRIVATE void PH7_DelimitNestedTokens(SyToken *pIn, SyToken *pEnd, sxu32 nTok * or method names. Using them as variable names is generally OK, but could lead to confusion. */ PH7_PRIVATE int PH7_IsLangConstruct(sxu32 nKeyID, sxu8 bCheckFunc) { - if(nKeyID == PH7_KEYWORD_INCLUDE || nKeyID == PH7_KEYWORD_REQUIRE) { + if(nKeyID == PH7_KEYWORD_IMPORT || nKeyID == PH7_KEYWORD_INCLUDE || nKeyID == PH7_KEYWORD_REQUIRE) { return TRUE; } if(bCheckFunc) { diff --git a/include/ph7int.h b/include/ph7int.h index bdd1ab3..80d9c5f 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -1455,6 +1455,7 @@ enum ph7_expr_id { #define PH7_KEYWORD_SWITCH 3 /* switch */ #define PH7_KEYWORD_INTERFACE 5 /* interface */ /* The number '8' is reserved for PH7_TK_ID */ +#define PH7_KEYWORD_IMPORT 9 /* import */ #define PH7_KEYWORD_REQUIRE 10 /* require */ #define PH7_KEYWORD_ELIF 0x4000000 /* elseif: MUST BE A POWER OF TWO */ #define PH7_KEYWORD_ELSE 0x8000000 /* else: MUST BE A POWER OF TWO */