示例#1
0
        public void ToCode(string bnf, string startParserName, TextWriter writer, string className = "GeneratedGrammar")
        {
            var parser = Build(bnf, startParserName);

#if CORECLR
            var iw = writer;
#else
            var iw = new IndentedTextWriter(writer, "    ");
#endif

            iw.WriteLine("/* Date Created: {0}, Source BNF:", DateTime.Now);
#if !CORECLR
            iw.Indent++;
#endif
            foreach (var line in bnf.Split('\n'))
            {
                iw.WriteLine(line);
            }
#if !CORECLR
            iw.Indent--;
#endif
            iw.WriteLine("*/");

            var parserWriter = new CodeParserWriter
            {
                ClassName = className
            };
            parserWriter.Write(parser, writer);
        }
示例#2
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);
        }
示例#3
0
        public void ToCode(string bnf, string startParserName, TextWriter writer, string className = "GeneratedGrammar")
        {
            Grammar parser = Build(bnf, startParserName);
            var     iw     = new IndentedTextWriter(writer, "    ");

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

            var parserWriter = new CodeParserWriter
            {
                ClassName = className
            };

            parserWriter.Write(parser, writer);
        }
示例#4
0
		public void ToCode(string bnf, string startParserName, TextWriter writer, string className = "GeneratedGrammar")
		{
			var parser = Build(bnf, startParserName);
			
			var parserWriter = new CodeParserWriter
			{
				ClassName = className
			};
			parserWriter.Write(parser, writer);
		}