Exemple #1
0
        public void ToCode(string grammar, TextWriter writer, string className = "GeneratedGrammar")
        {
            GoldDefinition definition = Build(grammar);
            var            iw         = new IndentedTextWriter(writer, "    ");

            iw.WriteLine("/* Date Created: {0}, Source:", DateTime.Now);
            iw.Indent++;
            foreach (string line in grammar.Split('\n'))
            {
                iw.WriteLine(line);
            }
            iw.Indent--;
            iw.WriteLine("*/");

            var parserWriter = new CodeParserWriter
            {
                ClassName = className
            };

            parserWriter.Write(definition.Grammar, writer);
        }
Exemple #2
0
 protected override int InnerParse(ParseArgs args)
 {
     definition = new GoldDefinition();
     return(base.InnerParse(args));
 }