Exemple #1
0
        /// <summary>
        /// Compile the whole program. Compile does not execute the program, it only parses
        /// program text and stores it into SILple commands fastly accessible at execution time.
        /// It has to be called prior to execution.
        /// </summary>
        /// <param name="text">The full program text</param>
        public static void Compile(string text)
        {
            FunctionTable.Clear();
            FunctionPrototype prototype = new FunctionPrototype();

            prototype.Actions        = null;
            prototype.ParameterTypes = new ObjectType[] { };
            prototype.ReturnType     = ObjectType.Void;
            FunctionTable.Add("Main", prototype);

            SymbolTable.Clear();
            ArrayTable.Arrays.Clear();

            actions_ = Parser.Parse(text, action_OnAction);
            //verify that all functions were defined
            string functionName;

            if (!FunctionTable.IsDefined(out functionName))
            {
                throw new Exception(string.Format("Function \"{0}\" is not defined!", functionName));
            }
        }
Exemple #2
0
 //Dispose local variables
 public void EndFunction()
 {
     SymbolTable.Clear(name_);
 }