Пример #1
0
        public void Indentation()
        {
            AtParser parser = new AtParser();
            parser.Reader = new StringReader(
            @"{
            @code
            int i = 0;
            @text
            123
            @end_text
            @end_code
            }");
            parser.Debug = true;

            Intruder parserIntruder = new Intruder(parser);
            parserIntruder.CallMethod<object>("InitParsing");
            parserIntruder.CallMethod<object>("BuildAst");

            SourceGenerator generator = new SourceGenerator();
            generator.Ast = parserIntruder.ReadField<AtTemplateAst>("ast");
            generator.Debugging = true;
            generator.Walk();

            Console.WriteLine(generator.SourceCode);
        }
Пример #2
0
        public void SingleStaticText()
        {
            AtTemplateAst ast = new AtTemplateAst();
            ast.Head.Parameters.Add(new Parameter("myName", "string"));
            ast.Body.Directives.Add(new StaticText("Hello World!\r\n", 2));

            SourceGenerator generator = new SourceGenerator();
            generator.Ast = ast;
            generator.Debugging = true;
            generator.Walk();

            Console.WriteLine(generator.SourceCode);
        }
Пример #3
0
        private void WalkAst()
        {
            SourceGenerator sourceGenerator = new SourceGenerator();
            sourceGenerator.Ast = this.ast;
            sourceGenerator.Debugging = this.debug;
            sourceGenerator.TemplateFile = this.templateFile;
            sourceGenerator.Walk();

            this.sourceCode = sourceGenerator.SourceCode;
        }