Ejemplo n.º 1
0
        internal ParserPosition Clone()
        {
            var child = new ParserPosition(Parser);

            child.Index      = Index;
            child.Row        = Row;
            child.Column     = Column;
            child.TraceDepth = TraceDepth;
            return(child);
        }
Ejemplo n.º 2
0
        internal ParserPosition Clone()
        {
            var child = new ParserPosition(Parser, error_collector)
            {
                Index      = Index,
                Row        = Row,
                Column     = Column,
                TraceDepth = TraceDepth
            };

            return(child);
        }
Ejemplo n.º 3
0
        /**
         * Parse a rule and, if succcessful, put the result into the provided list.
         */
        internal static bool ParseIntoList <T>(ref ParserPosition position, List <T> result, ParseRule <T> rule)
        {
            T obj;

            if (rule(ref position, out obj))
            {
                result.Add(obj);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /**
         * Parse an “expression” defined in the language specification.
         */
        public static AstNode ParseExpression(Parser parser)
        {
            expression result;
            var        position = new ParserPosition(parser);

            if (Flabbergast.expression.ParseRule_expression0(ref position, out result) && position.Finished)
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        /**
         * Parse in the “file” context defined in the language specification.
         */
        public static AstNode ParseFile(Parser parser)
        {
            file result;
            var  position = new ParserPosition(parser);

            if (Flabbergast.file.ParseRule_Base(ref position, out result) && position.Finished)
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        /**
         * Parse in the “file” context defined in the language specification.
         */
        public System.Type ParseFile(ErrorCollector collector, CompilationUnit unit, string type_name)
        {
            file result;
            var  position = new ParserPosition(this, collector);

            if (file.ParseRule_Base(ref position, out result) && position.Finished)
            {
                if (result.Analyse(collector))
                {
                    return(unit.CreateRootGenerator(result, type_name, generator => result.Generate(generator, generator.Return)));
                }
            }
            else
            {
                collector.ReportParseError(FileName, Index, Row, Column, Message);
            }
            return(null);
        }
Ejemplo n.º 7
0
        public XmlDocument DocumentFile(ErrorCollector collector, string lib_name, string github)
        {
            file result;
            var  position = new ParserPosition(this, collector);

            if (file.ParseRule_Base(ref position, out result) && position.Finished)
            {
                if (result.Analyse(collector))
                {
                    var api = ApiGenerator.Create(lib_name, github);
                    result.GenerateApi(api, true);
                    return(api.Document);
                }
            }
            else
            {
                collector.ReportParseError(FileName, Index, Row, Column, Message);
            }
            return(null);
        }
Ejemplo n.º 8
0
        /**
         * Parse in the “repl” context defined in the language specification.
         */
        public System.Type ParseRepl(ErrorCollector collector, CompilationUnit unit, string type_name)
        {
            repl result;
            var  position = new ParserPosition(this, collector);

            if (repl.ParseRule_Base(ref position, out result) && position.Finished)
            {
                if (result.Analyse(collector))
                {
                    return(unit.CreateReplGenerator(result, type_name,
                                                    (generator, root, current, update_current, escape_value, print_value) =>
                                                    result.Generate(generator, root, current, update_current, escape_value, print_value,
                                                                    generator.Return)));
                }
            }
            else
            {
                collector.ReportParseError(FileName, Index, Row, Column, Message);
            }
            return(null);
        }