Documentation
¶
Overview ¶
Package parser is a reusable concrete-syntax-tree parser for the Pawn language used by SA-MP and open.mp projects.
Index ¶
- func IsTopLevelDeclaration(k Kind) bool
- type BinarySyntax
- type BlockSyntax
- type ByteRange
- type CallSyntax
- type CompactError
- type CompactField
- type CompactFile
- func ParseCompact(source []byte, options ParseOptions) *CompactFile
- func ParseForLinter(source []byte) *CompactFile
- func ParseTokensCompact(source []byte, toks []token.Token, options ParseOptions) *CompactFile
- func ParseTokensCompactContext(ctx context.Context, source []byte, toks []token.Token, options ParseOptions) (*CompactFile, error)
- func ParseTokensForLinter(source []byte, toks []token.Token) *CompactFile
- func ParseWithProfile(source []byte, profile Profile) *CompactFile
- type CompactNode
- type CompactOrigin
- type CompactPosition
- type CompactToken
- type CompactTree
- type CompactTrivia
- type ConditionalSyntax
- type DeclarationBoundary
- type DeclarationIndex
- type DeclarationIterator
- type Diagnostic
- type DiagnosticCode
- type DirectiveSyntax
- type EnumSyntax
- type ExpressionSyntax
- type FieldID
- type File
- type FileID
- type FileSet
- type FunctionSyntax
- type IfSyntax
- type Kind
- type LoopSyntax
- type Node
- type ParameterIterator
- type ParameterSyntax
- type ParseOptions
- type Profile
- type Recovery
- type RecoveryConfidence
- type RecoveryKind
- type ReturnSyntax
- type SourceFile
- type StatementSyntax
- type SubscriptSyntax
- type SyntaxIterator
- type SyntaxNode
- func (n SyntaxNode) Bytes() []byte
- func (n SyntaxNode) Children() SyntaxIterator
- func (n SyntaxNode) Declarations() DeclarationIterator
- func (n SyntaxNode) Field(name string) (SyntaxNode, bool)
- func (n SyntaxNode) HasError() bool
- func (n SyntaxNode) Kind() Kind
- func (n SyntaxNode) MissingSemicolon() bool
- func (n SyntaxNode) Range() ByteRange
- func (n SyntaxNode) Text() string
- func (n SyntaxNode) Token() SyntaxToken
- func (n SyntaxNode) Valid() bool
- type SyntaxOrigin
- type SyntaxToken
- func (t SyntaxToken) Bytes() []byte
- func (t SyntaxToken) Kind() token.Kind
- func (t SyntaxToken) LeadingTrivia() []CompactTrivia
- func (t SyntaxToken) Origin() (SyntaxOrigin, bool)
- func (t SyntaxToken) Range() ByteRange
- func (t SyntaxToken) Text() string
- func (t SyntaxToken) TrailingTrivia() []CompactTrivia
- func (t SyntaxToken) Valid() bool
- type UnarySyntax
- type VariableSyntax
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTopLevelDeclaration ¶
IsTopLevelDeclaration reports whether k is a top-level declaration kind.
Types ¶
type BinarySyntax ¶
type BinarySyntax struct{ SyntaxNode }
BinarySyntax is a typed binary or assignment expression handle.
func AsBinary ¶
func AsBinary(n SyntaxNode) (BinarySyntax, bool)
AsBinary converts binary and assignment nodes.
func (BinarySyntax) Left ¶
func (b BinarySyntax) Left() (ExpressionSyntax, bool)
Left returns the left operand.
func (BinarySyntax) Right ¶
func (b BinarySyntax) Right() (ExpressionSyntax, bool)
Right returns the right operand.
type BlockSyntax ¶
type BlockSyntax struct{ SyntaxNode }
BlockSyntax is a typed block statement handle.
func (BlockSyntax) Statements ¶
func (b BlockSyntax) Statements() SyntaxIterator
Statements iterates statements in the block.
type ByteRange ¶
ByteRange is a half-open source byte range.
func ByteRangeFromSpan ¶
ByteRangeFromSpan drops s.File, keeping only the byte offsets.
type CallSyntax ¶
type CallSyntax struct{ SyntaxNode }
CallSyntax is a typed call expression handle.
func AsCall ¶
func AsCall(n SyntaxNode) (CallSyntax, bool)
AsCall converts n when it is a call expression.
func (CallSyntax) Arguments ¶
func (c CallSyntax) Arguments() SyntaxIterator
Arguments returns the argument nodes.
func (CallSyntax) Function ¶
func (c CallSyntax) Function() (ExpressionSyntax, bool)
Function returns the called expression.
type CompactError ¶
type CompactError struct {
Message string
Node uint32
Offset uint32
Found token.Kind
ExpectedStart uint32
ExpectedCount uint32
}
CompactError stores sparse recovery data.
type CompactField ¶
CompactField maps a field name to a node.
type CompactFile ¶
type CompactFile struct {
Source []byte
Tokens []CompactToken
Trivia []CompactTrivia
Origins []CompactOrigin
MacroNames []string
Lines token.LineMap
Tree CompactTree
Broken bool
Diagnostics []Diagnostic
Profile Profile
}
CompactFile is an index-based CST.
func ParseCompact ¶
func ParseCompact(source []byte, options ParseOptions) *CompactFile
ParseCompact parses source into a compact CST.
func ParseForLinter ¶
func ParseForLinter(source []byte) *CompactFile
ParseForLinter parses source without retaining tokens or trivia.
func ParseTokensCompact ¶
func ParseTokensCompact(source []byte, toks []token.Token, options ParseOptions) *CompactFile
ParseTokensCompact parses tokens into a compact CST.
func ParseTokensCompactContext ¶ added in v1.3.0
func ParseTokensCompactContext( ctx context.Context, source []byte, toks []token.Token, options ParseOptions, ) (*CompactFile, error)
ParseTokensCompactContext parses tokens with cancellation.
func ParseTokensForLinter ¶
func ParseTokensForLinter(source []byte, toks []token.Token) *CompactFile
ParseTokensForLinter parses an existing token stream for linting.
func ParseWithProfile ¶
func ParseWithProfile(source []byte, profile Profile) *CompactFile
ParseWithProfile parses source using a consumer-oriented retention profile.
func (*CompactFile) Expand ¶
func (f *CompactFile) Expand() *File
Expand builds the pointer CST represented by f.
func (*CompactFile) HasParseErrors ¶
func (f *CompactFile) HasParseErrors() bool
HasParseErrors reports whether compact parsing produced a syntax error.
func (*CompactFile) Syntax ¶
func (f *CompactFile) Syntax() SyntaxNode
Syntax returns the root syntax node.
type CompactNode ¶
type CompactNode struct {
Kind Kind
Start uint32
End uint32
TokenKind token.Kind
TokenStart uint32
TokenEnd uint32
ChildStart uint32
ChildCount uint32
FieldStart uint32
FieldCount uint32
HasError bool
MissingSemi bool
HasRaw bool
}
CompactNode stores one tree node.
func (CompactNode) Bytes ¶
func (n CompactNode) Bytes(source []byte) []byte
Bytes returns the node's exact source bytes without allocating.
func (CompactNode) Range ¶
func (n CompactNode) Range() ByteRange
Range returns the node's half-open source byte range.
func (CompactNode) Text ¶
func (n CompactNode) Text(source []byte) string
Text returns the node's exact source text.
type CompactPosition ¶
type CompactPosition = token.CompactPosition
CompactPosition stores a compact source position.
type CompactToken ¶
type CompactToken = token.CompactToken
CompactToken stores one token with indexed metadata.
type CompactTree ¶
type CompactTree struct {
Nodes []CompactNode
Children []uint32
Fields []CompactField
Errors []CompactError
Expected []token.Kind
Root uint32
}
CompactTree stores nodes and edges in arrays.
func (*CompactTree) ChildIndices ¶
func (t *CompactTree) ChildIndices(node uint32) []uint32
ChildIndices returns the child indices for node.
type ConditionalSyntax ¶
type ConditionalSyntax struct{ SyntaxNode }
ConditionalSyntax is a typed conditional region handle.
func AsConditional ¶
func AsConditional(n SyntaxNode) (ConditionalSyntax, bool)
AsConditional converts conditional region nodes.
func (ConditionalSyntax) Branches ¶
func (c ConditionalSyntax) Branches() SyntaxIterator
Branches iterates conditional branches.
type DeclarationBoundary ¶ added in v1.2.0
type DeclarationBoundary struct {
Kind Kind
Range ByteRange
Name string
Identity [sha256.Size]byte
Fingerprint [sha256.Size]byte
HasError bool
}
DeclarationBoundary identifies one top-level declaration.
type DeclarationIndex ¶ added in v1.2.0
type DeclarationIndex struct {
// contains filtered or unexported fields
}
DeclarationIndex is an immutable declaration boundary table.
func BuildDeclarationIndex ¶ added in v1.2.0
func BuildDeclarationIndex(file *CompactFile) DeclarationIndex
BuildDeclarationIndex indexes the top-level declarations in file.
func (DeclarationIndex) At ¶ added in v1.2.0
func (i DeclarationIndex) At(n int) (DeclarationBoundary, bool)
At returns the declaration at position n.
func (DeclarationIndex) Len ¶ added in v1.2.0
func (i DeclarationIndex) Len() int
Len returns the number of declarations.
func (DeclarationIndex) Reliable ¶ added in v1.2.0
func (i DeclarationIndex) Reliable() bool
Reliable reports whether every boundary was recovered cleanly.
type DeclarationIterator ¶
type DeclarationIterator struct {
// contains filtered or unexported fields
}
DeclarationIterator iterates top-level declarations without allocating.
func (*DeclarationIterator) Declaration ¶
func (i *DeclarationIterator) Declaration() SyntaxNode
Declaration returns the current declaration.
func (*DeclarationIterator) Next ¶
func (i *DeclarationIterator) Next() bool
Next advances to the next declaration.
type Diagnostic ¶
type Diagnostic struct {
Code DiagnosticCode
Message string
Range ByteRange
Found token.Token
Expected []token.Kind
Recovery Recovery
}
Diagnostic is a structured syntax error produced while building the CST.
func (Diagnostic) ToCore ¶
func (d Diagnostic) ToCore(file source.FileID) diagnostic.Diagnostic
ToCore converts d to the shared diagnostic format. Parser diagnostics currently use error severity.
type DiagnosticCode ¶
type DiagnosticCode string
DiagnosticCode is a stable, machine-readable syntax diagnostic identifier.
const ( // DiagnosticUnexpectedToken reports a token consumed by generic recovery. DiagnosticUnexpectedToken DiagnosticCode = "unexpected_token" // DiagnosticUnexpectedDelimiter reports an unmatched closing delimiter. DiagnosticUnexpectedDelimiter DiagnosticCode = "unexpected_closing_delimiter" // DiagnosticMissingToken reports required punctuation that was absent. DiagnosticMissingToken DiagnosticCode = "missing_token" // DiagnosticMissingExpression reports an absent expression operand. DiagnosticMissingExpression DiagnosticCode = "missing_expression" // DiagnosticMissingIdentifier reports an absent required identifier. DiagnosticMissingIdentifier DiagnosticCode = "missing_identifier" // DiagnosticMissingDeclaration reports an absent declaration component. DiagnosticMissingDeclaration DiagnosticCode = "missing_declaration_component" // DiagnosticMaximumDepth reports that the parser nesting limit was reached. DiagnosticMaximumDepth DiagnosticCode = "maximum_parse_depth" // DiagnosticUnrecoverable reports that parsing could not make progress. DiagnosticUnrecoverable DiagnosticCode = "unrecoverable_parse_failure" // DiagnosticSyntaxError reports an error node without a more specific code. DiagnosticSyntaxError DiagnosticCode = "syntax_error" )
type DirectiveSyntax ¶
type DirectiveSyntax struct{ SyntaxNode }
DirectiveSyntax is a typed preprocessor directive handle.
func AsDirective ¶
func AsDirective(n SyntaxNode) (DirectiveSyntax, bool)
AsDirective converts n when it is a directive.
type EnumSyntax ¶
type EnumSyntax struct{ SyntaxNode }
EnumSyntax is a typed enum declaration handle.
func AsEnum ¶
func AsEnum(n SyntaxNode) (EnumSyntax, bool)
AsEnum converts n when it is an enum declaration.
func (EnumSyntax) Entries ¶
func (e EnumSyntax) Entries() SyntaxIterator
Entries iterates enum entries.
func (EnumSyntax) Name ¶
func (e EnumSyntax) Name() (SyntaxNode, bool)
Name returns the enum name when present.
type ExpressionSyntax ¶
type ExpressionSyntax struct{ SyntaxNode }
ExpressionSyntax is a lightweight expression handle.
type File ¶
type File struct {
Source []byte
Tokens []token.Token
Root *Node
Broken bool
Diagnostics []Diagnostic
}
File is the result of parsing one Pawn source file/buffer.
func Parse ¶
Parse parses source into a File. Parse errors are reported via File.Broken and Node.HasError.
func ParseTokens ¶
ParseTokens parses a caller-provided token stream. It is useful for parsing preprocessed tokens whose Origin fields retain expansion history.
func ParseTokensWithOptions ¶
func ParseTokensWithOptions(source []byte, toks []token.Token, options ParseOptions) *File
ParseTokensWithOptions parses tokens with retention options.
func ParseWithOptions ¶
func ParseWithOptions(source []byte, options ParseOptions) *File
ParseWithOptions parses source with retention options.
func (*File) HasParseErrors ¶
HasParseErrors reports whether parsing produced a syntax diagnostic or an unrecoverable/broken result.
type FileSet ¶
type FileSet struct {
// contains filtered or unexported fields
}
FileSet owns logical source files and assigns deterministic IDs in insertion order. Logical names can be used instead of host paths in generated output.
func (*FileSet) Add ¶
func (s *FileSet) Add(name string, data []byte) SourceFile
Add copies data into the set and returns the newly added source file.
func (*FileSet) File ¶
func (s *FileSet) File(id FileID) (SourceFile, bool)
File returns the source file with id, if it exists.
func (*FileSet) Files ¶
func (s *FileSet) Files() []SourceFile
Files returns a copy of the set's source-file list.
type FunctionSyntax ¶
type FunctionSyntax struct{ SyntaxNode }
FunctionSyntax is a typed function declaration or definition handle.
func AsFunction ¶
func AsFunction(n SyntaxNode) (FunctionSyntax, bool)
AsFunction converts n when it is a function node.
func (FunctionSyntax) Body ¶
func (f FunctionSyntax) Body() (BlockSyntax, bool)
Body returns the function body when present.
func (FunctionSyntax) Name ¶
func (f FunctionSyntax) Name() (SyntaxNode, bool)
Name returns the function name.
func (FunctionSyntax) Parameters ¶
func (f FunctionSyntax) Parameters() ParameterIterator
Parameters returns the function parameter list.
type IfSyntax ¶
type IfSyntax struct{ SyntaxNode }
IfSyntax is a typed if statement handle.
func (IfSyntax) Alternative ¶
func (s IfSyntax) Alternative() (StatementSyntax, bool)
Alternative returns the else branch when present.
func (IfSyntax) Condition ¶
func (s IfSyntax) Condition() (ExpressionSyntax, bool)
Condition returns the if condition.
func (IfSyntax) Consequence ¶
func (s IfSyntax) Consequence() (StatementSyntax, bool)
Consequence returns the if consequence.
type Kind ¶
type Kind uint16
Kind identifies the syntactic category of a Node in the parsed CST.
const ( // KindInvalid is the zero value of Kind, used for uninitialized nodes. KindInvalid Kind = iota KindSourceFile KindComment KindRaw // Directives KindDirectiveInclude KindDirectiveTryInclude KindDirectiveDefine KindDirectiveUndef KindDirectiveIf KindDirectiveElseif KindDirectiveElse KindDirectiveEndif KindDirectivePragma KindDirectiveError KindDirectiveWarning KindDirectiveEmit KindDirectiveAssert KindDirectiveLine KindDirectiveFile KindDirectiveEndinput KindDirectiveRaw KindConditionalRegion KindConditionalBranch KindConditionalFunction // Declarations KindFunctionDefinition KindFunctionDeclaration KindVariableDeclaration KindVariableDeclarator KindEnumDeclaration KindEnumEntry KindParameterList KindParameter KindArgumentList KindDimension KindTaggedType // Statements KindBlock KindIfStatement KindWhileStatement KindDoWhileStatement KindForStatement KindSwitchStatement KindCaseClause KindDefaultClause KindCaseValueList KindCaseRange KindGotoStatement KindLabelStatement KindReturnStatement KindBreakStatement KindContinueStatement KindStateStatement KindExpressionStatement KindEmptyStatement KindMacroInvocationBlock // Expressions KindIdentifier KindLiteral KindCallExpression KindSubscriptExpression KindTernaryExpression KindBinaryExpression KindUnaryExpression KindUpdateExpression KindAssignmentExpression KindSizeofExpression KindTagofExpression KindDefinedExpression KindTaggedExpression KindParenthesizedExpression KindArrayLiteral KindExpressionList KindArgumentName KindIteratorArgument KindStringizeExpression KindStringConcat KindConditionalSplice KindDirectivePath KindMacroBody KindEnumIncrementClause KindStateSelector KindMacroInvocation )
func (Kind) IsDirective ¶
IsDirective reports whether k is one of the directive node kinds.
type LoopSyntax ¶
type LoopSyntax struct{ SyntaxNode }
LoopSyntax is a typed loop statement handle.
func AsLoop ¶
func AsLoop(n SyntaxNode) (LoopSyntax, bool)
AsLoop converts while, do-while, and for nodes.
func (LoopSyntax) Body ¶
func (s LoopSyntax) Body() (StatementSyntax, bool)
Body returns the loop body.
func (LoopSyntax) Condition ¶
func (s LoopSyntax) Condition() (ExpressionSyntax, bool)
Condition returns the loop condition when present.
type Node ¶
type Node struct {
Kind Kind
Tok token.Token
Children []*Node
Start int
End int
HasError bool
Raw []byte
ErrorMessage string
ErrorOffset int
ErrorFound token.Kind
ErrorExpected []token.Kind
MissingSemi bool
Leading []token.Trivia
Trailing []token.Trivia
// contains filtered or unexported fields
}
Node is a single element of the concrete syntax tree produced by Parse.
func (*Node) LeadingTrivia ¶
LeadingTrivia returns the trivia attached before the node's first token.
func (*Node) OperatorTokenHasComment ¶
OperatorTokenHasComment reports whether n's operator token has a leading or trailing comment attached.
func (*Node) TrailingTrivia ¶
TrailingTrivia returns the trivia attached after the node's last token.
type ParameterIterator ¶
type ParameterIterator struct {
// contains filtered or unexported fields
}
ParameterIterator iterates parameters without allocating.
func (*ParameterIterator) Next ¶
func (i *ParameterIterator) Next() bool
Next advances to the next parameter.
func (*ParameterIterator) Parameter ¶
func (i *ParameterIterator) Parameter() ParameterSyntax
Parameter returns the current parameter.
type ParameterSyntax ¶
type ParameterSyntax struct{ SyntaxNode }
ParameterSyntax is a typed parameter handle.
func (ParameterSyntax) DefaultValue ¶
func (p ParameterSyntax) DefaultValue() (ExpressionSyntax, bool)
DefaultValue returns the default value when present.
func (ParameterSyntax) Name ¶
func (p ParameterSyntax) Name() (SyntaxNode, bool)
Name returns the parameter name.
type ParseOptions ¶
ParseOptions controls retained parse data.
type Recovery ¶
type Recovery struct {
Kind RecoveryKind
Range ByteRange
Replacement string
Confidence RecoveryConfidence
}
Recovery describes a source edit associated with a diagnostic.
type RecoveryConfidence ¶
type RecoveryConfidence string
RecoveryConfidence states whether a recovery is safe to apply directly.
const ( // RecoveryExact marks an unambiguous parser-selected edit. RecoveryExact RecoveryConfidence = "exact" // RecoverySuggested marks an ambiguous, non-applicable recovery hint. RecoverySuggested RecoveryConfidence = "suggested" )
type RecoveryKind ¶
type RecoveryKind string
RecoveryKind describes the edit shape selected during recovery.
const ( // RecoveryNone indicates that no directly applicable edit is available. RecoveryNone RecoveryKind = "none" // RecoveryInsert inserts replacement text at an empty recovery range. RecoveryInsert RecoveryKind = "insert" // RecoveryRemove removes the recovery range. RecoveryRemove RecoveryKind = "remove" // RecoveryReplace replaces the recovery range with replacement text. RecoveryReplace RecoveryKind = "replace" )
type ReturnSyntax ¶
type ReturnSyntax struct{ SyntaxNode }
ReturnSyntax is a typed return statement handle.
func AsReturn ¶
func AsReturn(n SyntaxNode) (ReturnSyntax, bool)
AsReturn converts n when it is a return statement.
func (ReturnSyntax) Expression ¶
func (r ReturnSyntax) Expression() (ExpressionSyntax, bool)
Expression returns the returned expression when present.
type SourceFile ¶
SourceFile contains a logical source file and its stable ID.
type StatementSyntax ¶
type StatementSyntax struct{ SyntaxNode }
StatementSyntax is a lightweight statement handle.
type SubscriptSyntax ¶
type SubscriptSyntax struct{ SyntaxNode }
SubscriptSyntax is a typed array access handle.
func AsSubscript ¶
func AsSubscript(n SyntaxNode) (SubscriptSyntax, bool)
AsSubscript converts n when it is a subscript expression.
func (SubscriptSyntax) Array ¶
func (s SubscriptSyntax) Array() (ExpressionSyntax, bool)
Array returns the indexed expression.
func (SubscriptSyntax) Index ¶
func (s SubscriptSyntax) Index() (ExpressionSyntax, bool)
Index returns the index expression when present.
type SyntaxIterator ¶
type SyntaxIterator struct {
// contains filtered or unexported fields
}
SyntaxIterator iterates syntax nodes without allocating.
func (*SyntaxIterator) Node ¶
func (i *SyntaxIterator) Node() SyntaxNode
Node returns the current node.
type SyntaxNode ¶
type SyntaxNode struct {
// contains filtered or unexported fields
}
SyntaxNode is a lightweight handle into an immutable compact tree.
func (SyntaxNode) Bytes ¶
func (n SyntaxNode) Bytes() []byte
Bytes returns the node source bytes without allocating.
func (SyntaxNode) Children ¶
func (n SyntaxNode) Children() SyntaxIterator
Children returns an allocation-free child iterator.
func (SyntaxNode) Declarations ¶
func (n SyntaxNode) Declarations() DeclarationIterator
Declarations iterates top-level declarations.
func (SyntaxNode) Field ¶
func (n SyntaxNode) Field(name string) (SyntaxNode, bool)
Field returns a named child.
func (SyntaxNode) HasError ¶
func (n SyntaxNode) HasError() bool
HasError reports whether the node contains syntax errors.
func (SyntaxNode) MissingSemicolon ¶
func (n SyntaxNode) MissingSemicolon() bool
MissingSemicolon reports whether recovery inserted a semicolon.
func (SyntaxNode) Range ¶
func (n SyntaxNode) Range() ByteRange
Range returns the node source range.
func (SyntaxNode) Token ¶
func (n SyntaxNode) Token() SyntaxToken
Token returns the node's primary token reference.
func (SyntaxNode) Valid ¶
func (n SyntaxNode) Valid() bool
Valid reports whether n refers to a tree node.
type SyntaxOrigin ¶
type SyntaxOrigin struct {
// contains filtered or unexported fields
}
SyntaxOrigin is a lightweight origin-chain handle.
func (SyntaxOrigin) Macro ¶
func (o SyntaxOrigin) Macro() string
Macro returns the originating macro name.
func (SyntaxOrigin) Parent ¶
func (o SyntaxOrigin) Parent() (SyntaxOrigin, bool)
Parent returns the parent origin when present.
func (SyntaxOrigin) Span ¶
func (o SyntaxOrigin) Span() token.Span
Span returns the origin source span.
func (SyntaxOrigin) Valid ¶
func (o SyntaxOrigin) Valid() bool
Valid reports whether the origin exists.
type SyntaxToken ¶
type SyntaxToken struct {
// contains filtered or unexported fields
}
SyntaxToken is a lightweight token reference.
func (SyntaxToken) Bytes ¶
func (t SyntaxToken) Bytes() []byte
Bytes returns token source bytes without allocating.
func (SyntaxToken) LeadingTrivia ¶
func (t SyntaxToken) LeadingTrivia() []CompactTrivia
LeadingTrivia returns retained leading trivia.
func (SyntaxToken) Origin ¶
func (t SyntaxToken) Origin() (SyntaxOrigin, bool)
Origin returns the first retained token origin.
func (SyntaxToken) Range ¶
func (t SyntaxToken) Range() ByteRange
Range returns the token source range.
func (SyntaxToken) TrailingTrivia ¶
func (t SyntaxToken) TrailingTrivia() []CompactTrivia
TrailingTrivia returns retained trailing trivia.
func (SyntaxToken) Valid ¶
func (t SyntaxToken) Valid() bool
Valid reports whether the token reference is present.
type UnarySyntax ¶
type UnarySyntax struct{ SyntaxNode }
UnarySyntax is a typed unary expression handle.
func AsUnary ¶
func AsUnary(n SyntaxNode) (UnarySyntax, bool)
AsUnary converts unary and update nodes.
func (UnarySyntax) Expression ¶
func (u UnarySyntax) Expression() (ExpressionSyntax, bool)
Expression returns the unary operand.
type VariableSyntax ¶
type VariableSyntax struct{ SyntaxNode }
VariableSyntax is a typed variable declarator handle.
func AsVariable ¶
func AsVariable(n SyntaxNode) (VariableSyntax, bool)
AsVariable converts n when it is a variable declarator.
func (VariableSyntax) Initializer ¶
func (v VariableSyntax) Initializer() (ExpressionSyntax, bool)
Initializer returns the variable initializer when present.
func (VariableSyntax) Name ¶
func (v VariableSyntax) Name() (SyntaxNode, bool)
Name returns the variable name.
Source Files
¶
- calls.go
- compact.go
- compact_expand.go
- compact_sink.go
- conditionals.go
- core.go
- declaration_index.go
- declaration_parts.go
- declarations.go
- declarators.go
- diagnostic.go
- directive_lines.go
- directives.go
- expressions.go
- fields.go
- function_declarations.go
- kind.go
- literals.go
- macros.go
- node.go
- node_sink.go
- parameters.go
- parser.go
- profile.go
- simple_statements.go
- source.go
- statements.go
- switches.go
- syntax.go
- toplevel.go
- typed_syntax.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package lexer is a standalone tokenizer for the Pawn language.
|
Package lexer is a standalone tokenizer for the Pawn language. |
|
Package token defines token kinds, positions, and trivia shared by the lexer and parser packages.
|
Package token defines token kinds, positions, and trivia shared by the lexer and parser packages. |