Пример #1
0
        public static List <CatAstNode> Parse(string s)
        {
            Peg.Parser parser = new Peg.Parser(s);

            try {
                bool bResult = parser.Parse(CatGrammar.CatProgram());
                if (!bResult)
                {
                    throw new Exception("failed to parse input");
                }
            } catch (Exception e) {
                Output.WriteLine("Parsing error occured with message: " + e.Message);
                Output.WriteLine(parser.ParserPosition);
                throw e;
            }

            AstProgram tmp = new AstProgram(parser.GetAst());

            return(tmp.mStatements);
        }
Пример #2
0
        public static List<CatAstNode> Parse(string s)
        {
            Peg.Parser parser = new Peg.Parser(s);

            try
            {
                bool bResult = parser.Parse(CatGrammar.CatProgram());
                if (!bResult)
                    throw new Exception("failed to parse input");
            }
            catch (Exception e)
            {
                Output.WriteLine("Parsing error occured with message: " + e.Message);
                Output.WriteLine(parser.ParserPosition);
                throw e;
            }

            AstProgram tmp = new AstProgram(parser.GetAst());
            return tmp.mStatements;
        }