예제 #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));
            }
예제 #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);
            }