コード例 #1
0
 public PftProgram(PftParser.ProgramContext node)
     : base(node)
 {
     // Программа состоит из последовательности операторов
     foreach (PftParser.StatementContext statementContext
              in node.statement())
     {
         Children.Add(new PftStatement(statementContext));
     }
 }
コード例 #2
0
        public PftFormatter ParseInput
        (
            string input
        )
        {
            AntlrInputStream  stream = new AntlrInputStream(input);
            PftLexer          lexer  = new PftLexer(stream);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            PftParser         parser = new PftParser(tokens);

            PftParser.ProgramContext programContext = parser.program();
            Program = new PftProgram(programContext);

            if (!Program.Validate(false))
            {
                throw new ArgumentException();
            }

            return(this);
        }
コード例 #3
0
        public PftProgram
        (
            PftParser.ProgramContext context
        )
        {
            if (context.pftInfoBlock() != null)
            {
                Info = new PftInfoBlock(context.pftInfoBlock());
                Children.Add(Info);
            }

            foreach (PftParser.CompositeElementContext subContext
                     in context.compositeElement())
            {
                PftAst child = PftDispatcher.DispatchFormat(subContext);
                if (!ReferenceEquals(child, null))
                {
                    Children.Add(child);
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="PftParser.program"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitProgram([NotNull] PftParser.ProgramContext context)
 {
 }