public override Node VisitTypeExpr(ML4DParser.TypeExprContext context) { ExpressionNode node; switch (context.value.Type) { case ML4DLexer.INUM: node = new IntNode(int.Parse(context.value.Text)); break; case ML4DLexer.FNUM: node = new DoubleNode(double.Parse(context.value.Text, CultureInfo.InvariantCulture)); break; case ML4DLexer.BOOLVAL: node = new BoolNode(bool.Parse(context.value.Text)); break; case ML4DLexer.ID: node = new IDNode(context.value.Text); break; default: throw new NotSupportedException($"The value {context.value.Text}, is not allowed."); } return(node); }
/// <summary> /// Exit a parse tree produced by the <c>typeExpr</c> /// labeled alternative in <see cref="ML4DParser.expr"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitTypeExpr([NotNull] ML4DParser.TypeExprContext context) { }
/// <summary> /// Visit a parse tree produced by the <c>typeExpr</c> /// labeled alternative in <see cref="ML4DParser.expr"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitTypeExpr([NotNull] ML4DParser.TypeExprContext context) { return(VisitChildren(context)); }