Beispiel #1
0
        public Module parseFile(string filename)
        {
            if (filename != null)
            {
                var lexer = new Pytocs.Syntax.Lexer(filename, fs.CreateStreamReader(filename));
                var parser = new Pytocs.Syntax.Parser(filename, lexer);
                var moduleStmts = parser.Parse().ToList();
                var posStart = moduleStmts[0].Start;
                var posEnd = moduleStmts.Last().End;
                return new Module(
                    _.moduleName(fs, filename),
                    new SuiteStatement(file, posStart, posEnd) { stmts = moduleStmts },
                    filename, posStart, posEnd);
            }
            file = filename;
            content = fs.ReadFile(filename);

            Node node2 = parseFileInner(filename, python2Process);
            if (node2 != null)
            {
                return (Module) node2;
            }
            else if (python3Process != null)
            {
                Node node3 = parseFileInner(filename, python3Process);
                if (node3 == null)
                {
                    _.msg("failed to parse: " + filename);
                    Analyzer.self.failedToParse.Add(filename);
                    return null;
                }
                else
                {
                    return (Module) node3;
                }
            }
            else
            {
                _.msg("failed to parse: " + filename);
                Analyzer.self.failedToParse.Add(filename);
                return null;
            }
        }
Beispiel #2
0
        public Module parseFile(string filename)
        {
            if (filename != null)
            {
                var lexer = new Pytocs.Syntax.Lexer(filename, fs.CreateStreamReader(filename));
                var parser = new Pytocs.Syntax.Parser(filename, lexer);
                var moduleStmts = parser.Parse().ToList();
                var posStart = moduleStmts[0].Start;
                var posEnd = moduleStmts.Last().End;
                return new Module(
                    _.moduleName(fs, filename),
                    new SuiteStatement(file, posStart, posEnd) { stmts = moduleStmts },
                    filename, posStart, posEnd);
            }
            file = filename;
            content = fs.ReadFile(filename);

            Node node2 = parseFileInner(filename, python2Process);
            if (node2 != null)
            {
                return (Module) node2;
            }
            else if (python3Process != null)
            {
                Node node3 = parseFileInner(filename, python3Process);
                if (node3 == null)
                {
                    _.msg("failed to parse: " + filename);
                    Analyzer.self.failedToParse.Add(filename);
                    return null;
                }
                else
                {
                    return (Module) node3;
                }
            }
            else
            {
                _.msg("failed to parse: " + filename);
                Analyzer.self.failedToParse.Add(filename);
                return null;
            }
        }