Ejemplo n.º 1
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            AstNode sn=AddChild("from", treeNode.ChildNodes[0]);
            AstNode en=AddChild("to", treeNode.ChildNodes[2]);

            var dtsn=sn as DateTimeLiteralNode;
            var dten=en as DateTimeLiteralNode;
            if (dtsn!=null)
            {
                _StartDate=dtsn.Value;

                if (dten!=null)
                    _EndDate=dten.Value;
                else
                    _EndDate=_StartDate+((DurationLiteralNode)en).Value;
            } else
            {
                _EndDate=dten.Value;
                _StartDate=_EndDate-((DurationLiteralNode)sn).Value;
            }

            AsString="period";
        }
Ejemplo n.º 2
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);
            Text = treeNode.Token.Text;

            AsString = "StringValue";
        }
Ejemplo n.º 3
0
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
       foreach (var child in treeNode.ChildNodes)
     AddChild(NodeUseType.Parameter, "param", child);
       AsString = "param_list[" + ChildNodes.Count + "]";
 }
Ejemplo n.º 4
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            foreach (var node in treeNode.ChildNodes)
            {
                // linearize AuxiliaryNode children
                if (node.AstNode is AuxiliaryNode)
                {
                    var auxNode = node.AstNode as AuxiliaryNode;

                    foreach (var n in auxNode.ChildNodes)
                        ChildNodes.Add(n);

                    foreach (var n in auxNode.ChildParseNodes)
                        ChildParseNodes.Add(n);

                    continue;
                }

                // copy AstNode nodes
                if (node.AstNode is AstNode)
                {
                    ChildNodes.Add(node.AstNode as AstNode);
                    continue;
                }

                // otherwise, save parse nodes
                ChildParseNodes.Add(node);
            }
        }
Ejemplo n.º 5
0
        /// <summary>Initializes the current AST node with the specified <paramref name="context" /> and <paramref name="treeNode" />.</summary>
        /// <param name="context">The AST context.</param>
        /// <param name="treeNode">The parse tree node associated with the current AST node.</param>
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            AsString=treeNode.ChildNodes[0].Token.Text;
            _GeometryType=(GeometryType)Enum.Parse(typeof(GeometryType), AsString, true);
        }
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     var term = TerminalFactory.CreateCSharpIdentifier("text");
     var tok = new Token(term, Location, "text", System.String.Join("_", treeNode.ChildNodes.Select(cn => cn.Term.Name)));
     treeNode.Token = tok;
 }
Ejemplo n.º 7
0
    public override void Init(AstContext context, ParseTreeNode parseNode)
		{
			base.Init(context, parseNode);

			foreach (var node in parseNode.ChildNodes)
			{
				if (node.AstNode is Function)
				{
					AddFunction(node.AstNode as Function);
				}
				else if (node.AstNode is AuxiliaryNode)
				{
					var ids = (node.AstNode as AuxiliaryNode).ChildNodes.OfType<IdentifierNode>();

					foreach (var id in ids)
					{
						ExternalFunction ef = new ExternalFunction();
						ef.SetSpan(id.Span);
						ef.Name = id.Symbol;
						AddFunction(ef);
					}
				}
			}

			AsString = "Refal-5 program";
		}
Ejemplo n.º 8
0
 private void InitImpl(AstContext context, ParseTreeNode parseNode, ParseTreeNode parametersNode, ParseTreeNode bodyNode) {
   base.Init(context, parseNode);
   Parameters = AddChild("Parameters", parametersNode);
   Body = AddChild("Body", bodyNode);
   AsString = "Lambda[" + Parameters.ChildNodes.Count + "]";
   Body.SetIsTail(); //this will be propagated to the last statement
 }
Ejemplo n.º 9
0
 public override void Init(AstContext context, ParseTreeNode treeNode) {
   base.Init(context, treeNode);
   foreach (var child in treeNode.ChildNodes) {
       AddChild(NodeUseType.Parameter, "expr", child); 
   }
   AsString = "Expression list";
 }
Ejemplo n.º 10
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);

            var mapped = parseNode.GetMappedChildNodes();

            if (mapped.Count > 2)
            {
                Ident             = (IdentifierNode)AddChild("Ident", mapped[1]);
                Type              = Runtime.StringToTypeInfo(mapped[2].FindTokenAndGetText());
                IsParams          = true;
                IsTypeConstrained = true;
            }
            else if (mapped.Count > 1)
            {
                //params or typeConstrained
                if (mapped[0].Term.Name == "name")
                {
                    Ident             = (IdentifierNode)AddChild("Ident", mapped[0]);
                    Type              = Runtime.StringToTypeInfo(mapped[1].FindTokenAndGetText());
                    IsTypeConstrained = true;
                }
                else
                {
                    Ident    = (IdentifierNode)AddChild("Ident", mapped[1]);
                    IsParams = true;
                }
            }
            else
            {
                Ident = (IdentifierNode)AddChild("Ident", mapped[0]);
            }
        }
Ejemplo n.º 11
0
 // this is where data is initially passed to the item
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     string sVal = treeNode.FindTokenAndGetText();
     base.Init(context, treeNode);
     var nodes = treeNode.GetMappedChildNodes();
     var functionOrProperty = AddChild("FunctionOrId", nodes[0]);
     if (functionOrProperty is SelectFunctionNode)
     {
         _TheFunction = (SelectFunctionNode)functionOrProperty;
     }
     else if (functionOrProperty is SelectPropertyNode)
     {
         _PropNode = (SelectPropertyNode)functionOrProperty;
     }
     else
     {
         throw new Exception("Unmanaged type in selectmemberaccessnode");
     }
     if (nodes.Count > 1)
     {
         var child = AddChild("Queue", nodes[1]);
         string sval = nodes[1].FindTokenAndGetText();
         if (child is LeftObjectNode)
         {
             _queue = (LeftObjectNode)child;
         }
     }
 }
Ejemplo n.º 12
0
 public override void Init(AstContext context, ParseTreeNode treeNode) {
   base.Init(context, treeNode); 
   Value = treeNode.Token.Value;
   AsString = Value == null ? "null" : Value.ToString();
   if (Value is string)
     AsString = "\"" + AsString + "\"";
 }
Ejemplo n.º 13
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            Target = AddChild(AstNodeType.ValueWrite, "To", nodes[0]);

            AssignmentOp = nodes[1].FindTokenAndGetText();
            if (string.IsNullOrEmpty(AssignmentOp))
            {
                AssignmentOp = "=";
            }

            BinaryExpressionType = ExpressionType.Assign;

            Expression  = AddChild(AstNodeType.ValueRead, "Expression", nodes[nodes.Count - 1]);
            AsString    = AssignmentOp + " (assignment)";
            IsAugmented = AssignmentOp.Length > 1;

            if (IsAugmented)
            {
                var ctxt = (AstContext)context;
                ExpressionType       = ctxt.OperationHandler.GetOperatorExpressionType(AssignmentOp);
                BinaryExpressionType = ctxt.OperationHandler.GetBinaryOperatorForAugmented(ExpressionType);
                Target.NodeType      = AstNodeType.ValueReadWrite;
            }
        }
Ejemplo n.º 14
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            var node = treeNode.GetMappedChildNodes()[0];
            this.Label = node.Token.ValueString;
        }
Ejemplo n.º 15
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var valueStr = parseNode.FindToken().Text;

            Value = valueStr.Equals("true");
        }
Ejemplo n.º 16
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);

            target   = GetChildString(parseNode);
            AsString = target;
        }
Ejemplo n.º 17
0
    public override void Init(AstContext context, ParseTreeNode parseNode)
		{
			base.Init(context, parseNode);

			foreach (var node in parseNode.ChildNodes)
			{
				if (node.AstNode is Expression)
				{
					Expression = (node.AstNode as Expression);
				}
				else if (node.AstNode is AuxiliaryNode)
				{
					var nodes = (node.AstNode as AuxiliaryNode).ChildNodes;
					Pattern = nodes.OfType<Pattern>().FirstOrDefault();
					Block = nodes.OfType<Block>().FirstOrDefault();
					MoreConditions = nodes.OfType<Conditions>().FirstOrDefault();
					ResultExpression = nodes.OfType<Expression>().FirstOrDefault();
				}

				foreach (var astNode in new AstNode[] { Expression, Pattern, Block, MoreConditions, ResultExpression })
				{
					if (astNode != null)
						astNode.Parent = this;
				}
			}

			AsString = Block != null ? "with-clause" : "where-clause";
		}
Ejemplo n.º 18
0
 public override void Init(AstContext context, ParseTreeNode treeNode) {
   base.Init(context, treeNode);
   var nodes = treeNode.GetMappedChildNodes();
   _target = AddChild("Target", nodes.First());
   _index = AddChild("Index", nodes.Last()); 
   AsString = "[" + _index + "]";
 }
Ejemplo n.º 19
0
		/// <summary>
		/// Converts identifiers to compound symbols (strings in double quotes),
		/// expands character strings (in single quotes) to arrays of characters
		/// </summary>
		public static void InitNode(AstContext context, ParseTreeNode parseNode)
		{
			foreach (var node in parseNode.ChildNodes)
			{
				if (node.AstNode is LiteralValueNode)
				{
					if (node.Term.Name == "Char")
					{
						var literal = node.AstNode as LiteralValueNode;
						literal.Value = literal.Value.ToString().ToCharArray();
					}

					parseNode.AstNode = node.AstNode;
				}
				else
				{
					// identifiers in expressions are treated as strings (True is same as "True")
					parseNode.AstNode = new LiteralValueNode()
					{
						Value = node.FindTokenAndGetText(),
						Span = node.Span
					};
				}
			}
		}
Ejemplo n.º 20
0
        public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode)
        {
            hijos = new List <Arbol>();//inicializamos la lista
            base.Init(context, treeNode);
            switch ((String)treeNode.Term.Name)
            {           //  0 1 2
            case "E":   // E + E | E - E | E * E  | num
                if (treeNode.ChildNodes.Count > 1)
                {
                    Name = treeNode.ChildNodes[1].FindTokenAndGetText();  //SIGNO
                    hijos.Add((Arbol)treeNode.ChildNodes[0].AstNode);     // PRIMER VALOR
                    hijos.Add((Arbol)treeNode.ChildNodes[2].AstNode);     // SEGUNDO VALOR
                }
                else
                {
                    Name = treeNode.ChildNodes[0].FindTokenAndGetText();     //OBTENEMOS EL NUMERO
                }
                break;

            case "number":
                Name = treeNode.Token.Text;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 21
0
    public override void Init(AstContext context, ParseTreeNode parseNode)
		{
			base.Init(context, parseNode);
			
			foreach (var node in parseNode.ChildNodes)
			{
				if (node.AstNode is Pattern)
				{
					Pattern = node.AstNode as Pattern;
				}
				else if (node.AstNode is AuxiliaryNode)
				{
					var nodes = (node.AstNode as AuxiliaryNode).ChildNodes;
					Conditions = nodes.OfType<Conditions>().FirstOrDefault();
					Expression = nodes.OfType<Expression>().FirstOrDefault();
				}
			}

			foreach (var astNode in new AstNode[] { Pattern, Conditions, Expression })
			{
				if (astNode != null)
				{
					astNode.Parent = this;
				}
			}

			AsString = "match";
		}
Ejemplo n.º 22
0
 public override void Init(AstContext context, ParseTreeNode treeNode) {
   base.Init(context, treeNode);
   var nodes = treeNode.GetMappedChildNodes();
   Test = AddChild("Test", nodes[0]);
   IfTrue = AddChild("IfTrue", nodes[1]);
   if (nodes.Count > 2)
     IfFalse = AddChild("IfFalse", nodes[2]);
 }
Ejemplo n.º 23
0
 public virtual void BuildAst(LanguageData language, ParseTree parseTree)
 {
     if (!LanguageFlags.IsSet(LanguageFlags.CreateAst))
         return;
     var astContext = new AstContext(language);
     var astBuilder = new AstBuilder(astContext);
     astBuilder.BuildAst(parseTree);
 }
Ejemplo n.º 24
0
 public override void Init(AstContext Context, ParseTreeNode ParseNode)
 {
     IsDefault = (ParseNode.ChildNodes[0].FindTokenAndGetText() == "default");
     if (!IsDefault)
     {
         Value = ParseNode.ChildNodes[1];
     }
 }
Ejemplo n.º 25
0
 public override void Init(AstContext context, ParseTreeNode parseNode)
 {
     Debug.Assert("for" == parseNode.ChildNodes[0].FindTokenAndGetText());
     InitialSentence = parseNode.ChildNodes[1];
     ConditionExpresion = parseNode.ChildNodes[2];
     PostSentence = parseNode.ChildNodes[3];
     LoopSentence = parseNode.ChildNodes[4];
 }
Ejemplo n.º 26
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            _AttributeName=(AttributeNameNode)AddChild("", treeNode.ChildNodes[0]);
            _Negated=treeNode.ChildNodes[1].Term.Name.Contains("NOT");

        }
Ejemplo n.º 27
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            _eventEmitter = AddChild(string.Empty, treeNode.ChildNodes[0]) as AstNode;
            _eventName = (treeNode.ChildNodes[1].AstNode as AstNode).AsString;
            _listener = AddChild(string.Empty, treeNode.ChildNodes[2]) as AstNode;
        }
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("EN");
            base.Init(context, treeNode);
            operador = dic[treeNode.ChildNodes[1].FindTokenAndGetText()];

            arg1 = ((AstNode) treeNode.ChildNodes[0].AstNode).Evaluate(null);
            arg2 = ((AstNode)treeNode.ChildNodes[2].AstNode).Evaluate(null);
        }
Ejemplo n.º 29
0
 public override void Init(AstContext context, ParseTreeNode treeNode) {
   base.Init(context, treeNode);
   var nodes = treeNode.GetMappedChildNodes();
   OpSymbol = nodes[0].FindTokenAndGetText();
   Argument = AddChild("Arg", nodes[1]);
   base.AsString = OpSymbol + "(unary op)";
   var interpContext = (InterpreterAstContext)context; 
   base.ExpressionType = interpContext.OperatorHandler.GetUnaryOperatorExpressionType(OpSymbol);
 }
Ejemplo n.º 30
0
        public override void Init(AstContext context, ParseTreeNode parseNode)
        {
            Debug.Assert(parseNode.ChildNodes[0].FindTokenAndGetText() == "function");
            FunctionName = Php54Utils.NormalizeFunctionName(parseNode.ChildNodes[1].FindTokenAndGetText());
            ParametersDeclaration = parseNode.ChildNodes[2];
            CodeStatements = (parseNode.ChildNodes[3].AstNode as Node);

            //throw(new NotImplementedException());
        }
Ejemplo n.º 31
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            target = AddChild("Target", nodes[0]);

            AsString = "import Library";
        }
Ejemplo n.º 32
0
        /// <summary>Initializes the current AST node with the specified <paramref name="context" /> and <paramref name="treeNode" />.</summary>
        /// <param name="context">The AST context.</param>
        /// <param name="treeNode">The parse tree node associated with the current AST node.</param>
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            if (treeNode.ChildNodes.Count>1)
                _Point=AddChild("point", treeNode.ChildNodes[1]) as PointNode;

            AsString="POINT";
        }
Ejemplo n.º 33
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            target   = AddChild("Target", nodes[0]);
            index    = AddChild("Index", nodes[1]);
            AsString = target + "[" + index + "]";
        }
Ejemplo n.º 34
0
 public override void Init(AstContext context, ParseTreeNode treeNode) {
   base.Init(context, treeNode);
   var nodes = treeNode.GetMappedChildNodes();
   TargetRef = AddChild("Target", nodes[0]);
   TargetRef.UseType = NodeUseType.CallTarget;
   _targetName = nodes[0].FindTokenAndGetText();
   Arguments = AddChild("Args", nodes[1]);
   AsString = "Call " + _targetName;
 }
Ejemplo n.º 35
0
        public void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            var ctx = context as AstContext;

            Span              = parseNode.Span;
            FileName          = ctx.FileName;
            parseNode.AstNode = this;
            Init(ctx, parseNode);
        }
Ejemplo n.º 36
0
 // this is where data is initially passed to the item
 public override void Init(AstContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
     var nodes = treeNode.GetMappedChildNodes();
     if (nodes.Count > 0)
     {
         propName = nodes[0].FindTokenAndGetText();
     }
 }
Ejemplo n.º 37
0
 public override void Init(AstContext context, ParseTreeNode treeNode) {
   base.Init(context, treeNode);
   var nodes = treeNode.GetMappedChildNodes();
   _left = AddChild("Target", nodes[0]);
   var right = nodes[nodes.Count - 1];
   _memberName = right.FindTokenAndGetText();
   ErrorAnchor = right.Span.Location; 
   AsString = "." + _memberName;
 }
Ejemplo n.º 38
0
        public override void Init(AstContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            string n=treeNode.Term.ToString();
            Name=string.Concat(n.Substring(0, 1).ToUpperInvariant(), n.Substring(1).ToLowerInvariant());

            AsString=Name;
        }
Ejemplo n.º 39
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);

            var nodes = parseNode.GetMappedChildNodes();

            target      = AddChild("target", nodes[0]);
            alternative = AddChild("target", nodes[1]);
        }
Ejemplo n.º 40
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            Condition = AddChild("Condition", nodes[1]);
            Body      = AddChild("Body", nodes[0]);

            AsString = "Do While Loop";
        }
Ejemplo n.º 41
0
        public override void Init(Irony.Ast.AstContext context, Irony.Parsing.ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);

            Identifier = treeNode.ChildNodes[0].AstNode as IdentifierNode;
            if (treeNode.ChildNodes.Count > 1)
            {
                Source = (SourceNode)treeNode.ChildNodes[1].AstNode;
            }
        }
Ejemplo n.º 42
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            TargetRef  = AddChild("Target", nodes[0]);
            targetName = TargetRef.AsString;
            Arguments  = AddChild("Args", nodes[1]);
            AsString   = "Call " + targetName;
        }
Ejemplo n.º 43
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            foreach (var child in parseNode.ChildNodes)
            {
                AddChild(AstNodeType.Parameter, "expr", child);
            }

            AsString = "Expression List";
        }
Ejemplo n.º 44
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            Target      = AddChild("Target", nodes[0]);
            memberName  = nodes[1].FindTokenAndGetText();
            ErrorAnchor = nodes[1].Span.Location;
            AsString    = "." + memberName;
        }
Ejemplo n.º 45
0
 private void InitImpl(Irony.Ast.AstContext context, ParseTreeNode node, ParseTreeNode parameters, ParseTreeNode body)
 {
     base.Init(context, node);
     lock (lockObject)
     {
         Parameters = AddChild("Parameters", parameters) as ParamListNode;
     }
     Body     = AddChild("Body", body);
     AsString = "Lambda[" + Parameters.ChildNodes.Count + "]";
 }
Ejemplo n.º 46
0
        private void ParseSegments(Irony.Ast.AstContext context)
        {
            var exprParser         = new Parser(context.Language, templateSettings.ExpressionRoot);
            int currentPos         = 0;
            int exprPosInTokenText = 0;

            while (true)
            {
                var startTagPos = template.IndexOf(templateSettings.StartTag, currentPos);
                if (startTagPos < 0)
                {
                    startTagPos = template.Length;
                }
                var text = template.Substring(currentPos, startTagPos - currentPos);

                if (!string.IsNullOrEmpty(text))
                {
                    segments.Add(new TemplateSegment(text, null, 0));
                }

                if (startTagPos >= template.Length)
                {
                    break;
                }

                currentPos = startTagPos + templateSettings.StartTag.Length;
                var endTagPos = template.IndexOf(templateSettings.EndTag, currentPos);
                if (endTagPos < 0)
                {
                    context.AddMessage(Irony.ErrorLevel.Error, Location.SourceLocation, "No endtag in embedded expression found");
                    return;
                }

                var exprText = template.Substring(currentPos, endTagPos - currentPos);

                if (!string.IsNullOrEmpty(exprText))
                {
                    var exprTree = exprParser.Parse(exprText);
                    if (exprTree.HasErrors())
                    {
                        var baseLocation = Location.SourceLocation + tokenText.IndexOf(exprText);
                        CopyMessages(exprTree.ParserMessages, context.Messages, baseLocation, "");
                        return;
                    }

                    exprPosInTokenText = tokenText.IndexOf(templateSettings.StartTag, exprPosInTokenText) + templateSettings.StartTag.Length;
                    var segmNode = exprTree.Root.AstNode as AstNode;
                    segments.Add(new TemplateSegment(null, segmNode, exprPosInTokenText));

                    exprPosInTokenText += exprText.Length + templateSettings.EndTag.Length;
                }

                currentPos = endTagPos + templateSettings.EndTag.Length;
            }
        }
Ejemplo n.º 47
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            IterVarBlock = AddChild("IterVar", nodes[0]);
            InExpr       = AddChild("InExpr", nodes[1]);
            Block        = AddChild("ForeachBlock", nodes[2]);

            AsString = "Forech Loop";
        }
Ejemplo n.º 48
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            target      = AddChild("Target", nodes[1]) as IdentifierNode;
            parameters  = AddChild("Parameters", nodes[2]) as ParamListNode;
            isExtension = string.Equals(nodes[3].FindTokenAndGetText(), "extension", StringComparison.CurrentCultureIgnoreCase);

            AsString = "<extern " + (isExtension ? "Extension " : "") + "Function " + target.AsString + "[" + parameters.ChildNodes.Count + "]>";
        }
Ejemplo n.º 49
0
        public virtual void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            var acon = context as AstContext;

            Term              = parseNode.Term;
            Span              = parseNode.Span;
            Location          = new SourceInfo(Span.Location, acon.FileName);
            ErrorAnchor       = Location;
            parseNode.AstNode = this;
            AsString          = (Term == null ? GetType().Name : Term.Name);
        }
Ejemplo n.º 50
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            OpSymbol = nodes[0].FindTokenAndGetText();
            Argument = AddChild("Arg", nodes[1]);
            AsString = OpSymbol + "(unary op)";
            var interpContext = (AstContext)context;

            ExpressionType = interpContext.OperationHandler.GetUnaryOperatorExpressionType(OpSymbol);
        }
Ejemplo n.º 51
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            if (nodes.Any())
            {
                Expression = AddChild("Expression", nodes[0]);
            }

            AsString = "return" + (nodes.Any() ? " Expression" : "");
        }
Ejemplo n.º 52
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes  = parseNode.GetMappedChildNodes();
            var hasVar = nodes[0].ChildNodes[0].ChildNodes.Count > 0;

            if (hasVar)
            {
                exceptionVar = (IdentifierNode)AddChild("exceptionVar", nodes[0].ChildNodes[0].ChildNodes[0]);
            }
            block = AddChild("Block", nodes[1]);
        }
Ejemplo n.º 53
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            Condition = AddChild("Condition", nodes[0]);
            IfBlock   = AddChild("IfBlock", nodes[1]);
            if (nodes.Count > 2)
            {
                ElseBlock = AddChild("ElseBlock", nodes[2]);
            }
        }
Ejemplo n.º 54
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            foreach (var child in parseNode.GetMappedChildNodes())
            {
                if (child != null)
                {
                    AddChild("ArrayItem", child);
                }
            }

            AsString = "Array[" + ChildNodes.Count + "]";
        }
Ejemplo n.º 55
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);

            var nodes = parseNode.GetMappedChildNodes();

            from        = AddChild("from", nodes[0]);
            isInclusive = nodes[1].FindTokenAndGetText().Length == 3;
            to          = AddChild("to", nodes[2]);
            step        = nodes[3].ChildNodes.Count > 0 ? AddChild("step", nodes[3].ChildNodes[0]) : null;

            AsString = "Range " + from + " " + to + (isInclusive? " (inclusive)" : "") + (step != null ? " " + step : "");
        }
Ejemplo n.º 56
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            name = nodes[0].FindTokenAndGetText();
            if (name.StartsWith("\""))
            {
                name = name.Remove(name.Length - 1, 1).Remove(0, 1);
            }
            value = AddChild("Value", nodes[2]);

            AsString = "[" + name + "] = " + value.AsString;
        }
Ejemplo n.º 57
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            InitBlock = AddChild("Init", nodes[0]);
            var t = nodes[1].GetMappedChildNodes();

            Condition = t.Count > 0 ? AddChild("Condition", t[0]) : null;
            IterBlock = AddChild("Iter", nodes[2]);
            Block     = AddChild("ForBlock", nodes[3]);

            AsString = "For Loop";
        }
Ejemplo n.º 58
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            NameNode = null;
            var nodes = parseNode.GetMappedChildNodes();

            if (nodes.Count > 2)
            {
                InitImpl(context, parseNode, nodes[1], nodes[2]);
            }
            else
            {
                InitImpl(context, parseNode, nodes[0], nodes[1]);
            }
        }
Ejemplo n.º 59
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            if (!parseNode.FindTokenAndGetText().StartsWith("$"))
            {
                parseNode.AstNode = new LiteralValueNode();
                ((LiteralValueNode)parseNode.AstNode).Init(context, parseNode);
                return;
            }

            base.Init(context, parseNode);
            template         = parseNode.Token.ValueString;
            tokenText        = parseNode.Token.Text;
            templateSettings = parseNode.Term.AstConfig.Data as StringTemplateSettings;
            ParseSegments(context);
            AsString = "\"" + template + "\" (templated string)";
        }
Ejemplo n.º 60
0
        public override void Init(Irony.Ast.AstContext context, ParseTreeNode parseNode)
        {
            base.Init(context, parseNode);
            var nodes = parseNode.GetMappedChildNodes();

            FindOpAndDetectPostfix(nodes);
            int argIndex = IsPostfix ? 0 : 1;

            Argument = AddChild(AstNodeType.ValueReadWrite, "Arg", nodes[argIndex]);

            BinaryOpSymbol = Opsymbol[0].ToString();
            var interpContext = (AstContext)context;

            BinaryOp = interpContext.OperationHandler.GetOperatorExpressionType(BinaryOpSymbol);
            AsString = Opsymbol + (IsPostfix ? "(postfix)" : "(prefix)");
        }