Exemple #1
0
        ///   FACTOR: '-'? EXPONENT
        private ASTNode ParseFactor( )
        {
            ASTNode node = default;

            if (IsNext(Token.TokenType.Minus))
            {
                node = new NegationUnaryOperatorASTNode(Accept( ), ParseExponent( ));
            }
            else
            {
                node = ParseExponent( );
            }

            return(node);
        }
Exemple #2
0
 /// FACTOR: '-'? IMPLICT_MUL
 private bool TryParseFactor(out ASTNode node)
 {
     if (IsNext(Token.TokenType.Minus))
     {
         var op = Accept( );
         if (TryParseImplictMultiplication(out node))
         {
             node = new NegationUnaryOperatorASTNode(op, node);
         }
         else
         {
             throw new Exception($"Exception Parsing the Factor Rule at Position {_lexer.Position}");
         }
     }
     else
     {
         TryParseImplictMultiplication(out node);
     }
     return(node != null);
 }
Exemple #3
0
 protected double Evaluate(NegationUnaryOperatorASTNode node) => - 1 * Evaluate(node.Target as dynamic);