Ejemplo n.º 1
0
        public override object VisitPrimaryExpression(PrimaryExpressionContext context)
        {
            switch (context.ChildCount)
            {
            case 1:
            { var c = context.GetChild(0);
              switch (c)
              {
              case DataStatementContext it:
              { return(Visit(context.dataStatement())); } break;

              case IdContext it:
              { return(Visit(context.id())); } break;
              }
              if (context.t.Type == Discard)
              {
                  return(new Result("var", "_"));
              }
            } break;

            case 2:
            { var id       = ((Result)Visit(context.id()));
              var template = "<" + ((string)Visit(context.templateCall())) + ">";
              var ret      = (new Result(id.text + template, id.text + template));
              ret.rootID = id.text;
              return(ret); } break;
            }
            var r = ((Result)Visit(context.expression()));

            return(new Result(r.data, (new System.Text.StringBuilder().Append("(").Append(r.text).Append(")")).To_Str()));
        }
Ejemplo n.º 2
0
        public override object VisitPrimaryExpression([NotNull] PrimaryExpressionContext context)
        {
            if (context.ChildCount == 1)
            {
                var c = context.GetChild(0);
                if (c is DataStatementContext)
                {
                    return(Visit(context.dataStatement()));
                }
                else if (c is IdContext)
                {
                    return(Visit(context.id()));
                }
                else if (context.t.Type == Self)
                {
                    return(new Result {
                        text = "this", data = "var"
                    });
                }
                else if (context.t.Type == Discard)
                {
                    return(new Result {
                        text = "_", data = "var"
                    });
                }
            }
            else if (context.ChildCount == 2)
            {
                var id       = Visit(context.id()).@as <Result>();
                var template = Visit(context.templateCall()).@as <string>();
                return(new Result {
                    text = id.text + template, data = id.text + template
                });
            }
            var r = (Result)Visit(context.expression());

            return(new Result {
                text = "(" + r.text + ")", data = r.data
            });
        }
Ejemplo n.º 3
0
        public override object VisitPrimaryExpression(PrimaryExpressionContext context)
        {
            if (context.ChildCount == 1)
            {
                var c = context.GetChild(0);
                if (c.@is <DataStatementContext>())
                {
                    return(Visit(context.dataStatement()));
                }
                else if (c.@is <IdContext>())
                {
                    return(Visit(context.id()));
                }
                else if (context.t.Type == Discard)
                {
                    return(new Result()
                    {
                        text = "_", data = "var"
                    });
                }
            }
            else if (context.ChildCount == 4)
            {
                var id       = (Result)(Visit(context.id()));
                var template = (string)("<" + Visit(context.templateCall())) + ">";
                return(new Result()
                {
                    text = id.text + template, data = id.text + template, rootID = id.text
                });
            }
            var r = (Result)(Visit(context.expression()));

            return(new Result()
            {
                text = (new System.Text.StringBuilder().Append("(").Append(r.text).Append(")")).to_str(), data = r.data
            });
        }