Documentation
¶
Overview ¶
Package ttcn3 provides routines for evaluating TTCN-3 source code.
This package is in alpha stage, as we are still figuring out requirements and interfaces.
Index ¶
- type DB
- type Definition
- type NodeEvent
- type Scope
- type Source
- type Tree
- func (t *Tree) Components() []*Definition
- func (t *Tree) Controls() []*Definition
- func (tree *Tree) ExprAt(pos loc.Pos) ast.Expr
- func (t *Tree) Filename() string
- func (t *Tree) Funcs() []*Definition
- func (t *Tree) Imports() []*Definition
- func (tree *Tree) Lookup(n ast.Expr) []*Definition
- func (tree *Tree) LookupWithDB(n ast.Expr, db *DB) []*Definition
- func (t *Tree) ModuleOf(n ast.Node) *ast.Module
- func (t *Tree) ModulePars() []*Definition
- func (t *Tree) Modules() []*Definition
- func (t *Tree) ParentOf(n ast.Node) ast.Node
- func (t *Tree) Ports() []*Definition
- func (tree *Tree) Pos(line int, column int) loc.Pos
- func (tree *Tree) Position(pos loc.Pos) loc.Position
- func (t *Tree) QualifiedName(n ast.Node) string
- func (tree *Tree) SliceAt(pos loc.Pos) []ast.Node
- func (tree *Tree) Tags() []ast.Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶ added in v0.13.0
type DB struct {
// Names is a map from symbol name to a list of files that define the symbol.
Names map[string]map[string]bool
// Uses maps from symbol name to a list of files that use the symbol.
Uses map[string]map[string]bool
// Modules maps from module name to file path.
Modules map[string]map[string]bool
// contains filtered or unexported fields
}
DB implements database for querying TTCN-3 source code bases.
func (*DB) Index ¶ added in v0.13.0
Index parses TTCN-3 source files and adds names and dependencies to the database.
func (*DB) VisibleModules ¶ added in v0.14.0
func (db *DB) VisibleModules(id string, mod *ast.Module) []*Definition
VisibleModules returns a list of modules that may contain the given symbol. First parameter id specifies the symbol to look for and second parameter module specifies where the imports come from.
type Definition ¶ added in v0.13.0
func Definitions ¶ added in v0.14.0
func Definitions(id string, n ast.Node, t *Tree) []*Definition
func Inspect ¶ added in v0.16.2
func Inspect(files []string, fn func(*Tree) []*Definition) ([]*Definition, error)
Inspect the AST and return a list of all the definitions found by fn.
type NodeEvent ¶ added in v0.16.2
type NodeEvent struct {
// Kind is the type of an node event (AddToken, OpenFooBar, CloseFooBar).
Kind string `json:"kind"`
// Text is the text of a AddToken event.
Text string `json:"text,omitempty"`
// Offset is the position of the first character belonging to the node.
Offs int `json:"offs"`
// End is the position of the first character immediately after the node.
Len int `json:"len"`
// Other is the index of the matching node event.
Other int `json:"other,omitempty"`
}
type Scope ¶ added in v0.13.0
type Scope struct {
ast.Node
Tree *Tree
Names map[string]*Definition
}
func NewScope ¶ added in v0.13.0
NewScope builts and populares a new scope from the given syntax node. NewScope returns nil if no valid scope could be built.
func (*Scope) Lookup ¶ added in v0.14.0
func (scp *Scope) Lookup(name string) []*Definition
Lookup returns a list of defintions for the given identifier. Lookup may be called with nil as receiver.
type Tree ¶
type Tree struct {
FileSet *loc.FileSet
Root ast.Node
Names map[string]bool
Uses map[string]bool
Err error
// contains filtered or unexported fields
}
Tree represents the TTCN-3 syntax tree, usually of a file.
func (*Tree) Components ¶ added in v0.12.0
func (t *Tree) Components() []*Definition
func (*Tree) Controls ¶ added in v0.12.0
func (t *Tree) Controls() []*Definition
func (*Tree) Funcs ¶ added in v0.12.0
func (t *Tree) Funcs() []*Definition
func (*Tree) Imports ¶ added in v0.12.0
func (t *Tree) Imports() []*Definition
func (*Tree) Lookup ¶ added in v0.14.0
func (tree *Tree) Lookup(n ast.Expr) []*Definition
Lookup returns the definitions of the given expression. For handling imports and multiple modules, use LookupWithDB.
func (*Tree) LookupWithDB ¶ added in v0.14.0
func (tree *Tree) LookupWithDB(n ast.Expr, db *DB) []*Definition
LookupWithDB returns the definitions of the given expression, but uses the database for import resoltion.
func (*Tree) ModuleOf ¶ added in v0.14.0
ModuleOf returns the module of the given node, by walking up the tree.
func (*Tree) ModulePars ¶ added in v0.12.0
func (t *Tree) ModulePars() []*Definition
func (*Tree) Modules ¶ added in v0.9.6
func (t *Tree) Modules() []*Definition
func (*Tree) Ports ¶ added in v0.12.0
func (t *Tree) Ports() []*Definition
func (*Tree) Pos ¶ added in v0.13.0
Pos encodes a line and column tuple into a offset-based Pos tag. If file nas not been parsed yet, Pos will return loc.NoPos.
func (*Tree) QualifiedName ¶ added in v0.16.2
Returns the qualified name of the given node.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ast provides TTCN-3 syntax tree nodes and functions for tree traversal.
|
Package ast provides TTCN-3 syntax tree nodes and functions for tree traversal. |
|
Package parser implements a tolerant TTCN-3 parser library.
|
Package parser implements a tolerant TTCN-3 parser library. |
|
Package scanner provides a TTCN-3 scanner
|
Package scanner provides a TTCN-3 scanner |
|
Package syntax provides a fast high fidelity parser for TTCN-3.
|
Package syntax provides a fast high fidelity parser for TTCN-3. |
|
internal/gen
command
This program reads the TTCN-3 grammar file and generates a parser for it.
|
This program reads the TTCN-3 grammar file and generates a parser for it. |
|
Package token defines constants representing the lexical tokens of the TTCN-3 programming language and basic operations on tokens (printing, predicates).
|
Package token defines constants representing the lexical tokens of the TTCN-3 programming language and basic operations on tokens (printing, predicates). |