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); }
public override void ExitText(QLParser.TextContext context) { Text literal = new Text(context.TEXT().GetText(), SourceLocation.CreateFor(context)); AppendToAST(literal); }
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); }