Ejemplo n.º 1
0
        public XmlElement Visit(IdentifierParseNode i)
        {
            var el = makeNode(i, "identifier");

            addProperty(el, "name", i.Name);
            return(el);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public Node Visit(IdentifierParseNode i)
        {
            var ret = new ImplicitReceiverRequestNode(i.Token, i);
            var rpn = new RequestPartNode(i.Name, new List <Node>(), new List <Node>());

            ret.AddPart(rpn);
            return(ret);
        }
Ejemplo n.º 3
0
 /// <inheritdoc/>
 public override ParseNode Visit(IdentifierParseNode ipn)
 {
     // A bare identifier that matches an element of the
     // set of disallowed names will always raise an error,
     // but the other cases below avoid visiting such a
     // node if it is in a valid place.
     if (_names.Contains(ipn.Name))
     {
         ErrorReporting.ReportStaticError(ipn.Token.Module,
                                          ipn.Line, "P1043",
                                          new Dictionary <string, string> {
             { "name", ipn.Name }
         },
                                          "Invalid use of parent name");
     }
     return(ipn);
 }
Ejemplo n.º 4
0
 private GraceBlock(EvaluationContext ctx, List <Node> parameters,
                    List <Node> body, BlockNode node)
 {
     this.parameters = parameters;
     this.body       = body;
     this.node       = node;
     lexicalScope    = ctx.Memorise();
     applyName       = MethodHelper.ArityNamePart("apply", parameters.Count);
     AddMethod(applyName, null);
     AddMethod("spawn", null);
     AddMethod("asString", null);
     if (parameters.Count == 1)
     {
         AddMethod("match(_)", null);
         AddMethod("|(_)", Matching.OrMethod);
         AddMethod("&(_)", Matching.AndMethod);
         var par   = parameters[0];
         var first = par as ParameterNode;
         if (first != null && first.Type != null)
         {
             Pattern = first.Type.Evaluate(ctx);
         }
         else if (par is NumberLiteralNode || par is StringLiteralNode ||
                  par is ExplicitReceiverRequestNode)
         {
             Pattern         = par.Evaluate(ctx);
             explicitPattern = true;
             var t  = par.Location;
             var id = new IdentifierParseNode(
                 new IdentifierToken(t.module, t.line, t.column,
                                     "_"));
             this.parameters = new List <Node> {
                 new ParameterNode(t, id)
             };
         }
     }
 }
Ejemplo n.º 5
0
        /// <inheritdoc />
        public Node Visit(BlockParseNode d)
        {
            var  parameters    = new List <Node>();
            Node forcedPattern = null;

            foreach (ParseNode p in d.Parameters)
            {
                var id    = p as IdentifierParseNode;
                var tppn  = p as TypedParameterParseNode;
                var vappn = p as VarArgsParameterParseNode;
                if (id != null)
                {
                    parameters.Add(new ParameterNode(id.Token, id));
                }
                else if (tppn != null)
                {
                    parameters.Add(
                        new ParameterNode(tppn.Token,
                                          tppn.Name as IdentifierParseNode,
                                          tppn.Type.Visit(this)));
                }
                else if (vappn != null)
                {
                    // Inside could be either an identifier or a
                    // TypedParameterParseNode - check for both.
                    var inIPN  = vappn.Name as IdentifierParseNode;
                    var inTPPN = vappn.Name as TypedParameterParseNode;
                    if (inIPN != null)
                    {
                        parameters.Add(new ParameterNode(inIPN.Token,
                                                         inIPN,
                                                         true // Variadic
                                                         ));
                    }
                    else if (inTPPN != null)
                    {
                        parameters.Add(new ParameterNode(inTPPN.Token,
                                                         inTPPN.Name as IdentifierParseNode,
                                                         true, // Variadic
                                                         inTPPN.Type.Visit(this)
                                                         ));
                    }
                }
                else if (p is NumberParseNode || p is StringLiteralParseNode ||
                         p is OperatorParseNode)
                {
                    parameters.Add(p.Visit(this));
                }
                else if (p is ParenthesisedParseNode)
                {
                    var tok = p.Token;
                    var it  = new IdentifierToken(tok.module, tok.line,
                                                  tok.column, "_");
                    id = new IdentifierParseNode(it);
                    parameters.Add(new ParameterNode(tok, id, p.Visit(this)));
                }
                else
                {
                    throw new Exception("unimplemented - unusual parameters");
                }
            }
            var ret = new BlockNode(d.Token, d,
                                    parameters,
                                    map(d.Body),
                                    forcedPattern);

            return(ret);
        }
Ejemplo n.º 6
0
 public void VisitIdentifier(IdentifierParseNode node)
 {
     Print($"Identifier (Parse Tree Node) (Name={node.Name})");
 }
Ejemplo n.º 7
0
 /// <inheritdoc/>
 public virtual ParseNode Visit(IdentifierParseNode i)
 {
     return(i);
 }
Ejemplo n.º 8
0
 public void VisitIdentifier(IdentifierParseNode node)
 {
 }
Ejemplo n.º 9
0
 public void VisitIdentifier(IdentifierParseNode node)
 {
     VisitPreOrder(node);
     VisitPostOrder(node);
 }
Ejemplo n.º 10
0
 public void VisitIdentifier(IdentifierParseNode node)
 {
     IdentifierVisitor?.Visit(node);
 }