/// <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); } }
public StdTriviaNode(Symbol name, object value, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) { _name = name ?? GSymbol.Empty; _tokenValue = value; }
public StdIdNodeWithAttrs(VList<LNode> attrs, Symbol name, SourceRange range, NodeStyle style = NodeStyle.Default) : base(name, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
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"); }
public StdComplexCallNode(LNode target, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(args, range, style) { CheckParam.IsNotNull("target", target); _target = target; }
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"); }
public bool Contains(SourceRange inner) { return Source == inner.Source && StartIndex <= inner.StartIndex && EndIndex >= inner.EndIndex; }
protected LiteralNode(SourceRange range, NodeStyle style) : base(range, style) { }
public StdSimpleCallNode(Symbol name, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(args, range, style) { _name = name ?? GSymbol.Empty; DetectTargetRange(); }
public StdCallNode(VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) { _args = args; NoNulls(args, "Args"); }
public StdLiteralNodeWithAttrs(VList<LNode> attrs, object value, SourceRange range, NodeStyle style = NodeStyle.Default) : base(value, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public StdLiteralNode(object value, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) { _value = value; }
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); }
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 ? ',' : ';'); }
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); }
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"); } }
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."); }
/// <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)); }
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"); }