Ejemplo n.º 1
0
        public override Node VisitVariable([NotNull] VeeParser.VariableContext context)
        {
            var variableName = context.Name().Symbol.Text;

            if (context.Parents().Any(x => (x is VeeParser.LambdaContext lambda && (ParserUtils.IsDefinedLambdaParam(lambda, variableName) || ParserUtils.IsDefinedDeclaration(lambda.body.declarations(), variableName))) ||
                                      (x is VeeParser.RootContext root && ParserUtils.IsDefinedDeclaration(root.declarations(), variableName))
                                      ))
            {
                return(new Node(variableName, NodeType.BoundedVariable));
            }
Ejemplo n.º 2
0
        public override string VisitVariable(VeeParser.VariableContext context)
        {
            var variableName = context.Name().Symbol.Text;

            // TODO: the variable is local and does not need to be get from the context if it references any of the following
            // - lambda parameter
            // - declaration statements in lambda
            // - declaration statements in root
            // - capture variable in a pattern matching context
            if (context.Parents().Any(x => (x is VeeParser.LambdaContext lambda && (ParserUtils.IsDefinedLambdaParam(lambda, variableName) || ParserUtils.IsDefinedDeclaration(lambda.body.declarations(), variableName))) ||
                                      (x is VeeParser.RootContext root && ParserUtils.IsDefinedDeclaration(root.declarations(), variableName))
                                      ))
            {
                return(variableName);
            }
Ejemplo n.º 3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>variable</c>
 /// labeled alternative in <see cref="VeeParser.expression"/>.
 /// <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 VisitVariable([NotNull] VeeParser.VariableContext context)
 {
     return(VisitChildren(context));
 }