Documentation ¶
Overview ¶
Package syntax provides a fast high fidelity parser for TTCN-3.
Index ¶
- Constants
- Variables
- type Builder
- type Error
- type Kind
- type Node
- func (n Node) End() int
- func (n Node) Err() error
- func (n Node) FirstChild() Node
- func (n Node) FirstToken() Node
- func (n Node) Inspect(f func(n Node) bool)
- func (n Node) IsNonTerminal() bool
- func (n Node) IsTerminal() bool
- func (n Node) Kind() Kind
- func (n Node) LastToken() Node
- func (n Node) Len() int
- func (n Node) Next() Node
- func (n Node) Parent() Node
- func (n Node) Pos() int
- func (n Node) Text() string
- type Scanner
Constants ¶
const ( AddToken treeEventType = iota OpenNode CloseNode )
Variables ¶
var (
Nil = Node{}
)
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
A Builder is used to build a syntax tree. The zero value is ready to use.
func (*Builder) Pop ¶
func (b *Builder) Pop()
Pop finishes a non-terminal. Invalid pop calls will panic.
type Kind ¶
type Kind int32
Kind describes the kind of a syntax node.
const ( EOF Kind = iota Unknown Malformed Unterminated Identifier Comment Preproc Modifier Integer Float String Bitstring Unused ErrorLiteral FailLiteral FalseLiteral InconcLiteral NoneLiteral PassLiteral TrueLiteral AddressKeyword AllKeyword AltKeyword AltstepKeyword And4bKeyword AndKeyword AnyKeyword CaseKeyword CatchKeyword CharstringKeyword ClassKeyword ComponentKeyword ConfigurationKeyword ConnectKeyword ConstKeyword ControlKeyword CreateKeyword DisplayKeyword DoKeyword ElseKeyword EncodeKeyword EnumeratedKeyword ExceptKeyword ExceptionKeyword ExecuteKeyword ExtendsKeyword ExtensionKeyword ExternalKeyword FinallyKeyword ForKeyword FriendKeyword FromKeyword FunctionKeyword GotoKeyword GroupKeyword IfKeyword ImportKeyword InKeyword InoutKeyword InterleaveKeyword LabelKeyword LanguageKeyword LengthKeyword MapKeyword MessageKeyword ModKeyword ModifiesKeyword ModuleKeyword ModuleparKeyword MtcKeyword NoblockKeyword Not4bKeyword NotKeyword NullKeyword OfKeyword OmitKeyword OnKeyword OptionalKeyword Or4bKeyword OrKeyword OutKeyword OverrideKeyword ParamKeyword PortKeyword PresentKeyword PrivateKeyword ProcedureKeyword PublicKeyword RealtimeKeyword RecordKeyword RemKeyword ReturnKeyword RunsKeyword SelectKeyword SelfKeyword SetKeyword SignatureKeyword StreamKeyword SystemKeyword TemplateKeyword TestcaseKeyword ThisKeyword TimerKeyword ToKeyword TypeKeyword UnionKeyword UniversalKeyword UnmapKeyword ValueKeyword VarKeyword VariantKeyword WhileKeyword WithKeyword Xor4bKeyword XorKeyword Add Any Arrow Assign AtDefault AtLocal Colon ColonColon Comma Concat Div Dot DotDot DoubleArrow Equal Exclude Greater GreaterEqual LeftBrace LeftBracket LeftParen Less LessEqual Mul NotANumber NotEqual RightBrace RightBracket RightParen RotateLeft RotateRight Semicolon ShiftLeft ShiftRight Sub Root Module Decls Decl Group Friend Import ExceptSpec ExceptStmt ImportSpec ImportStmt ImportKind Signature Component Port PortKind PortSpec PortAttribute PortElement PortTranslation SubType Struct StructKind StructMember List ListKind Enum EnumLabel Map Class Constructor Control Destructor TestcaseType FunctionType AltstepType VarDecl TimerDecl PortDecl Template Testcase Function Configuration Altstep Stmt IfStmt SelectStmt ForStmt WhileStmt DoStmt GotoStmt LabelStmt ReturnStmt AltStmt AssignStmt GuardStmt Block BasicBlock Exprs Expr PrimaryExpr Literal UnaryExpr BinaryExpr Ref TypePars TypePar With WithStmt WithQualifier WithKind Refs Extends Language Return ValueConstraints ConfigSpec Exception Visibility Name FormalTypePars FormalTypePar FormalPars FormalPar Declarator ArrayDef TemplateRestriction NestedTemplate NestedType NestedStruct NestedList NestedEnum )
func (Kind) IsLiteral ¶
IsLiteral returns true if the kind is a literal token. Literal tokens are tokens which have a value, such as identifier, integer, ...
func (Kind) IsNonTerminal ¶
IsNonTerminal returns true if the kind is a non terminal. Non terminals are produced by the parser and usually have other non terminals or tokens as children.
func (Kind) IsTerminal ¶
IsTerminal returns true if the kind is a terminal. Terminals are also known as leave nodes, lexemes, tokens, ...
func (Kind) IsToken ¶
IsToken returns true if the kind is a token. This function is the same as IsTerminal.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a syntax node.
func (Node) End ¶
End returns the end position of the node in the source code. Or -1 if none was available.
func (Node) FirstChild ¶
FirstChild returns the first child of the node or nil if there is none.
func (Node) FirstToken ¶
FirstToken returns the first token of a syntax node which is not a trivia or Invalid if there is none.
Trivia tokens are tokens that are comments or preproccessor directives.
func (Node) Inspect ¶
Inspect traverses the syntax tree in depth-first order. It calls f for each node recursively followed by a call of f(Invalid).
func (Node) IsNonTerminal ¶
IsNonTerminal returns true if the node is a non-terminal node.
func (Node) IsTerminal ¶
IsTerminal returns true if the node is a terminal node.
func (Node) Kind ¶
Kind returns the syntax node kind of the node, such as Comment, Identifier, VarDecl, etc.
func (Node) LastToken ¶
LastToken returns the last token of a syntax node which is not a trivia or Invalid if none is available.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner scans a TTCN-3 source.
func NewScanner ¶
NewScanner returns a new TTCN-3 scanner for src.