Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Properties | Public Member Functions | Protected Member Functions | List of all members
Loyc.Syntax.IdNode Class Referenceabstract

Base class of all nodes that represent simple identifiers (including special symbols such as #foo). More...


Source file:
Inheritance diagram for Loyc.Syntax.IdNode:
Loyc.Syntax.LNode Loyc.ICloneable< out T > Loyc.IHasLocation Loyc.IHasValue< out T >

Remarks

Base class of all nodes that represent simple identifiers (including special symbols such as #foo).

Properties

sealed override LNodeKind Kind [get]
 
abstract override Symbol Name [get]
 
override object Value [get]
 
override LNode Target [get]
 
override VList< LNodeArgs [get]
 
sealed override int Max [get]
 
- Properties inherited from Loyc.Syntax.LNode
virtual SourceRange Range [get]
 Returns the location and range in source code of this node. More...
 
ISourceFile Source [get]
 Returns the source file (shortcut for Range.Source). More...
 
NodeStyle Style [get, set]
 Indicates the preferred style to use when printing the node to a text string. More...
 
NodeStyle BaseStyle [get, set]
 
virtual VList< LNodeAttrs [get]
 Returns the attribute list for this node. More...
 
virtual bool IsFrozen [get]
 Returns true if the node is immutable, and false if any part of it can be edited. Currently, mutable nodes are not implemented. More...
 
abstract LNodeKind Kind [get]
 Returns the LNodeKind: Symbol, Literal, or Call. More...
 
bool IsCall [get]
 
bool IsId [get]
 
bool IsLiteral [get]
 
abstract Symbol Name [get]
 Returns the Symbol if IsId. If this node is a call (IsCall) and Target.IsId is true, this property returns Target.Name. In all other cases, the name is GSymbol.Empty. Shall not return null. More...
 
bool HasSpecialName [get]
 Returns true if Name starts with '#'. More...
 
bool HasValue [get]
 
abstract object Value [get]
 Returns the value of a literal node, or NoValue.Value if this node is not a literal (IsLiteral is false). More...
 
abstract LNode Target [get]
 Returns the target of a method call, or null if IsCall is false. The target can be a symbol with no name (GSymbol.Empty) to represent a parenthesized expression, if there is one argument. More...
 
abstract VList< LNodeArgs [get]
 Returns the argument list of this node. Always empty when IsCall==false. More...
 
static LNodePrinter Printer [get, set]
 Gets or sets the default node printer on the current thread, which controls how nodes are serialized to text by default. More...
 
virtual object TriviaValue [get]
 Gets the value of Args[0].Value, if Args[0] exists; otherwise, returns NoValue.Value. More...
 
bool HasTokenValue [get]
 
int ArgCount [get]
 
int AttrCount [get]
 
bool HasAttrs [get]
 
bool IsTrivia [get]
 
int Min [get]
 
virtual int Max [get]
 
LNode this[int index] [get]
 
int Count [get]
 
- Properties inherited from Loyc.IHasLocation
object Location [get]
 
- Properties inherited from Loyc.IHasValue< out T >
Value [get]
 

Public Member Functions

abstract override LNode WithName (Symbol name)
 Creates a node with a new value for Name. More...
 
override LiteralNode WithValue (object value)
 Creates a new literal node with a different Value than the current literal node. More...
 
override CallNode WithArgs (VList< LNode > args)
 Creates a Node with a new argument list. If this node is not a call, a new node is created using this node as its target. Otherwise, the existing argument list is replaced. More...
 
sealed override void Call (LNodeVisitor visitor)
 
sealed override void Call (ILNodeVisitor visitor)
 
abstract override LNode Clone ()
 Creates a copy of the node. Since nodes are immutable, there is little reason for an end-user to call this, but Clone() is used internally as a helper method by the WithXyz() methods. More...
 
abstract override LNode WithAttrs (VList< LNode > attrs)
 
override bool Equals (LNode b, bool compareStyles)
 Compares two nodes for structural equality. Two green nodes are considered equal if they have the same name, the same value, the same arguments, and the same attributes. IsCall must be the same, but they need not have the same values of SourceWidth or IsFrozen. More...
 
override bool IsIdWithoutPAttrs ()
 
override bool IsIdWithoutPAttrs (Symbol name)
 
override bool IsIdNamed (Symbol name)
 
override bool IsIdNamed (string name)
 
override LNode Select (Func< LNode, LNode > selector)
 Transforms the attributes, Target, and parameters of an LNode, returning another LNode of the same Kind. If the selector makes no changes, Select() returns this. More...
 
override LNode ReplaceRecursive (Func< LNode, LNode > selector, bool replaceRoot=true)
 Performs a recursive find-and-replace operation, by attempting to replace each child (among Attrs, Target, Args) using the specified selector. This method can also be used for simple searching, by giving a selector that always returns null. More...
 
- Public Member Functions inherited from Loyc.Syntax.LNode
LNode SetBaseStyle (NodeStyle s)
 
LNode SetStyle (NodeStyle s)
 
virtual CallNode WithTarget (LNode target)
 
virtual CallNode WithTarget (Symbol name)
 
virtual CallNode With (LNode target, VList< LNode > args)
 Creates a CallNode with the same attributes and Range, but a different target and argument list. If the current node is not a CallNode, it becomes one (the Range, Style and attributes of the current node are kept, but the Kind, Value, and Name are discarded.) More...
 
virtual CallNode With (Symbol target, VList< LNode > args)
 Creates a CallNode with the same attributes and Range, but a different target and argument list. If the current node is not a CallNode, it becomes one (the Range, Style and attributes of the current node are kept, but the Kind, Value, and Name are discarded.) More...
 
CallNode With (Symbol target, params LNode[] args)
 
LNode WithRange (SourceRange range)
 
LNode WithRange (int startIndex, int endIndex)
 
LNode WithStyle (NodeStyle style)
 
virtual LNode With (SourceRange range, NodeStyle style)
 
virtual LNode WithoutAttrs ()
 
LNode WithAttrs (params LNode[] attrs)
 
CallNode WithArgs (params LNode[] args)
 
LNode PlusAttr (LNode attr)
 
LNode PlusAttrs (VList< LNode > attrs)
 
LNode PlusAttrs (IEnumerable< LNode > attrs)
 
LNode PlusAttrs (params LNode[] attrs)
 
LNode PlusArg (LNode arg)
 
LNode PlusArgs (VList< LNode > args)
 
LNode PlusArgs (IEnumerable< LNode > args)
 
LNode PlusArgs (params LNode[] args)
 
LNode WithArgChanged (int index, LNode newValue)
 
LNode WithAttrChanged (int index, LNode newValue)
 
virtual string Print (object mode=null, string indentString="\t", string lineSeparator="\n")
 
override string ToString ()
 
bool Equals (LNode other)
 
override bool Equals (object other)
 
override int GetHashCode ()
 Gets the hash code based on the structure of the tree. More...
 
bool HasPAttrs ()
 
VList< LNodePAttrs ()
 
virtual bool Calls (Symbol name, int argCount)
 
virtual bool Calls (string name, int argCount)
 
virtual bool Calls (Symbol name)
 
virtual bool Calls (string name)
 
virtual bool CallsMin (Symbol name, int argCount)
 
virtual bool CallsMin (string name, int argCount)
 
virtual bool HasSimpleHead ()
 Returns true if this is not a call, or if the call's Target is an Id or a Literal. More...
 
virtual bool HasSimpleHeadWithoutPAttrs ()
 Returns true if this is not a call, or if the call's Target is an Id or a Literal, and the Target has only trivia attributes. More...
 
LNode WithAttrs (Func< LNode, Maybe< LNode >> selector)
 
virtual LNode WithArgs (Func< LNode, Maybe< LNode >> selector)
 
virtual bool IsParenthesizedExpr ()
 
CallNode WithSplicedArgs (int index, LNode from, Symbol listName)
 
CallNode WithSplicedArgs (LNode from, Symbol listName)
 
LNode WithSplicedAttrs (int index, LNode from, Symbol listName)
 
LNode WithSplicedAttrs (LNode from, Symbol listName)
 
NestedEnumerable
< DescendantsFrame, LNode
Descendants (NodeScanMode mode=NodeScanMode.YieldAllChildren)
 
NestedEnumerable
< DescendantsFrame, LNode
DescendantsAndSelf ()
 
LNode TryGet (int index, out bool fail)
 
IRange< LNodeSlice (int start, int count=int.MaxValue)
 
IEnumerator< LNodeGetEnumerator ()
 

Protected Member Functions

 IdNode (LNode ras)
 
 IdNode (SourceRange range, NodeStyle style)
 
- Protected Member Functions inherited from Loyc.Syntax.LNode
 LNode (LNode prototype)
 
 LNode (SourceRange range, NodeStyle style)
 

Additional Inherited Members

- Public static fields inherited from Loyc.Syntax.LNode
static readonly EmptySourceFile SyntheticSource = new EmptySourceFile("<Synthetic Code>")
 
static readonly IdNode Missing = Id(CodeSymbols.Missing)
 
static readonly LNode InParensTrivia = Id(CodeSymbols.TriviaInParens)
 
- Static Public Member Functions inherited from Loyc.Syntax.LNode
static IdNode Id (Symbol name, LNode prototype)
 
static IdNode Id (string name, LNode prototype)
 
static IdNode Id (VList< LNode > attrs, Symbol name, LNode prototype)
 
static IdNode Id (VList< LNode > attrs, string name, LNode prototype)
 
static LiteralNode Literal (object value, LNode prototype)
 
static LiteralNode Literal (VList< LNode > attrs, object value, LNode prototype)
 
static CallNode Call (Symbol name, LNode prototype)
 
static CallNode Call (LNode target, LNode prototype)
 
static CallNode Call (Symbol name, VList< LNode > args, LNode prototype)
 
static CallNode Call (LNode target, VList< LNode > args, LNode prototype)
 
static CallNode Call (VList< LNode > attrs, Symbol name, VList< LNode > args, LNode prototype)
 
static CallNode Call (VList< LNode > attrs, LNode target, VList< LNode > args, LNode prototype)
 
static CallNode Trivia (Symbol name, object value, LNode prototype)
 
static LNode InParens (LNode node)
 
static IdNode Id (Symbol name, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static IdNode Id (string name, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static IdNode Id (VList< LNode > attrs, Symbol name, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static IdNode Id (VList< LNode > attrs, string name, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static LiteralNode Literal (object value, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static LiteralNode Literal (VList< LNode > attrs, object value, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (Symbol name, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (LNode target, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (Symbol name, VList< LNode > args, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (LNode target, VList< LNode > args, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (VList< LNode > attrs, Symbol name, VList< LNode > args, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (VList< LNode > attrs, LNode target, VList< LNode > args, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static CallNode Trivia (Symbol name, object value, SourceRange range, NodeStyle style=NodeStyle.Default)
 
static LNode InParens (LNode node, SourceRange range)
 
static IdNode Id (Symbol name, ISourceFile file=null, int position=-1, int width=-1)
 
static IdNode Id (string name, ISourceFile file=null, int position=-1, int width=-1)
 
static IdNode Id (VList< LNode > attrs, Symbol name, ISourceFile file=null, int position=-1, int width=-1)
 
static IdNode Id (VList< LNode > attrs, string name, ISourceFile file=null, int position=-1, int width=-1)
 
static LiteralNode Literal (object value, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static LiteralNode Literal (VList< LNode > attrs, object value, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (Symbol name, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (LNode target, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (Symbol name, VList< LNode > args, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (LNode target, VList< LNode > args, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (VList< LNode > attrs, Symbol name, VList< LNode > args, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static CallNode Call (VList< LNode > attrs, LNode target, VList< LNode > args, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static CallNode Trivia (Symbol name, object value, ISourceFile file=null, int position=-1, int width=-1, NodeStyle style=NodeStyle.Default)
 
static LNode InParens (LNode node, ISourceFile file=null, int position=-1, int width=-1)
 
static VList< LNodeList ()
 
static VList< LNodeList (LNode list_0)
 
static VList< LNodeList (LNode list_0, LNode list_1)
 
static VList< LNodeList (params LNode[] list)
 
static VList< LNodeList (IEnumerable< LNode > list)
 
static VList< LNodeList (VList< LNode > list)
 
static PushedPrinter PushPrinter (LNodePrinter printer)
 Helps you change printers temporarily. Usage in C#: using (LNode.PushPrinter(myPrinter)) { ... } More...
 
static bool Equals (LNode a, LNode b, bool compareStyles=false)
 
static bool Equals (VList< LNode > a, VList< LNode > b, bool compareStyles=false)
 Compares two lists of nodes for structural equality. More...
 
static LNode MergeLists (LNode node1, LNode node2, Symbol listName)
 Some CallNodes are used to represent lists. This method merges two nodes, forming or appending a list (see remarks). More...
 
static LNode MergeBinary (LNode node1, LNode node2, Symbol binaryOpName)
 Combines two nodes using a binary operator or function. More...
 
- Static Protected Member Functions inherited from Loyc.Syntax.LNode
static void NoNulls (VList< LNode > list, string propName)
 
- Protected fields inherited from Loyc.Syntax.LNode
RangeAndStyle RAS
 

Member Function Documentation

abstract override LNode Loyc.Syntax.IdNode.Clone ( )
pure virtual

Creates a copy of the node. Since nodes are immutable, there is little reason for an end-user to call this, but Clone() is used internally as a helper method by the WithXyz() methods.

Implements Loyc.Syntax.LNode.

override bool Loyc.Syntax.IdNode.Equals ( LNode  other,
bool  compareStyles 
)
inlinevirtual

Compares two nodes for structural equality. Two green nodes are considered equal if they have the same name, the same value, the same arguments, and the same attributes. IsCall must be the same, but they need not have the same values of SourceWidth or IsFrozen.

Parameters
compareStylesWhether to compare values of Style

Position information (Range) is not compared.

Implements Loyc.Syntax.LNode.

References Loyc.Syntax.LNode.Attrs, Loyc.Syntax.LNode.Kind, and Loyc.Syntax.LNode.Style.

override LNode Loyc.Syntax.IdNode.ReplaceRecursive ( Func< LNode, LNode selector,
bool  replaceRoot = true 
)
inlinevirtual

Performs a recursive find-and-replace operation, by attempting to replace each child (among Attrs, Target, Args) using the specified selector. This method can also be used for simple searching, by giving a selector that always returns null.

Parameters
selectorThe selector is called for each descendant, and optionally the root node. If the selector returns a node, the new node replaces the node that was passed to selector and the children of the new node are ignored. If the selector returns null, children of the child are scanned recursively.
replaceRootWhether to call selector(this).
Returns
The new node produced after all replacements have occurred.

If replaceFunc always returns null (or if replaceRoot is false and the root has no children), ReplaceRecursive returns this.

Implements Loyc.Syntax.LNode.

override LNode Loyc.Syntax.IdNode.Select ( Func< LNode, LNode selector)
inlinevirtual

Transforms the attributes, Target, and parameters of an LNode, returning another LNode of the same Kind. If the selector makes no changes, Select() returns this.

The selector is not allowed to return null.

Implements Loyc.Syntax.LNode.

override CallNode Loyc.Syntax.IdNode.WithArgs ( VList< LNode args)
inlinevirtual

Creates a Node with a new argument list. If this node is not a call, a new node is created using this node as its target. Otherwise, the existing argument list is replaced.

Parameters
argsNew argument list

Implements Loyc.Syntax.LNode.

abstract override LNode Loyc.Syntax.IdNode.WithName ( Symbol  name)
pure virtual

Creates a node with a new value for Name.

If IsId, the Name is simply changed. If IsCall, this method returns the equivalent of WithTarget(Target.WithName(name)) (which may be optimized for the particular call type). If IsLiteral, the Kind changes to LNodeKind.Id in order to set the name.

Reimplemented from Loyc.Syntax.LNode.

override LiteralNode Loyc.Syntax.IdNode.WithValue ( object  value)
inlinevirtual

Creates a new literal node with a different Value than the current literal node.

Exceptions
InvalidOperationExceptionThe node was not a literal already.

Implements Loyc.Syntax.LNode.