parser

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package parser implements a tolerant TTCN-3 parser library.

It implements most of TTCN-3 core language specification 4.10 (2018), Advanced Parametrisation, Behaviour Types, Performance and Realtime Testing, simplistic preprocessor support, multi-line string literals for Titan TestPorts, and optional semicolon for backward compatibility.

Index

Constants

View Source
const (
	PedanticSemicolon = 1 << iota // expect semicolons pedantically
	IgnoreComments                // ignore comments
	Trace                         // print a trace of parsed productions
	AllErrors                     // report all errors (not just the first 10 on different lines)
)

Variables

This section is empty.

Functions

func ParseExpr

func ParseExpr(fset *loc.FileSet, filename string, src interface{}) (ast.Expr, error)

func ParseModules

func ParseModules(fset *loc.FileSet, filename string, src interface{}, mode Mode) (root []*ast.Module, err error)

ParseModules parses the source code of a single source file and returns the corresponding nodes. The source code may be provided via the filename of the source file, or via the src parameter.

If src != nil, ParseModules parses the source from src and the filename is only used when recording position information. The type of the argument for the src parameter must be string, []byte, or io.Reader. If src == nil, ParseModules parses the file specified by filename.

The mode parameter controls the amount of source text parsed and other optional parser functionality. Position information is recorded in the file set fset, which must not be nil.

If the source couldn't be read, the returned AST is nil and the error indicates the specific failure. If the source was read but syntax errors were found, the result is a partial AST (with Bad* nodes representing the fragments of erroneous source code). Multiple errors are returned via a ErrorList which is sorted by file position.

Types

type Mode

type Mode uint

A Mode value is a set of flags (or 0). They control the amount of source code parsed and other optional parser functionality.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL