Parse() public method

public Parse ( TextReader input ) : PrologCodeUnit
input System.IO.TextReader
return Axiom.Compiler.CodeObjectModel.PrologCodeUnit
コード例 #1
0
        protected virtual PrologCompilerResults FromFile(PrologCompilerParameters options, string fileName)
        {
            PrologCompilerResults results = new PrologCompilerResults();
            PrologCodeParser      parser  = new PrologCodeParser();
            PrologCodeUnit        unit    = new PrologCodeUnit();

            try
            {
                StreamReader reader = new StreamReader(fileName);
                unit = parser.Parse(reader);
            }
            catch (FileNotFoundException)
            {
                results.Errors.Add(new PrologCompilerError("P0008", "Input file not found.", fileName, false, 0, 0));
                return(results);
            }
            return(FromUnit(options, unit));
        }
コード例 #2
0
        PrologCompilerResults IPrologCompiler.CompileAbstractCodeFromFile(PrologCompilerParameters p, string fileName)
        {
            PrologCompilerResults results = new PrologCompilerResults();
            PrologCodeParser      parser  = new PrologCodeParser();
            PrologCodeUnit        unit    = new PrologCodeUnit();

            try
            {
                StreamReader reader = new StreamReader(fileName);
                unit = parser.Parse(reader);

                /* Get errors after parsing */
                results.Errors = parser.Errors;
            }
            catch (FileNotFoundException)
            {
                results.Errors.Add(new PrologCompilerError("P0008", "Input file not found.", fileName, false, 0, 0));
                return(results);
            }
            results.AbstractInstructions = new ArrayList();
            GenerateCodeFromUnit(unit, results.AbstractInstructions);

            /* patch predicates */
            //PatchPredicates(results.AbstractInstructions, GetPredicateAddresses(results.AbstractInstructions));

            /* Save foreign methods */
            //results.ForeignMethods = GetForeignMethods(unit.Methods);

            /* save namespaces */
            results.Namespaces = unit.Namespaces;

            /* save assembly files */
            results.AssemblyFiles = unit.AssemblyFiles;

            /* return results */
            return(results);
        }
コード例 #3
0
        PrologCompilerResults IPrologCompiler.CompileAbstractCodeFromFile(PrologCompilerParameters p, string fileName)
        {
            PrologCompilerResults results = new PrologCompilerResults();
            PrologCodeParser parser = new PrologCodeParser();
            PrologCodeUnit unit = new PrologCodeUnit();
            try
            {
                StreamReader reader = new StreamReader(fileName);
                unit = parser.Parse(reader);

                /* Get errors after parsing */
                results.Errors = parser.Errors;
            }
            catch (FileNotFoundException)
            {
                results.Errors.Add(new PrologCompilerError("P0008", "Input file not found.", fileName, false, 0, 0));
                return results;
            }
            results.AbstractInstructions = new ArrayList();
            GenerateCodeFromUnit(unit, results.AbstractInstructions);

            /* patch predicates */
            //PatchPredicates(results.AbstractInstructions, GetPredicateAddresses(results.AbstractInstructions));

            /* Save foreign methods */
            //results.ForeignMethods = GetForeignMethods(unit.Methods);

            /* save namespaces */
            results.Namespaces = unit.Namespaces;

            /* save assembly files */
            results.AssemblyFiles = unit.AssemblyFiles;

            /* return results */
            return results;
        }
コード例 #4
0
 protected virtual PrologCompilerResults FromFile(PrologCompilerParameters options, string fileName)
 {
     PrologCompilerResults results = new PrologCompilerResults();
     PrologCodeParser parser = new PrologCodeParser();
     PrologCodeUnit unit = new PrologCodeUnit();
     try
     {
         StreamReader reader = new StreamReader(fileName);
         unit = parser.Parse(reader);
     }
     catch (FileNotFoundException)
     {
         results.Errors.Add(new PrologCompilerError("P0008", "Input file not found.", fileName, false, 0, 0));
         return results;
     }
     return FromUnit(options, unit);
 }