Beispiel #1
0
        public override void ExitStatementUnit(QLParser.StatementUnitContext context)
        {
            IList<ElementBase> children = GetChildren();

            ThrowExceptionIfAny();
            if (children.Count() != 2)
            {
                _astBuilderExceptions.Add(new ParserError("A statement should have only expression and an identifier as children."));
            }

            StatementUnit statement = new StatementUnit(
                (Identifier)children[0],
                (Expression)children[1],
                context.TEXT().GetText(),
                _terminalTypeFactory.GetTypeInstance(context.type()),
                SourceLocation.CreateFor(context)
                );
            AppendToAST(statement);
        }
Beispiel #2
0
        public override void ExitQuestionUnit(QLParser.QuestionUnitContext context)
        {
            IList<ElementBase> children = GetChildren();

            ThrowExceptionIfAny();
            if (children.Count() != 1)
            {
                _astBuilderExceptions.Add(new ParserError("A question should have only identifier as a child."));
            }

            QuestionUnit question = new QuestionUnit(
                (Identifier)children[0],
                _terminalTypeFactory.GetTypeInstance(context.type()),
                context.TEXT().GetText(),
                SourceLocation.CreateFor(context)
                );
            AppendToAST(question);
        }