Browse Source

Treat 'import' as a special keyword.

pull/43/head
Rafal Kupiec 3 years ago
parent
commit
9100bf0696
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
  1. 1
      engine/lexer.c
  2. 2
      engine/parser.c
  3. 1
      include/ph7int.h

1
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},

2
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) {

1
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 */

Loading…
Cancel
Save