Documentation
¶
Index ¶
- func IsAssignment(nodeType string) bool
- func IsAttribute(nodeType string) bool
- func IsBlock(nodeType string) bool
- func IsCall(nodeType string) bool
- func IsCaseClause(nodeType string) bool
- func IsClosingDelimiter(token string) bool
- func IsClosure(nodeType string) bool
- func IsComment(nodeType string) bool
- func IsContainer(nodeType string) bool
- func IsContainerDeclaration(nodeType string) bool
- func IsDeclaration(nodeType string) bool
- func IsDeclarator(nodeType string) bool
- func IsDelimitedContainer(nodeType string) bool
- func IsDelimiter(nodeType, label string) bool
- func IsExpression(nodeType string) bool
- func IsExpressionStatement(nodeType string) bool
- func IsFlattened(nodeType string) bool
- func IsIdentifier(nodeType string) bool
- func IsImport(nodeType string) bool
- func IsIndexed(nodeType string) bool
- func IsJumpStatement(nodeType string) bool
- func IsKeyword(nodeType, label string) bool
- func IsLocalVarDeclaration(nodeType string) bool
- func IsOpeningDelimiter(token string) bool
- func IsOperatorLiteral(nodeType string) bool
- func IsPunctuation(token string) bool
- func IsScaffolding(nodeType string) bool
- func IsSelector(nodeType string) bool
- func IsSentinel(label string) bool
- func IsStatement(nodeType string) bool
- func IsTrailingSeparator(token string) bool
- func IsType(nodeType string) bool
- func IsWrapper(nodeType string) bool
- type Rules
- func (r *Rules) Alias(nodeType, label string) (string, bool)
- func (r *Rules) AreTypesEquivalent(t1, t2 string) bool
- func (r *Rules) CompileSets()
- func (r *Rules) DefaultRootType() string
- func (r *Rules) IsAssignment(nodeType string) bool
- func (r *Rules) IsAttribute(nodeType string) bool
- func (r *Rules) IsBlock(nodeType string) bool
- func (r *Rules) IsCall(nodeType string) bool
- func (r *Rules) IsCaseClause(nodeType string) bool
- func (r *Rules) IsClosingDelimiter(token string) bool
- func (r *Rules) IsClosure(nodeType string) bool
- func (r *Rules) IsComment(nodeType string) bool
- func (r *Rules) IsContainer(nodeType string) bool
- func (r *Rules) IsContainerDeclaration(nodeType string) bool
- func (r *Rules) IsDeclaration(nodeType string) bool
- func (r *Rules) IsDeclarator(nodeType string) bool
- func (r *Rules) IsDelimitedContainer(nodeType string) bool
- func (r *Rules) IsDelimiter(nodeType, label string) bool
- func (r *Rules) IsExpression(nodeType string) bool
- func (r *Rules) IsExpressionStatement(nodeType string) bool
- func (r *Rules) IsFlattened(nodeType string) bool
- func (r *Rules) IsIdentifier(nodeType string) bool
- func (r *Rules) IsIgnored(nodeType, label string) bool
- func (r *Rules) IsImport(nodeType string) bool
- func (r *Rules) IsIndexed(nodeType string) bool
- func (r *Rules) IsJumpStatement(nodeType string) bool
- func (r *Rules) IsKeyword(nodeType, label string) bool
- func (r *Rules) IsLocalVarDeclaration(nodeType string) bool
- func (r *Rules) IsOpeningDelimiter(token string) bool
- func (r *Rules) IsOperatorLiteral(nodeType string) bool
- func (r *Rules) IsPair(nodeType string) bool
- func (r *Rules) IsPunctuation(token string) bool
- func (r *Rules) IsScaffolding(nodeType string) bool
- func (r *Rules) IsSelector(nodeType string) bool
- func (r *Rules) IsSentinel(label string) bool
- func (r *Rules) IsStatement(nodeType string) bool
- func (r *Rules) IsTag(nodeType string) bool
- func (r *Rules) IsTerminalCallPath(calleePath string) bool
- func (r *Rules) IsTrailingSeparator(token string) bool
- func (r *Rules) IsType(nodeType string) bool
- func (r *Rules) IsUnordered(nodeType string) bool
- func (r *Rules) IsWrapper(nodeType string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAssignment ¶ added in v0.12.0
IsAssignment reports whether nodeType is configured as an assignment in any language rule set.
func IsAttribute ¶ added in v0.16.0
IsAttribute reports whether nodeType is configured as an attribute or decorator in any language rule set.
func IsCaseClause ¶ added in v0.10.0
IsCaseClause reports whether nodeType is configured as a case clause in any language rule set.
func IsClosingDelimiter ¶ added in v0.12.0
IsClosingDelimiter checks if token closes a container under any registered language rules.
func IsClosure ¶ added in v0.8.0
IsClosure reports whether nodeType is configured as a closure in any language rule set.
func IsComment ¶
IsComment reports whether nodeType is configured as a comment in any language rule set.
func IsContainer ¶ added in v0.12.0
IsContainer reports whether any registered language treats nodeType as a container.
func IsContainerDeclaration ¶ added in v0.8.0
IsContainerDeclaration reports whether nodeType is configured as a container declaration in any language rule set.
func IsDeclaration ¶
IsDeclaration reports whether nodeType is configured as a declaration in any language rule set.
func IsDeclarator ¶ added in v0.16.0
IsDeclarator reports whether nodeType is configured as a declarator in any language rule set.
func IsDelimitedContainer ¶ added in v0.9.0
IsDelimitedContainer reports whether nodeType is a delimited container in any registered language.
func IsDelimiter ¶
IsDelimiter reports whether nodeType or label is a delimiter token (semicolon or comma).
func IsExpression ¶ added in v0.10.0
IsExpression reports whether nodeType is configured as an expression in any language rule set.
func IsExpressionStatement ¶ added in v0.10.0
IsExpressionStatement reports whether nodeType represents an expression statement.
func IsFlattened ¶
IsFlattened reports whether nodeType is configured as flattened in any language rule set.
func IsIdentifier ¶
IsIdentifier reports whether nodeType is configured as an identifier in any language rule set.
func IsImport ¶ added in v0.16.0
IsImport reports whether nodeType is configured as an import in any language rule set.
func IsIndexed ¶ added in v0.8.0
IsIndexed reports whether nodeType is configured as an indexed container in any language rule set.
func IsJumpStatement ¶ added in v0.9.0
IsJumpStatement reports whether nodeType is configured as a jump statement in any language rule set.
func IsKeyword ¶
IsKeyword reports whether nodeType or label is configured as a keyword in any language rule set.
func IsLocalVarDeclaration ¶ added in v0.8.0
IsLocalVarDeclaration reports whether nodeType is configured as a local variable declaration in any language rule set.
func IsOpeningDelimiter ¶ added in v0.12.0
IsOpeningDelimiter checks if token opens a container under any registered language rules.
func IsOperatorLiteral ¶
IsOperatorLiteral reports whether nodeType is configured as an operator literal in any language rule set.
func IsPunctuation ¶ added in v0.8.0
IsPunctuation reports whether a string is a structural punctuation token in any language rule set.
func IsScaffolding ¶
IsScaffolding reports whether nodeType is configured as scaffolding in any language rule set.
func IsSelector ¶ added in v0.17.0
IsSelector reports whether nodeType is a selector/field access in any registered language.
func IsSentinel ¶ added in v0.11.0
IsSentinel reports whether label is a sentinel in any language rule set.
func IsStatement ¶ added in v0.12.0
IsStatement reports whether nodeType represents a statement in any language rule set.
func IsTrailingSeparator ¶ added in v0.12.0
IsTrailingSeparator checks if token is an item separator in any registered language.
Types ¶
type Rules ¶
type Rules struct {
Flattened []string
Ignored []string
Aliased map[string]string
Scaffolding []string
Keywords []string
Declarations []string
Identifiers []string
Blocks []string
Wrappers []string
Pairs []string
Unordered []string
EquivalentTypes [][]string
Comments []string
Calls []string
Indexed []string // Subscript nodes with prefix receivers (e.g. arr[i]).
LocalVarDeclarations []string
Assignments []string // Assignment expressions or statements (e.g. assignment_expression, assignment_statement).
ContainerDeclarations []string // Major declaration scope boundaries (functions, classes, structs, etc.).
Closures []string // Anonymous functions, lambdas, and callbacks.
Types []string // Type annotations and type expressions.
JumpStatements []string // Control-flow exit statements (return, break, continue, goto, throw, raise).
TerminalCalls []string // Dotted callee paths for execution-terminating calls (os.Exit, sys.exit, panic, etc.).
DelimitedContainers []string // Containers whose elements are separated by delimiters (like commas).
Selectors []string // Member or field access expressions (e.g. selector_expression, field_expression, member_expression, attribute, field_access).
Expressions []string // Expression container node types.
CaseClauses []string // Arms that hold statements directly without curly braces (case, default, when, match_arm).
Tags []string // Markup elements and tags (e.g. element, start_tag, jsx_element, jsx_opening_element).
Sentinels []string // Built-in nil, null, and boolean identifiers (e.g. NULL, None, undefined).
Statements []string // Standalone statement and statement-level declaration node types.
Imports []string // Import and include declaration node types.
Attributes []string // Decorators, attributes, and annotations on declarations (e.g. attribute_item).
Declarators []string // Declarator node types holding declaration identifiers and parameters (e.g. function_declarator).
OpeningDelimiters []string // Container openers; defaults to standard brackets, braces, and angles unless overridden per language.
ClosingDelimiters []string // Matching container closers used to locate headers and closing delimiter spans.
Separators []string // Punctuation between sibling elements (commas, match arrows, colons) absorbed as trailing trivia.
// SignificantWhitespace reports whether indentation defines blocks and scope (as in Python).
SignificantWhitespace bool
// contains filtered or unexported fields
}
Rules configures language-specific AST transformations and node matching.
func Get ¶
Get returns the compiled AST rules for a language, or a default empty rule set if none exist.
func (*Rules) Alias ¶
Alias returns the replacement node type if one exists for the label or node type.
func (*Rules) AreTypesEquivalent ¶
AreTypesEquivalent reports whether t1 and t2 belong to the same equivalent_types group.
func (*Rules) CompileSets ¶
func (r *Rules) CompileSets()
CompileSets builds the internal lookup sets for fast querying.
func (*Rules) DefaultRootType ¶
DefaultRootType returns the top-level root AST node type for the language.
func (*Rules) IsAssignment ¶ added in v0.12.0
IsAssignment reports whether nodeType is an assignment expression or statement.
func (*Rules) IsAttribute ¶ added in v0.16.0
IsAttribute reports whether nodeType is an attribute or decorator in the language.
func (*Rules) IsCaseClause ¶ added in v0.10.0
IsCaseClause reports whether nodeType is a branch or pattern arm in a switch/match/select statement.
func (*Rules) IsClosingDelimiter ¶ added in v0.12.0
IsClosingDelimiter checks if token marks the end of an enclosed body or argument list.
func (*Rules) IsClosure ¶ added in v0.8.0
IsClosure reports whether nodeType is an anonymous function, closure, or lambda callback.
func (*Rules) IsContainer ¶ added in v0.12.0
IsContainer reports whether nodeType wraps children (block, wrapper, unordered, or indexed).
func (*Rules) IsContainerDeclaration ¶ added in v0.8.0
IsContainerDeclaration reports whether nodeType is a major container declaration (such as a function, method, class, struct, interface, trait, or enum).
func (*Rules) IsDeclaration ¶
IsDeclaration reports whether nodeType is a declaration.
func (*Rules) IsDeclarator ¶ added in v0.16.0
IsDeclarator reports whether nodeType is a declarator holding declaration identifiers and parameters.
func (*Rules) IsDelimitedContainer ¶ added in v0.9.0
IsDelimitedContainer reports whether nodeType is a comma-delimited container (like an argument list or array).
func (*Rules) IsDelimiter ¶
IsDelimiter reports whether nodeType or label is a delimiter token (semicolon or comma).
func (*Rules) IsExpression ¶ added in v0.10.0
IsExpression reports whether nodeType represents an expression node.
func (*Rules) IsExpressionStatement ¶ added in v0.10.0
IsExpressionStatement reports whether nodeType represents an expression statement.
func (*Rules) IsFlattened ¶
IsFlattened checks if intermediate nodes of this type should merge into their parent.
func (*Rules) IsIdentifier ¶
IsIdentifier reports whether nodeType is an identifier token.
func (*Rules) IsIgnored ¶
IsIgnored checks if a node type or label is filtered out when building the AST.
func (*Rules) IsImport ¶ added in v0.16.0
IsImport reports whether nodeType is an import or include declaration.
func (*Rules) IsIndexed ¶ added in v0.8.0
IsIndexed reports whether nodeType is a subscript container with a prefix receiver.
func (*Rules) IsJumpStatement ¶ added in v0.9.0
IsJumpStatement reports whether nodeType is an early-exit jump statement (such as return, break, continue, goto, throw, raise, yield).
func (*Rules) IsLocalVarDeclaration ¶ added in v0.8.0
IsLocalVarDeclaration reports whether nodeType is a local variable declaration.
func (*Rules) IsOpeningDelimiter ¶ added in v0.12.0
IsOpeningDelimiter checks if token marks the start of a block, wrapper, or parameter list.
func (*Rules) IsOperatorLiteral ¶
IsOperatorLiteral reports whether nodeType is an aliased operator literal.
func (*Rules) IsPair ¶ added in v0.8.0
IsPair checks if nodeType represents a key-value property pair.
func (*Rules) IsPunctuation ¶ added in v0.8.0
IsPunctuation reports whether a string is a structural punctuation token (braces, brackets, parentheses, delimiters).
func (*Rules) IsScaffolding ¶
IsScaffolding reports whether nodeType is scaffolding.
func (*Rules) IsSelector ¶ added in v0.17.0
IsSelector reports whether nodeType is a member or field access expression.
func (*Rules) IsSentinel ¶ added in v0.11.0
IsSentinel reports whether label is a built-in sentinel identifier (like NULL, None, or undefined).
func (*Rules) IsStatement ¶ added in v0.12.0
IsStatement reports whether nodeType represents a statement or statement-level declaration.
func (*Rules) IsTag ¶ added in v0.10.0
IsTag reports whether nodeType represents a markup element or tag.
func (*Rules) IsTerminalCallPath ¶ added in v0.9.0
IsTerminalCallPath reports whether calleePath matches an execution-terminating call. The path is a dot-joined identifier (e.g. "os.Exit", "sys.exit", "panic").
func (*Rules) IsTrailingSeparator ¶ added in v0.12.0
IsTrailingSeparator checks if token acts as a delimiter between sibling items in lists or match arms.
func (*Rules) IsType ¶ added in v0.8.0
IsType reports whether nodeType is a type annotation or type expression in the language.
func (*Rules) IsUnordered ¶
IsUnordered checks if child order doesn't matter for this container.