C# 클래스 Loyc.Ecs.EcsValidators

A class filled with methods for checking whether a node has the correct LNode.Name and structure. For example, IsPropertyDefinition(node) checks whether node meets the requirements for being a property definition, such as having a Name equal to #property, and having name and return value that are complex identifiers.
This class also has useful helper functions, such as KeyNameComponentOf(LNode).
파일 보기 프로젝트 열기: qwertie/ecsharp 1 사용 예제들

공개 메소드들

메소드 설명
ExecutableBlockStmtType ( LNode _n, Pedantics p = Pedantics.Lax ) : Symbol
IsAssignmentOperator ( Symbol opName ) : bool
IsBracedBlock ( LNode n ) : bool
IsComplexIdentifier ( LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax ) : bool
IsEventDefinition ( LNode n, Pedantics p ) : bool
IsExecutableBlockStmt ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
IsForwardedProperty ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
IsIdentContChar ( char c ) : bool
IsIdentStartChar ( char c ) : bool
IsLabelStmt ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
IsNamedArgument ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
IsOperator ( Symbol opName ) : bool
IsPlainCsIdentContChar ( char c ) : bool
IsPlainCsIdentStartChar ( char c ) : bool
IsPlainCsIdentifier ( string text ) : bool
IsPrintableTypeParam ( LNode n, Pedantics p = Pedantics.Lax ) : bool

Checks if 'n' is a legal type parameter definition.

A type parameter definition must be a simple symbol with at most one #in or #out attribute, and at most one #where attribute with an argument list consisting of complex identifiers.

IsPropertyDefinition ( LNode n, LNode &retType, LNode &name, LNode &args, LNode &body, LNode &initialValue, Pedantics p = Pedantics.Lax ) : bool

Returns true iff the given node has a valid syntax tree for a property definition, and gets the component parts of the definition.

The body may be anything. If it calls CodeSymbols.Braces, it's a normal body.

IsPropertyDefinition ( LNode n, Pedantics p = Pedantics.Lax ) : bool

Returns true iff the given node has a valid syntax tree for a property definition.

IsResultExpr ( LNode n, Pedantics p = Pedantics.Lax ) : bool
IsSimpleIdentifier ( LNode n, Pedantics p ) : bool
IsVariableDecl ( LNode _n, bool allowMultiple, bool allowNoAssignment, Pedantics p ) : bool
IsVariableDeclExpr ( LNode expr, LNode &type, LNode &name, LNode &initialValue ) : bool

Verifies that a declaration of a single variable is valid and gets its parts.

KeyNameComponentOf ( LNode name ) : Symbol

Given a complex name such as global::Foo<int>.Bar<T>, this method identifies the base name component, which in this example is Bar. This is used, for example, to identify the expected name for a constructor based on the class name, e.g. Foo<T> => Foo.

It is not verified that name is a complex identifier. There is no error detection but in some cases an empty name may be returned, e.g. for input like Foo."Hello".

MayBeImplicitChildStatement ( LNode node, int childIndex ) : bool

Returns true if the specified child of the specified node can be an implicit child statement, i.e. a child statement that is not necessarily a braced block, e.g. the second child of a while loop.

This method helps the printer decide when a newline should be added before an unbraced child statement when there are no attributes dictating whether to add a newline or not. This method only cares about executable parent nodes. It returns false for class/space and function/property bodies, which are always braced blocks and therefore get a newline before every child statement automatically.

MethodDefinitionKind ( LNode n, LNode &retType, LNode &name, LNode &args, LNode &body, bool allowDelegate, Pedantics p = Pedantics.Lax ) : Symbol

If the given node has a valid syntax tree for a method definition, a constructor, or (when orDelegate is true) a delegate definition, gets the definition kind (#fn, #cons, or #delegate).

Method declarations (no body) also count. A destructor counts as a #fn with a method name that calls the ~ operator.

MethodDefinitionKind ( LNode n, bool allowDelegate, Pedantics p = Pedantics.Lax ) : Symbol

If the given node has a valid syntax tree for a method definition, a constructor, or (when orDelegate is true) a delegate definition, gets the definition kind (#fn, #cons, or #delegate).

SanitizeIdentifier ( string id ) : string

Eliminates punctuation and special characters from a string so that the string can be used as a plain C# identifier, e.g. "I'd" => "I_aposd", "123" => "_123", "+5" => "_plus5".

The empty string "" becomes "__empty__", ASCII punctuation becomes "_xyz" where xyz is an HTML entity name, e.g. '!' becomes "_excl", and all other characters become "Xxx" where xx is the hexadecimal representation of the code point. Designed for the Unicode BMP only.

SpaceDefinitionKind ( LNode n, LNode &name, LNode &bases, LNode &body, Pedantics p = Pedantics.Lax ) : Symbol

Returns the space kind, which is one of the names #struct, #class, #enum, #interface, #namespace, #alias, #trait, or null if the node Name or structure is not valid for a space statement.

SpaceDefinitionKind ( LNode n, Pedantics p = Pedantics.Lax ) : Symbol

Returns the space kind, which is one of the names #struct, #class, #enum, #interface, #namespace, #alias, #trait, or null if the node Name or structure is not valid for a space statement.

비공개 메소드들

메소드 설명
CallsMinWPAIH ( LNode self, Symbol name, int argCount, Pedantics p ) : bool
CallsWPAIH ( LNode self, Symbol name, Pedantics p ) : bool
CallsWPAIH ( LNode self, Symbol name, int argCount, Pedantics p ) : bool
HasPAttrs ( LNode node, Pedantics p ) : bool
HasPAttrsOrParens ( LNode node, Pedantics p ) : bool
HasSimpleHeadWPA ( LNode self, Pedantics p ) : bool
IsEventDefinition ( LNode node, LNode &type, LNode &name, LNode &body, Pedantics p ) : bool
IsSimpleExecutableKeywordStmt ( LNode _n, Pedantics p ) : bool
IsSimpleSymbolWPA ( LNode self, Pedantics p ) : bool
IsSimpleSymbolWPA ( LNode self, Symbol name, Pedantics p ) : bool
OtherBlockStmtType ( LNode _n, Pedantics p ) : Symbol
TwoArgBlockStmtType ( LNode _n, Pedantics p ) : Symbol

메소드 상세

ExecutableBlockStmtType() 공개 정적인 메소드

public static ExecutableBlockStmtType ( LNode _n, Pedantics p = Pedantics.Lax ) : Symbol
_n LNode
p Pedantics
리턴 Symbol

IsAssignmentOperator() 공개 정적인 메소드

public static IsAssignmentOperator ( Symbol opName ) : bool
opName Symbol
리턴 bool

IsBracedBlock() 공개 정적인 메소드

public static IsBracedBlock ( LNode n ) : bool
n LNode
리턴 bool

IsComplexIdentifier() 공개 정적인 메소드

public static IsComplexIdentifier ( LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax ) : bool
n LNode
f ICI
p Pedantics
리턴 bool

IsEventDefinition() 공개 정적인 메소드

public static IsEventDefinition ( LNode n, Pedantics p ) : bool
n LNode
p Pedantics
리턴 bool

IsExecutableBlockStmt() 공개 정적인 메소드

public static IsExecutableBlockStmt ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
_n LNode
p Pedantics
리턴 bool

IsForwardedProperty() 공개 정적인 메소드

public static IsForwardedProperty ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
_n LNode
p Pedantics
리턴 bool

IsIdentContChar() 공개 정적인 메소드

public static IsIdentContChar ( char c ) : bool
c char
리턴 bool

IsIdentStartChar() 공개 정적인 메소드

public static IsIdentStartChar ( char c ) : bool
c char
리턴 bool

IsLabelStmt() 공개 정적인 메소드

public static IsLabelStmt ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
_n LNode
p Pedantics
리턴 bool

IsNamedArgument() 공개 정적인 메소드

public static IsNamedArgument ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
_n LNode
p Pedantics
리턴 bool

IsOperator() 공개 정적인 메소드

public static IsOperator ( Symbol opName ) : bool
opName Symbol
리턴 bool

IsPlainCsIdentContChar() 공개 정적인 메소드

public static IsPlainCsIdentContChar ( char c ) : bool
c char
리턴 bool

IsPlainCsIdentStartChar() 공개 정적인 메소드

public static IsPlainCsIdentStartChar ( char c ) : bool
c char
리턴 bool

IsPlainCsIdentifier() 공개 정적인 메소드

public static IsPlainCsIdentifier ( string text ) : bool
text string
리턴 bool

IsPrintableTypeParam() 공개 정적인 메소드

Checks if 'n' is a legal type parameter definition.
A type parameter definition must be a simple symbol with at most one #in or #out attribute, and at most one #where attribute with an argument list consisting of complex identifiers.
public static IsPrintableTypeParam ( LNode n, Pedantics p = Pedantics.Lax ) : bool
n LNode
p Pedantics
리턴 bool

IsPropertyDefinition() 공개 정적인 메소드

Returns true iff the given node has a valid syntax tree for a property definition, and gets the component parts of the definition.
The body may be anything. If it calls CodeSymbols.Braces, it's a normal body.
public static IsPropertyDefinition ( LNode n, LNode &retType, LNode &name, LNode &args, LNode &body, LNode &initialValue, Pedantics p = Pedantics.Lax ) : bool
n LNode
retType LNode
name LNode
args LNode
body LNode
initialValue LNode
p Pedantics
리턴 bool

IsPropertyDefinition() 공개 정적인 메소드

Returns true iff the given node has a valid syntax tree for a property definition.
public static IsPropertyDefinition ( LNode n, Pedantics p = Pedantics.Lax ) : bool
n LNode
p Pedantics
리턴 bool

IsResultExpr() 공개 정적인 메소드

public static IsResultExpr ( LNode n, Pedantics p = Pedantics.Lax ) : bool
n LNode
p Pedantics
리턴 bool

IsSimpleIdentifier() 공개 정적인 메소드

public static IsSimpleIdentifier ( LNode n, Pedantics p ) : bool
n LNode
p Pedantics
리턴 bool

IsVariableDecl() 공개 정적인 메소드

public static IsVariableDecl ( LNode _n, bool allowMultiple, bool allowNoAssignment, Pedantics p ) : bool
_n LNode
allowMultiple bool
allowNoAssignment bool
p Pedantics
리턴 bool

IsVariableDeclExpr() 공개 정적인 메소드

Verifies that a declaration of a single variable is valid and gets its parts.
public static IsVariableDeclExpr ( LNode expr, LNode &type, LNode &name, LNode &initialValue ) : bool
expr LNode Potential variable or field declaration
type LNode Variable type (empty identifier if `var`)
name LNode Variable name (identifier or $substutution expr)
initialValue LNode Initial value that is assigned in expr, or null if unassigned.
리턴 bool

KeyNameComponentOf() 공개 정적인 메소드

Given a complex name such as global::Foo<int>.Bar<T>, this method identifies the base name component, which in this example is Bar. This is used, for example, to identify the expected name for a constructor based on the class name, e.g. Foo<T> => Foo.
It is not verified that name is a complex identifier. There is no error detection but in some cases an empty name may be returned, e.g. for input like Foo."Hello".
public static KeyNameComponentOf ( LNode name ) : Symbol
name LNode
리턴 Symbol

MayBeImplicitChildStatement() 공개 정적인 메소드

Returns true if the specified child of the specified node can be an implicit child statement, i.e. a child statement that is not necessarily a braced block, e.g. the second child of a while loop.
This method helps the printer decide when a newline should be added before an unbraced child statement when there are no attributes dictating whether to add a newline or not. This method only cares about executable parent nodes. It returns false for class/space and function/property bodies, which are always braced blocks and therefore get a newline before every child statement automatically.
public static MayBeImplicitChildStatement ( LNode node, int childIndex ) : bool
node LNode
childIndex int
리턴 bool

MethodDefinitionKind() 공개 정적인 메소드

If the given node has a valid syntax tree for a method definition, a constructor, or (when orDelegate is true) a delegate definition, gets the definition kind (#fn, #cons, or #delegate).
Method declarations (no body) also count. A destructor counts as a #fn with a method name that calls the ~ operator.
public static MethodDefinitionKind ( LNode n, LNode &retType, LNode &name, LNode &args, LNode &body, bool allowDelegate, Pedantics p = Pedantics.Lax ) : Symbol
n LNode
retType LNode Return type of the method (if it's a constructor, this will be the empty identifier).
name LNode Name of the method.
args LNode args.Args is the argument list of the method.
body LNode The method body, or null if there is no method body. /// The method body calls if the method is a /// non-lambda-style method.
allowDelegate bool
p Pedantics
리턴 Symbol

MethodDefinitionKind() 공개 정적인 메소드

If the given node has a valid syntax tree for a method definition, a constructor, or (when orDelegate is true) a delegate definition, gets the definition kind (#fn, #cons, or #delegate).
public static MethodDefinitionKind ( LNode n, bool allowDelegate, Pedantics p = Pedantics.Lax ) : Symbol
n LNode
allowDelegate bool
p Pedantics
리턴 Symbol

SanitizeIdentifier() 공개 정적인 메소드

Eliminates punctuation and special characters from a string so that the string can be used as a plain C# identifier, e.g. "I'd" => "I_aposd", "123" => "_123", "+5" => "_plus5".
The empty string "" becomes "__empty__", ASCII punctuation becomes "_xyz" where xyz is an HTML entity name, e.g. '!' becomes "_excl", and all other characters become "Xxx" where xx is the hexadecimal representation of the code point. Designed for the Unicode BMP only.
public static SanitizeIdentifier ( string id ) : string
id string
리턴 string

SpaceDefinitionKind() 공개 정적인 메소드

Returns the space kind, which is one of the names #struct, #class, #enum, #interface, #namespace, #alias, #trait, or null if the node Name or structure is not valid for a space statement.
public static SpaceDefinitionKind ( LNode n, LNode &name, LNode &bases, LNode &body, Pedantics p = Pedantics.Lax ) : Symbol
n LNode The node to examine.
name LNode Name of the space.
bases LNode bases.Args will be the list of base types.
body LNode A braced block of statements holding the contents of the space.
p Pedantics
리턴 Symbol

SpaceDefinitionKind() 공개 정적인 메소드

Returns the space kind, which is one of the names #struct, #class, #enum, #interface, #namespace, #alias, #trait, or null if the node Name or structure is not valid for a space statement.
public static SpaceDefinitionKind ( LNode n, Pedantics p = Pedantics.Lax ) : Symbol
n LNode
p Pedantics
리턴 Symbol