Added support for dots in preprocessors
This commit is contained in:
+25
-1
@@ -1780,7 +1780,7 @@ class Parser {
|
|||||||
case '.'.code:
|
case '.'.code:
|
||||||
return TQuestionDot;
|
return TQuestionDot;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.char = char;
|
this.char = char;
|
||||||
return TQuestion;
|
return TQuestion;
|
||||||
case ":".code: return TDoubleDot;
|
case ":".code: return TDoubleDot;
|
||||||
@@ -1872,6 +1872,21 @@ class Parser {
|
|||||||
push(TPOpen);
|
push(TPOpen);
|
||||||
parseExpr();
|
parseExpr();
|
||||||
case TId(id):
|
case TId(id):
|
||||||
|
while(true) {
|
||||||
|
var tk = token();
|
||||||
|
if(tk == TDot) {
|
||||||
|
id += ".";
|
||||||
|
tk = token();
|
||||||
|
switch(tk) {
|
||||||
|
case TId(id2):
|
||||||
|
id += id2;
|
||||||
|
default: unexpected(tk);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
push(tk);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
mk(EIdent(id), tokenMin, tokenMax);
|
mk(EIdent(id), tokenMin, tokenMax);
|
||||||
case TOp("!"):
|
case TOp("!"):
|
||||||
mk(EUnop("!", true, parsePreproCond()), tokenMin, tokenMax);
|
mk(EUnop("!", true, parsePreproCond()), tokenMin, tokenMax);
|
||||||
@@ -1884,6 +1899,14 @@ class Parser {
|
|||||||
switch( expr(e) ) {
|
switch( expr(e) ) {
|
||||||
case EIdent(id):
|
case EIdent(id):
|
||||||
return preprocValue(id) != null;
|
return preprocValue(id) != null;
|
||||||
|
case EField(e2, f):
|
||||||
|
switch(expr(e2)) {
|
||||||
|
case EIdent(id):
|
||||||
|
return preprocValue(id + "." + f) != null;
|
||||||
|
default:
|
||||||
|
error(EInvalidPreprocessor("Can't eval " + expr(e).getName() + " with " + expr(e2).getName()), readPos, readPos);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
case EUnop("!", _, e):
|
case EUnop("!", _, e):
|
||||||
return !evalPreproCond(e);
|
return !evalPreproCond(e);
|
||||||
case EParent(e):
|
case EParent(e):
|
||||||
@@ -1937,6 +1960,7 @@ class Parser {
|
|||||||
var pos = readPos;
|
var pos = readPos;
|
||||||
while( true ) {
|
while( true ) {
|
||||||
var tk = token();
|
var tk = token();
|
||||||
|
// TODO: Fix ending in with #end in the file
|
||||||
if( tk == TEof )
|
if( tk == TEof )
|
||||||
error(EInvalidPreprocessor("Unclosed"), pos, pos);
|
error(EInvalidPreprocessor("Unclosed"), pos, pos);
|
||||||
if( preprocStack[spos] != obj ) {
|
if( preprocStack[spos] != obj ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user