Exemplo n.º 1
0
		/// <summary>Converts a list of LNodes to a single LNode by using the list 
		/// as the argument list in a call to the specified identifier, or, if the 
		/// list contains a single item, by returning that single item.</summary>
		/// <param name="listIdentifier">Target of the node that is created if <c>list</c>
		/// does not contain exactly one item. Typical values include "{}" and "#splice".</param>
		/// <remarks>This is the reverse of the operation performed by <see cref="AsList(LNode,Symbol)"/>.</remarks>
		public static LNode AsLNode(this RVList<LNode> list, Symbol listIdentifier)
		{
			if (list.Count == 1)
				return list[0];
			else {
				var r = SourceRange.Nowhere;
				if (list.Count != 0) {
					r = list[0].Range;
					r = new SourceRange(r.Source, r.StartIndex, list.Last.Range.EndIndex - r.StartIndex);
				}
 				return LNode.Call(listIdentifier, list, r);
			}
		}
Exemplo n.º 2
0
		public StdTriviaNode(Symbol name, object value, SourceRange range, NodeStyle style = NodeStyle.Default) 
			: base(range, style) { _name = name ?? GSymbol.Empty; _tokenValue = value; }
Exemplo n.º 3
0
		public StdIdNodeWithAttrs(VList<LNode> attrs, Symbol name, SourceRange range, NodeStyle style = NodeStyle.Default) 
			: base(name, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
Exemplo n.º 4
0
		public StdComplexCallNodeWithAttrs(VList<LNode> attrs, LNode target, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default)
			: base(target, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
Exemplo n.º 5
0
		public StdComplexCallNode(LNode target, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default)
			: base(args, range, style) { CheckParam.IsNotNull("target", target); _target = target; }
Exemplo n.º 6
0
		public StdSimpleCallNodeWithAttrs(VList<LNode> attrs, Loyc.Syntax.Lexing.Token targetToken, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default)
			: base(targetToken, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
Exemplo n.º 7
0
 public bool Contains(SourceRange inner)
 {
     return Source == inner.Source && StartIndex <= inner.StartIndex && EndIndex >= inner.EndIndex;
 }
Exemplo n.º 8
0
		protected LiteralNode(SourceRange range, NodeStyle style) : base(range, style) { }
Exemplo n.º 9
0
		public StdSimpleCallNode(Symbol name, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) 
			: base(args, range, style) { _name = name ?? GSymbol.Empty; DetectTargetRange(); }
Exemplo n.º 10
0
		public StdCallNode(VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default)
			: base(range, style) { _args = args; NoNulls(args, "Args"); }
Exemplo n.º 11
0
		public StdLiteralNodeWithAttrs(VList<LNode> attrs, object value, SourceRange range, NodeStyle style = NodeStyle.Default) 
			: base(value, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
Exemplo n.º 12
0
		public StdLiteralNode(object value, SourceRange range, NodeStyle style = NodeStyle.Default) 
			: base(range, style) { _value = value; }
Exemplo n.º 13
0
		public StdSimpleCallNode(Symbol name, VList<LNode> args, SourceRange range, int targetStart, int targetEnd, NodeStyle style = NodeStyle.Default) 
			: base(args, range, style)
		{
			_name = name ?? GSymbol.Empty;
			_targetOffs = ClipUShort(targetStart - RAS.StartIndex);
			_targetLen = ClipUShort(targetEnd - targetStart);
		}
Exemplo n.º 14
0
		void MissingEndMarker(LNode previousExpr, TokenType endMarker) {
			var location = new SourceRange(SourceFile, LT(-1).EndIndex + 1);
			ErrorSink.Write(Severity.Error, location, "Expected '{0}'", endMarker == TT.Comma ? ',' : ';');
		}
Exemplo n.º 15
0
		public StdSimpleCallNode(Loyc.Syntax.Lexing.Token targetToken, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default)
			: base(args, range, style)
		{
			_name = (Symbol)(targetToken.Value ?? GSymbol.Empty); 
			_targetOffs = ClipUShort(targetToken.StartIndex - RAS.StartIndex);
			_targetLen = ClipUShort(targetToken.Length);
		}
Exemplo n.º 16
0
		public void CheckForSpaceAtEndOfAttribute() {
			if (LT0.StartIndex == LT(-1).EndIndex) {
				var location = new SourceRange(SourceFile, LT0.StartIndex);
				ErrorSink.Write(Severity.Error, location, "Expected space after attribute");
			}
		}
Exemplo n.º 17
0
		public StdIdNode(Symbol name, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) 
		{
			if ((_name = name) == null)
				throw new ArgumentException("Cannot set IdNode.Name to null.");
		}
Exemplo n.º 18
0
		/// <summary>Returns the same node with a parentheses attribute added.</summary>
		/// <remarks>The node's range is changed to the provided <see cref="SourceRange"/>
        /// and the original range of the node is assigned to the parentheses attribute.</remarks>
		public static LNode InParens(this LNode node, SourceRange range)
		{
			return node.WithRange(range).PlusAttrBefore(LNode.Id(CodeSymbols.TriviaInParens));
		}
Exemplo n.º 19
0
		public StdSimpleCallNodeWithAttrs(RVList<LNode> attrs, Symbol name, RVList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) 
			: base(name, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }