Exemplo n.º 1
0
        private static Expression ParseExpression(ScriptVariableTable scriptVariableTable, TokenStream stream)
        {
            Console.WriteLine("Parse expression needs to resolve any variable lookups");
            Console.WriteLine("Parse expression also needs to work out the return type");

            var expressionTokens = new List <InputToken>();
            var currentToken     = stream.PeekNext();

            while ((int)currentToken.TokenType >= (int)SemanticTokenType.BeginExpressionTokens &&
                   (int)currentToken.TokenType <= (int)SemanticTokenType.EndExpressionTokens)
            {
                expressionTokens.Add(stream.Pop());
                currentToken = stream.GetCurrent();
            }

            var rv = new Expression();

            rv.Instructions = expressionParser.ConvertToReversePolishNotation(scriptVariableTable, expressionTokens);

            return(rv);
        }
        // Parallel index?

        // TODO Set the variables for the Program
        public void LoadVariableTable(ScriptVariableTable variableTable)
        {
            // TODO initalize with copies instead of reference
            programData.ScriptVariableTable = variableTable;
        }