Ejemplo n.º 1
0
        /// <summary>
        ///     <see cref="BaseExprn" /> := { ident | numeric | string | bool };
        /// </summary>
        /// <returns>
        ///     <see cref="Nodes" />.<see cref="Nodes.Node" />. Monadic
        /// </returns>
        private static Nodes.Node BaseExprn()
        {
            //Go further down the order of precedence
            //Return if at the end of the expression or not Base value
            if ((CurrentToken == null) ||
                ((CurrentToken?.TokenType != Token.TokenTypes.Instruction) &&
                 (CurrentToken?.TokenType != Token.TokenTypes.String) &&
                 (CurrentToken?.TokenType != Token.TokenTypes.Boolean) &&
                 (CurrentToken?.TokenType != Token.TokenTypes.Binary) &&
                 (CurrentToken?.TokenType != Token.TokenTypes.Float) &&
                 (CurrentToken?.TokenType != Token.TokenTypes.Hex) &&
                 (CurrentToken?.TokenType != Token.TokenTypes.Octal) &&
                 (CurrentToken?.TokenType != Token.TokenTypes.Decimal) &&
                 (CurrentToken?.TokenType != Token.TokenTypes.Variable) &&
                 !Helper.IsNumeric(CurrentToken)))
            {
                return(new Nodes.Error("Base value not found"));
            }

            //Create node for base value, and consume the token
            var node = new Nodes.Node(CurrentToken);

            ConsumeToken();
            return(node);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Adds the <paramref name="node" />.
 /// </summary>
 /// <param name="node">The <paramref name="node" />.</param>
 /// <returns><see cref="Nodes" />.<see cref="Nodes.Node" />.</returns>
 public static Nodes.Node AddNode(Nodes.Node node)
 {
     AbstractSyntaxTree.Nodes.Add(node);
     return(node);
 }