protected virtual object EvalStart(ParseTree tree, params object[] paramlist)
 {
     return("Could not interpret input; no semantics implemented.");
 }
        /// <summary>
        /// this implements the evaluation functionality, cannot be used directly
        /// </summary>
        /// <param name="tree">the parsetree itself</param>
        /// <param name="paramlist">optional input parameters</param>
        /// <returns>a partial result of the evaluation</returns>
        internal object Eval(ParseTree tree, params object[] paramlist)
        {
            object Value = null;

            switch (Token.Type)
            {
            case TokenType.Start:
                Value = EvalStart(tree, paramlist);
                break;

            case TokenType.Gramatica:
                Value = EvalGramatica(tree, paramlist);
                break;

            case TokenType.Sets:
                Value = EvalSets(tree, paramlist);
                break;

            case TokenType.CuerpoSets:
                Value = EvalCuerpoSets(tree, paramlist);
                break;

            case TokenType.ListaSets:
                Value = EvalListaSets(tree, paramlist);
                break;

            case TokenType.SetDef:
                Value = EvalSetDef(tree, paramlist);
                break;

            case TokenType.Def:
                Value = EvalDef(tree, paramlist);
                break;

            case TokenType.Tokens:
                Value = EvalTokens(tree, paramlist);
                break;

            case TokenType.DeclaracionTokens:
                Value = EvalDeclaracionTokens(tree, paramlist);
                break;

            case TokenType.CuerpoTokens:
                Value = EvalCuerpoTokens(tree, paramlist);
                break;

            case TokenType.ListaTokens:
                Value = EvalListaTokens(tree, paramlist);
                break;

            case TokenType.ListaDefToken:
                Value = EvalListaDefToken(tree, paramlist);
                break;

            case TokenType.DefToken:
                Value = EvalDefToken(tree, paramlist);
                break;

            case TokenType.SimpleToken:
                Value = EvalSimpleToken(tree, paramlist);
                break;

            case TokenType.AgrupaToken:
                Value = EvalAgrupaToken(tree, paramlist);
                break;

            case TokenType.Acciones:
                Value = EvalAcciones(tree, paramlist);
                break;

            case TokenType.DeclaracionAcciones:
                Value = EvalDeclaracionAcciones(tree, paramlist);
                break;

            case TokenType.CuerpoAcciones:
                Value = EvalCuerpoAcciones(tree, paramlist);
                break;

            case TokenType.FuncionReservadas:
                Value = EvalFuncionReservadas(tree, paramlist);
                break;

            case TokenType.CuerpoFunciones:
                Value = EvalCuerpoFunciones(tree, paramlist);
                break;

            case TokenType.ListaAcciones:
                Value = EvalListaAcciones(tree, paramlist);
                break;

            case TokenType.ListaFunciones:
                Value = EvalListaFunciones(tree, paramlist);
                break;

            case TokenType.OtrasFunciones:
                Value = EvalOtrasFunciones(tree, paramlist);
                break;

            case TokenType.Errores:
                Value = EvalErrores(tree, paramlist);
                break;

            case TokenType.ListaErrores:
                Value = EvalListaErrores(tree, paramlist);
                break;

            default:
                Value = Token.Text;
                break;
            }
            return(Value);
        }
예제 #3
0
 public ParseTree Parse(string input)
 {
     tree = new ParseTree();
     return(Parse(input, tree));
 }
 protected object GetValue(ParseTree tree, TokenType type, int index)
 {
     return(GetValue(tree, type, ref index));
 }
예제 #5
0
파일: Parser.cs 프로젝트: wholroyd/TinyPG
 public ParseTree Parse(string input, string fileName)
 {
     tree = new ParseTree();
     return(Parse(input, fileName, tree));
 }