Exemplo n.º 1
0
        private static Expression ParseBaseExpression(Scanner scanner)
        {
            int    intvalue;
            string strvalue;

            if (scanner.TryGetIdentifier("null"))
            {
                return(new NullExpression());
            }
            else if (scanner.TryGetIdentifier("true"))
            {
                return(new TrueExpression());
            }
            else if (scanner.TryGetIdentifier("false"))
            {
                return(new FalseExpression());
            }
            else if (scanner.TryGetIdentifier("new"))
            {
                scanner.GetIdentifier(out strvalue);
                //return new NewExpression(strvalue);
                throw new NotImplementedException();
            }
            else if (scanner.TryGetIdentifier(out strvalue))
            {
                return(new VariableExpression(strvalue));
            }
            else if (scanner.TryGetInteger(out intvalue))
            {
                return(new IntegerLiteralExpression(intvalue));
            }
            else if (scanner.TryGetString(out strvalue))
            {
                return(new StringLiteralExpression(strvalue));
            }
            else if (scanner.TryGetSpecial(out strvalue))
            {
                return(new EnvironmentExpression(strvalue));
            }
            else if (scanner.TryGetDelimiter("("))
            {
                Expression expression = ParseExpression(scanner);
                scanner.GetDelimiter(")");
                return(expression);
            }
            else
            {
                throw new ApplicationException();
            }
        }
Exemplo n.º 2
0
 private static Expression ParseBaseExpression(Scanner scanner)
 {
     int intvalue;
     string strvalue;
     if (scanner.TryGetIdentifier("null"))
     {
         return new NullExpression();
     }
     else if (scanner.TryGetIdentifier("true"))
     {
         return new TrueExpression();
     }
     else if (scanner.TryGetIdentifier("false"))
     {
         return new FalseExpression();
     }
     else if (scanner.TryGetIdentifier("new"))
     {
         scanner.GetIdentifier(out strvalue);
         //return new NewExpression(strvalue);
         throw new NotImplementedException();
     }
     else if (scanner.TryGetIdentifier(out strvalue))
     {
         return new VariableExpression(strvalue);
     }
     else if (scanner.TryGetInteger(out intvalue))
     {
         return new IntegerLiteralExpression(intvalue);
     }
     else if (scanner.TryGetString(out strvalue))
     {
         return new StringLiteralExpression(strvalue);
     }
     else if (scanner.TryGetSpecial(out strvalue))
     {
         return new EnvironmentExpression(strvalue);
     }
     else if (scanner.TryGetDelimiter("("))
     {
         Expression expression = ParseExpression(scanner);
         scanner.GetDelimiter(")");
         return expression;
     }
     else
     {
         throw new ApplicationException();
     }
 }