Beispiel #1
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);
        }
Beispiel #2
0
        private void InitParsing()
        {
            this.ast = new AtTemplateAst();

            this.ast.Head.References.Add(new Reference("System.dll"));
            this.ast.Head.References.Add(new Reference(Assembly.GetExecutingAssembly().Location));

            this.currentDirective = this.ast.Body;

            if (this.outputStack == null)
            {
                this.outputStack = new Stack<OutputContext>();
            }
            else
            {
                this.outputStack.Clear();
            }

            if (this.contextStack == null)
            {
                this.contextStack = new ContextStack();
            }
            else
            {
                this.contextStack.Clear();
            }

            if (this.sections == null)
            {
                this.sections = new Dictionary<string, object>();
            }
            else
            {
                this.sections.Clear();
            }

            this.contextStack.Push(new Context(TemplateMode.Static, string.Empty));

            this.lineCount = 0;
            this.isInGlobalBlock = false;
        }
Beispiel #3
0
 public void Parse()
 {
     try
     {
         InitParsing();
         BuildAst();
         WalkAst();
         this.references = this.ast.Head.References
                          .ConvertAll(reference => reference.Value)
                          .ToArray();
     }
     finally
     {
         this.ast = null;
     }
 }