Example #1
0
 //not_test: 'not' not_test | comparison
 private Expression ParseNotTest()
 {
     if (MaybeEat(TokenKind.KeywordNot)) {
         string proceeding = _tokenWhiteSpace;
         var start = GetStart();
         Expression ret = new UnaryExpression(JOperator.Not, ParseNotTest());
         if (_verbatim) {
             AddPreceedingWhiteSpace(ret, proceeding);
         }
         ret.SetLoc(start, GetEnd());
         return ret;
     } else {
         return ParseComparison();
     }
 }
Example #2
0
 // factor: ('+'|'-'|'~') factor | power
 private Expression ParseFactor()
 {
     var start = _lookahead.Span.Start;
     Expression ret;
     switch (PeekToken().Kind) {
         case TokenKind.Add:
             NextToken();
             string posWhiteSpace = _tokenWhiteSpace;
             ret = new UnaryExpression(JOperator.Pos, ParseFactor());
             if (_verbatim) {
                 AddPreceedingWhiteSpace(ret, posWhiteSpace);
             }
             break;
         case TokenKind.Subtract:
             NextToken();
             ret = FinishUnaryNegate();
             break;
         case TokenKind.Twiddle:
             NextToken();
             string twiddleWhiteSpace = _tokenWhiteSpace;
             ret = new UnaryExpression(JOperator.Invert, ParseFactor());
             if (_verbatim) {
                 AddPreceedingWhiteSpace(ret, twiddleWhiteSpace);
             }
             break;
         default:
             return ParsePower();
     }
     ret.SetLoc(start, GetEnd());
     return ret;
 }