bool PPUnaryExpression(PPScanner scan) { bool not = false; PPToken ppt = scan.peek(); while (ppt.getKind() == PPToken.eNot) { scan.next(); not = !not; ppt = scan.peek(); } return not ^ PPPrimaryExpression(scan); }
bool PPEqualityExpression(PPScanner scan) { bool e1, e2; e1 = PPUnaryExpression(scan); int tk = scan.peek().getKind(); while (tk == PPToken.eEQ || tk == PPToken.eNE) { scan.next(); e2 = PPUnaryExpression(scan); if (tk == PPToken.eEQ) { e1 = e1 == e2; } else { // tk == PPToken.eNE e1 = e1 != e2; } tk = scan.peek().getKind(); } return e1; }
// preprocessor expression parser start bool PPOrExpression(PPScanner scan) { bool e1, e2; e1 = PPAndExpression(scan); while (scan.peek().getKind() == PPToken.eOr) { scan.next(); e2 = PPAndExpression(scan); e1 = e1 || e2; } return e1; }
bool PPAndExpression(PPScanner scan) { bool e1, e2; e1 = PPEqualityExpression(scan); while (scan.peek().getKind() == PPToken.eAnd) { scan.next(); e2 = PPEqualityExpression(scan); e1 = e1 && e2; } return e1; }