Parcourir la source

Add new token to lexer/compiler TK_IGNORE to ignore some keywords and make some C/C++ code be compiled, for the moment only "new" is ignored.

mingodad il y a 13 ans
Parent
commit
2b9d6070ba
3 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 5 0
      squirrel/sqcompiler.cpp
  2. 1 0
      squirrel/sqcompiler.h
  3. 1 0
      squirrel/sqlexer.cpp

+ 5 - 0
squirrel/sqcompiler.cpp

@@ -870,6 +870,11 @@ public:
 			_fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->GetConstant(_sourcename));
 			Lex();
 			break;
+		case TK_IGNORE:
+            Warning("Keyword ignored \"%s\" at line %d:%d\n", _lex.Tok2Str(_token),
+                    _lex._currentline, _lex._currentcolumn);
+            Lex(); Factor();
+            break;
 		default: Error(_SC("expression expected"));
 		}
 		return -1;

+ 1 - 0
squirrel/sqcompiler.h

@@ -72,6 +72,7 @@ struct SQVM;
 #define TK_CONST 324
 #define TK___LINE__ 325
 #define TK___FILE__ 326
+#define TK_IGNORE 327
 
 
 typedef void(*CompilerErrorFunc)(void *ud, const SQChar *s);

+ 1 - 0
squirrel/sqlexer.cpp

@@ -68,6 +68,7 @@ void SQLexer::Init(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,Compile
 	ADD_KEYWORD(const,TK_CONST);
 	ADD_KEYWORD(__LINE__,TK___LINE__);
 	ADD_KEYWORD(__FILE__,TK___FILE__);
+	ADD_KEYWORD(new,TK_IGNORE);
 
 	_readf = rg;
 	_up = up;