token

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package token defines constants representing the lexical tokens of the TTCN-3 programming language and basic operations on tokens (printing, predicates).

Index

Constants

View Source
const (
	LowestPrec  = 0 // non-operators
	UnaryPrec   = 6
	HighestPrec = 15
)

A set of constants for precedence-based expression parsing. Non-operators have lowest precedence, followed by operators starting with precedence 1 up to unary operators. The highest precedence serves as "catch-all" precedence for selector, indexing, and other operator and delimiter tokens.

Variables

This section is empty.

Functions

func Unquote

func Unquote(s string) (string, error)

Unquote interprets s as a quoted TTCN-3 string literal, returning the string value that s quotes.

Types

type Kind

type Kind int

Kind is the set of lexical tokens of the Go programming language.

const (
	// Special tokens
	ILLEGAL Kind = iota
	EOF
	COMMENT
	PREPROC

	// Identifiers and basic type literals
	// (these tokens stand for classes of literals)
	IDENT   // main
	INT     // 12345
	FLOAT   // 123.45
	STRING  // "abc"
	BSTRING // '101?F'H
	MODIF   // @fuzzy

	// Operators and delimiters
	ADD // +
	SUB // -
	MUL // *
	DIV // /

	SHL    // <<
	ROL    // <@
	SHR    // >>
	ROR    // @>
	CONCAT // &

	REDIR      // ->
	DECODE     // =>
	ANY        // ?
	EXCL       // !
	RANGE      // ..
	ASSIGN     // :=
	COLONCOLON // ::

	EQ // ==
	NE // !=
	LT // <
	LE // <=
	GT // >
	GE // >=

	LPAREN // (
	LBRACK // [
	LBRACE // {
	COMMA  // ,
	DOT    // .

	RPAREN    // )
	RBRACK    // ]
	RBRACE    // }
	SEMICOLON // ;
	COLON     // :

	// Keywords
	MOD // mod
	REM // rem

	AND // and
	OR  // or
	XOR // xor
	NOT // not

	AND4B // and4b
	OR4B  // or4b
	XOR4B // xor4b
	NOT4B // not4b

	ADDRESS
	ALIVE
	ALL
	ALT
	ALTSTEP
	ANYKW
	BREAK
	CASE
	CHARSTRING
	COMPONENT
	CONST
	CONTINUE
	CONTROL
	DECMATCH
	DISPLAY
	DO
	ELSE
	ENCODE
	ENUMERATED
	ERROR
	EXCEPT
	EXCEPTION
	EXTENDS
	EXTENSION
	EXTERNAL
	FAIL
	FALSE
	FOR
	FRIEND
	FROM
	FUNCTION
	GOTO
	GROUP
	IF
	IFPRESENT
	IMPORT
	IN
	INCONC
	INOUT
	INTERLEAVE
	LABEL
	LANGUAGE
	LENGTH
	MAP
	MESSAGE
	MIXED
	MODIFIES
	MODULE
	MODULEPAR
	MTC
	NAN
	NOBLOCK
	NONE
	NULL
	OF
	OMIT
	ON
	OPTIONAL
	OUT
	OVERRIDE
	PARAM
	PASS
	PATTERN
	PORT
	PRESENT
	PRIVATE
	PROCEDURE
	PUBLIC
	REALTIME
	RECORD
	REGEXP
	REPEAT
	RETURN
	RUNS
	SELECT
	SENDER
	SET
	SIGNATURE
	STEPSIZE
	SYSTEM
	TEMPLATE
	TESTCASE
	TIMER
	TIMESTAMP
	TO
	TRUE
	TYPE
	UNION
	UNIVERSAL
	UNMAP
	VALUE
	VAR
	VARIANT
	WHILE
	WITH
)

The list of tokens.

func Lookup

func Lookup(ident string) Kind

Lookup maps an identifier to its keyword token or IDENT (if not a keyword).

func (Kind) IsKeyword

func (tok Kind) IsKeyword() bool

IsKeyword returns true for tokens corresponding to keywords; it returns false otherwise.

func (Kind) IsLiteral

func (tok Kind) IsLiteral() bool

IsLiteral returns true for tokens corresponding to identifiers and basic type literals; it returns false otherwise.

func (Kind) IsOperator

func (tok Kind) IsOperator() bool

IsOperator returns true for tokens corresponding to operators and delimiters; it returns false otherwise.

func (Kind) Precedence

func (tok Kind) Precedence() int

Precedence returns the operator precedence of the binary operator op. If op is not a binary operator, the result is LowestPrecedence.

func (Kind) String

func (tok Kind) String() string

String returns the string corresponding to the token tok. For operators, delimiters, and keywords the string is the actual token character sequence (e.g., for the token ADD, the string is "+"). For all other tokens the string corresponds to the token constant name (e.g. for the token IDENT, the string is "IDENT").

Jump to

Keyboard shortcuts

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