C# 클래스 Loyc.Syntax.LNodeExt

Standard extension methods for LNode.
파일 보기 프로젝트 열기: qwertie/ecsharp 1 사용 예제들

공개 메소드들

메소드 설명
ArgCount ( this node ) : int
ArgNamed ( this self, Symbol name ) : LNode
Args ( this node ) : NegListSlice
AsLNode ( this list, Symbol listIdentifier ) : LNode

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.

This is the reverse of the operation performed by AsList(LNode,Symbol).

AsList ( this block, Symbol listIdentifier ) : VList

Interprets a node as a list by returning block.Args if block.Calls(listIdentifier), otherwise returning a one-item list of nodes with block as the only item.

AttrCount ( this node ) : int
AttrNamed ( this node, Symbol name ) : ILNode
AttrNamed ( this self, Symbol name ) : LNode
Attrs ( this node ) : NegListSlice
BaseStyle ( this node ) : NodeStyle
Calls ( this node, Symbol name ) : bool
GetCaptureIdentifier ( LNode pattern, bool identifierRequired = true ) : LNode

Checks if pattern matches one of the syntax trees $x or $(..x) or $(...x) for some identifier x. These are conventionally used to represent partial syntax trees.

GetTrailingTrivia ( this node ) : IListSource
GetTrailingTrivia ( this node ) : VList

Gets all trailing trivia attached to the specified node.

GetTrailingTrivia ( this attrs ) : VList

Gets all trailing trivia attached to the specified node.

Trailing trivia is represented by a call to #trivia_trailing in a node's attribute list; each argument to #trivia_trailing represents one piece of trivia. If the attribute list has multiple calls to #trivia_trailing, this method combines those lists into a single list.

GetTrivia ( this node ) : VList
GetTrivia ( this attrs ) : VList
HasAttrs ( this node ) : bool
HasPAttrs ( this node ) : bool
HasSpecialName ( this node ) : bool
InParens ( this node ) : LNode

Returns the same node with a parentheses attribute added.

InParens ( this node, ISourceFile file, int startIndex, int endIndex ) : LNode

Returns the same node with a parentheses attribute added.

InParens ( this node, SourceRange range ) : LNode

Returns the same node with a parentheses attribute added.

The node's range is changed to the provided SourceRange and the original range of the node is assigned to the parentheses attribute.

IndexWithName ( this self, Symbol name, int resultIfNotFound = -1 ) : int
IsCall ( this node ) : bool
IsId ( this node ) : bool
IsIdNamed ( this node, Symbol name ) : bool
IsIdNamed ( this node, string name ) : bool
IsLiteral ( this node ) : bool
IsParenthesizedExpr ( this node ) : bool
IsTrivia ( this node ) : bool
MatchesPattern ( this candidate, LNode pattern, LNode>.IDictionary &captures ) : bool
MatchesPattern ( this candidate, LNode pattern, LNode>.IDictionary &captures, VList &unmatchedAttrs ) : bool
MatchesPattern ( this candidate, LNode pattern, LNode>.MMap &captures, VList &unmatchedAttrs ) : bool

Determines whether one Loyc tree "matches" another. This is different from a simple equality test in that (1) trivia atributes do not have to match, and (2) the pattern can contain placeholders represented by calls to $ (the substitution operator) with an identifier as a parameter. Placeholders match any subtree, and are saved to the captures map.

Attributes in patterns are not yet supported. This method supports multi-part captures, which are matched to placeholders whose identifier either (A) has a #params attribute or (B) has the unary ".." operator applied to it (for example, if the placeholder is called p, this is written as $(params p) in EC#.) A placeholder that looks like this can match multiple arguments or multiple statements in the candidate (or no arguments, or no statements), and will become a #splice(...) node in captures if it matches multiple items. Multi-part captures are often useful for getting lists of statements before and after some required element, e.g. { $(params before); MatchThis($something); $(params after); } If the same placeholder appears twice then the two matching items are combined into a single output node (calling #splice). If matching is unsuccessful, captures and unmatchedAttrs may contain irrelevant information gathered during the attempt to match. In EC#, the quote(...) macro can be used to create the LNode object for a pattern.

NodeNamed ( this self, Symbol name ) : ILNode
NodeNamed ( this self, Symbol name ) : LNode
PlusTrailingTrivia ( this node, LNode trivia ) : LNode

Adds additional trailing trivia to a node.

PlusTrailingTrivia ( this node, VList trivia ) : LNode

Adds additional trailing trivia to a node.

PlusTrailingTrivia ( this attrs, LNode trivia ) : VList

Adds additional trailing trivia to an attribute list.

PlusTrailingTrivia ( this attrs, VList trivia ) : VList

Adds additional trailing trivia to an attribute list. Has no effect if trivia is empty.

Trailing trivia is represented by a call to #trivia_trailing in a node's attribute list; each argument to #trivia_trailing represents one piece of trivia. In the current design, this method has a side-effect of recreating the #trivia_trailing node at the end of the attribute list, and if there are multiple #trivia_trailing lists, consolidating them into a single list, but only if the specified trivia list is not empty.

SpliceAdd ( this list, LNode node, Symbol listName = null ) : void
SpliceInsert ( this list, int index, LNode node, Symbol listName = null ) : void
ToLNode ( ILNode node ) : LNode

Converts ILNode to LNode recursively. If the specified node is already an LNode, this method simply does a cast.

WithSpliced ( this list, LNode node, Symbol listName = null ) : VList
WithSpliced ( this list, int index, LNode node, Symbol listName = null ) : VList
WithTrailingTrivia ( this node, VList trivia ) : LNode

Removes a node's trailing trivia and adds a new list of trailing trivia.

WithTrailingTrivia ( this attrs, VList trivia ) : VList

Removes all existing trailing trivia from an attribute list and adds a new list of trailing trivia.

This method has a side-effect of recreating the #trivia_trailing node, if there is one, at the end of the attribute list. If trivia is empty then all calls to #trivia_trailing are removed.

Without ( this list, LNode node ) : VList
WithoutAttr ( this self, LNode node ) : LNode
WithoutAttrNamed ( this self, Symbol name ) : LNode
WithoutAttrNamed ( this self, Symbol name, LNode &removedAttr ) : LNode
WithoutNodeNamed ( this a, Symbol name ) : VList
WithoutNodeNamed ( this list, Symbol name, LNode &removedNode ) : VList
WithoutOuterParens ( this self ) : LNode

Removes a single pair of parentheses, if the node has a #trivia_inParens attribute. Returns the same node when no parens are present.

WithoutTrailingTrivia ( this attrs ) : VList

Gets a new list with any #trivia_trailing attributes removed.

WithoutTrailingTrivia ( this attrs, VList &trailingTrivia ) : VList

Gets a new list with any #trivia_trailing attributes removed. Those trivia are returned in an `out` parameter.

비공개 메소드들

메소드 설명
AddCapture ( LNode>.MMap captures, LNode cap, Slice_ items ) : void
AddCapture ( LNode>.MMap captures, Symbol capName, LNode candidate ) : void
AttributesMatch ( LNode candidate, LNode pattern, LNode>.MMap &captures, VList &unmatchedAttrs ) : bool
CaptureGroup ( int &c, int &p, VList cArgs, VList pArgs, LNode>.MMap &captures, VList &attrs ) : bool
IsParamsCapture ( LNode pattern ) : bool
ListMatches ( VList candidates, VList patterns, LNode>.MMap &captures, VList &unmatchedAttrs ) : bool
MatchThenParams ( VList cArgs, VList pArgs, LNode paramsCap, LNode>.MMap &captures, VList &attrs ) : bool
MatchesPatternNested ( LNode candidate, LNode pattern, LNode>.MMap &captures, VList &trivia ) : bool
ToLNodeCore ( ILNode node ) : LNode

메소드 상세

ArgCount() 공개 정적인 메소드

public static ArgCount ( this node ) : int
node this
리턴 int

ArgNamed() 공개 정적인 메소드

public static ArgNamed ( this self, Symbol name ) : LNode
self this
name Symbol
리턴 LNode

Args() 공개 정적인 메소드

public static Args ( this node ) : NegListSlice
node this
리턴 NegListSlice

AsLNode() 공개 정적인 메소드

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.
This is the reverse of the operation performed by AsList(LNode,Symbol).
public static AsLNode ( this list, Symbol listIdentifier ) : LNode
list this
listIdentifier Symbol Target of the node that is created if list /// does not contain exactly one item. Typical values include "'{}" and "#splice".
리턴 LNode

AsList() 공개 정적인 메소드

Interprets a node as a list by returning block.Args if block.Calls(listIdentifier), otherwise returning a one-item list of nodes with block as the only item.
public static AsList ( this block, Symbol listIdentifier ) : VList
block this
listIdentifier Symbol
리턴 VList

AttrCount() 공개 정적인 메소드

public static AttrCount ( this node ) : int
node this
리턴 int

AttrNamed() 공개 정적인 메소드

public static AttrNamed ( this node, Symbol name ) : ILNode
node this
name Symbol
리턴 ILNode

AttrNamed() 공개 정적인 메소드

public static AttrNamed ( this self, Symbol name ) : LNode
self this
name Symbol
리턴 LNode

Attrs() 공개 정적인 메소드

public static Attrs ( this node ) : NegListSlice
node this
리턴 NegListSlice

BaseStyle() 공개 정적인 메소드

public static BaseStyle ( this node ) : NodeStyle
node this
리턴 NodeStyle

Calls() 공개 정적인 메소드

public static Calls ( this node, Symbol name ) : bool
node this
name Symbol
리턴 bool

GetCaptureIdentifier() 공개 정적인 메소드

Checks if pattern matches one of the syntax trees $x or $(..x) or $(...x) for some identifier x. These are conventionally used to represent partial syntax trees.
public static GetCaptureIdentifier ( LNode pattern, bool identifierRequired = true ) : LNode
pattern LNode
identifierRequired bool
리턴 LNode

GetTrailingTrivia() 공개 정적인 메소드

public static GetTrailingTrivia ( this node ) : IListSource
node this
리턴 IListSource

GetTrailingTrivia() 공개 정적인 메소드

Gets all trailing trivia attached to the specified node.
public static GetTrailingTrivia ( this node ) : VList
node this
리턴 VList

GetTrailingTrivia() 공개 정적인 메소드

Gets all trailing trivia attached to the specified node.
Trailing trivia is represented by a call to #trivia_trailing in a node's attribute list; each argument to #trivia_trailing represents one piece of trivia. If the attribute list has multiple calls to #trivia_trailing, this method combines those lists into a single list.
public static GetTrailingTrivia ( this attrs ) : VList
attrs this
리턴 VList

GetTrivia() 공개 정적인 메소드

public static GetTrivia ( this node ) : VList
node this
리턴 VList

GetTrivia() 공개 정적인 메소드

public static GetTrivia ( this attrs ) : VList
attrs this
리턴 VList

HasAttrs() 공개 정적인 메소드

public static HasAttrs ( this node ) : bool
node this
리턴 bool

HasPAttrs() 공개 정적인 메소드

public static HasPAttrs ( this node ) : bool
node this
리턴 bool

HasSpecialName() 공개 정적인 메소드

public static HasSpecialName ( this node ) : bool
node this
리턴 bool

InParens() 공개 정적인 메소드

Returns the same node with a parentheses attribute added.
public static InParens ( this node ) : LNode
node this
리턴 LNode

InParens() 공개 정적인 메소드

Returns the same node with a parentheses attribute added.
public static InParens ( this node, ISourceFile file, int startIndex, int endIndex ) : LNode
node this
file ISourceFile
startIndex int
endIndex int
리턴 LNode

InParens() 공개 정적인 메소드

Returns the same node with a parentheses attribute added.
The node's range is changed to the provided SourceRange and the original range of the node is assigned to the parentheses attribute.
public static InParens ( this node, SourceRange range ) : LNode
node this
range SourceRange
리턴 LNode

IndexWithName() 공개 정적인 메소드

public static IndexWithName ( this self, Symbol name, int resultIfNotFound = -1 ) : int
self this
name Symbol
resultIfNotFound int
리턴 int

IsCall() 공개 정적인 메소드

public static IsCall ( this node ) : bool
node this
리턴 bool

IsId() 공개 정적인 메소드

public static IsId ( this node ) : bool
node this
리턴 bool

IsIdNamed() 공개 정적인 메소드

public static IsIdNamed ( this node, Symbol name ) : bool
node this
name Symbol
리턴 bool

IsIdNamed() 공개 정적인 메소드

public static IsIdNamed ( this node, string name ) : bool
node this
name string
리턴 bool

IsLiteral() 공개 정적인 메소드

public static IsLiteral ( this node ) : bool
node this
리턴 bool

IsParenthesizedExpr() 공개 정적인 메소드

public static IsParenthesizedExpr ( this node ) : bool
node this
리턴 bool

IsTrivia() 공개 정적인 메소드

public static IsTrivia ( this node ) : bool
node this
리턴 bool

MatchesPattern() 공개 정적인 메소드

public static MatchesPattern ( this candidate, LNode pattern, LNode>.IDictionary &captures ) : bool
candidate this
pattern LNode
captures LNode>.IDictionary
리턴 bool

MatchesPattern() 공개 정적인 메소드

public static MatchesPattern ( this candidate, LNode pattern, LNode>.IDictionary &captures, VList &unmatchedAttrs ) : bool
candidate this
pattern LNode
captures LNode>.IDictionary
unmatchedAttrs VList
리턴 bool

MatchesPattern() 공개 정적인 메소드

Determines whether one Loyc tree "matches" another. This is different from a simple equality test in that (1) trivia atributes do not have to match, and (2) the pattern can contain placeholders represented by calls to $ (the substitution operator) with an identifier as a parameter. Placeholders match any subtree, and are saved to the captures map.
Attributes in patterns are not yet supported. This method supports multi-part captures, which are matched to placeholders whose identifier either (A) has a #params attribute or (B) has the unary ".." operator applied to it (for example, if the placeholder is called p, this is written as $(params p) in EC#.) A placeholder that looks like this can match multiple arguments or multiple statements in the candidate (or no arguments, or no statements), and will become a #splice(...) node in captures if it matches multiple items. Multi-part captures are often useful for getting lists of statements before and after some required element, e.g. { $(params before); MatchThis($something); $(params after); } If the same placeholder appears twice then the two matching items are combined into a single output node (calling #splice). If matching is unsuccessful, captures and unmatchedAttrs may contain irrelevant information gathered during the attempt to match. In EC#, the quote(...) macro can be used to create the LNode object for a pattern.
public static MatchesPattern ( this candidate, LNode pattern, LNode>.MMap &captures, VList &unmatchedAttrs ) : bool
candidate this A node that you want to compare with a 'pattern'.
pattern LNode A syntax tree that may contain placeholders. A /// placeholder is a call to the $ operator with one parameter, which must /// be either (A) a simple identifier, or (B) the ".." operator with a simple /// identifier as its single parameter. Otherwise, the $ operator is treated /// literally as something that must exist in candidate). The subtree /// in candidate corresponding to the placeholder is saved in /// captures.
captures LNode>.MMap A table that maps placeholder names from /// pattern to subtrees in candidate. You can set your map to /// null and a map will be created for you if necessary. If you already have /// a map, you should clear it before calling this method.
unmatchedAttrs VList On return, a list of trivia attributes in /// candidate that were not present in pattern.
리턴 bool

NodeNamed() 공개 정적인 메소드

public static NodeNamed ( this self, Symbol name ) : ILNode
self this
name Symbol
리턴 ILNode

NodeNamed() 공개 정적인 메소드

public static NodeNamed ( this self, Symbol name ) : LNode
self this
name Symbol
리턴 LNode

PlusTrailingTrivia() 공개 정적인 메소드

Adds additional trailing trivia to a node.
public static PlusTrailingTrivia ( this node, LNode trivia ) : LNode
node this
trivia LNode
리턴 LNode

PlusTrailingTrivia() 공개 정적인 메소드

Adds additional trailing trivia to a node.
public static PlusTrailingTrivia ( this node, VList trivia ) : LNode
node this
trivia VList
리턴 LNode

PlusTrailingTrivia() 공개 정적인 메소드

Adds additional trailing trivia to an attribute list.
public static PlusTrailingTrivia ( this attrs, LNode trivia ) : VList
attrs this
trivia LNode
리턴 VList

PlusTrailingTrivia() 공개 정적인 메소드

Adds additional trailing trivia to an attribute list. Has no effect if trivia is empty.
Trailing trivia is represented by a call to #trivia_trailing in a node's attribute list; each argument to #trivia_trailing represents one piece of trivia. In the current design, this method has a side-effect of recreating the #trivia_trailing node at the end of the attribute list, and if there are multiple #trivia_trailing lists, consolidating them into a single list, but only if the specified trivia list is not empty.
public static PlusTrailingTrivia ( this attrs, VList trivia ) : VList
attrs this
trivia VList
리턴 VList

SpliceAdd() 공개 정적인 메소드

public static SpliceAdd ( this list, LNode node, Symbol listName = null ) : void
list this
node LNode
listName Symbol
리턴 void

SpliceInsert() 공개 정적인 메소드

public static SpliceInsert ( this list, int index, LNode node, Symbol listName = null ) : void
list this
index int
node LNode
listName Symbol
리턴 void

ToLNode() 공개 정적인 메소드

Converts ILNode to LNode recursively. If the specified node is already an LNode, this method simply does a cast.
public static ToLNode ( ILNode node ) : LNode
node ILNode
리턴 LNode

WithSpliced() 공개 정적인 메소드

public static WithSpliced ( this list, LNode node, Symbol listName = null ) : VList
list this
node LNode
listName Symbol
리턴 VList

WithSpliced() 공개 정적인 메소드

public static WithSpliced ( this list, int index, LNode node, Symbol listName = null ) : VList
list this
index int
node LNode
listName Symbol
리턴 VList

WithTrailingTrivia() 공개 정적인 메소드

Removes a node's trailing trivia and adds a new list of trailing trivia.
public static WithTrailingTrivia ( this node, VList trivia ) : LNode
node this
trivia VList
리턴 LNode

WithTrailingTrivia() 공개 정적인 메소드

Removes all existing trailing trivia from an attribute list and adds a new list of trailing trivia.
This method has a side-effect of recreating the #trivia_trailing node, if there is one, at the end of the attribute list. If trivia is empty then all calls to #trivia_trailing are removed.
public static WithTrailingTrivia ( this attrs, VList trivia ) : VList
attrs this
trivia VList
리턴 VList

Without() 공개 정적인 메소드

public static Without ( this list, LNode node ) : VList
list this
node LNode
리턴 VList

WithoutAttr() 공개 정적인 메소드

public static WithoutAttr ( this self, LNode node ) : LNode
self this
node LNode
리턴 LNode

WithoutAttrNamed() 공개 정적인 메소드

public static WithoutAttrNamed ( this self, Symbol name ) : LNode
self this
name Symbol
리턴 LNode

WithoutAttrNamed() 공개 정적인 메소드

public static WithoutAttrNamed ( this self, Symbol name, LNode &removedAttr ) : LNode
self this
name Symbol
removedAttr LNode
리턴 LNode

WithoutNodeNamed() 공개 정적인 메소드

public static WithoutNodeNamed ( this a, Symbol name ) : VList
a this
name Symbol
리턴 VList

WithoutNodeNamed() 공개 정적인 메소드

public static WithoutNodeNamed ( this list, Symbol name, LNode &removedNode ) : VList
list this
name Symbol
removedNode LNode
리턴 VList

WithoutOuterParens() 공개 정적인 메소드

Removes a single pair of parentheses, if the node has a #trivia_inParens attribute. Returns the same node when no parens are present.
public static WithoutOuterParens ( this self ) : LNode
self this
리턴 LNode

WithoutTrailingTrivia() 공개 정적인 메소드

Gets a new list with any #trivia_trailing attributes removed.
public static WithoutTrailingTrivia ( this attrs ) : VList
attrs this
리턴 VList

WithoutTrailingTrivia() 공개 정적인 메소드

Gets a new list with any #trivia_trailing attributes removed. Those trivia are returned in an `out` parameter.
public static WithoutTrailingTrivia ( this attrs, VList &trailingTrivia ) : VList
attrs this
trailingTrivia VList
리턴 VList