symbols

package
v0.0.0-...-d977049 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package symbols is a static reposistory of the symbols of generated parser. It is used by all code generation modules

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNonTerminalSymbols

func GetNonTerminalSymbols() []string

GetNonTerminalSymbols returns the list of non-terminals used by code generation modules

func GetSymbols

func GetSymbols() []string

GetSymbols returns the code strings of all the NT and T symbols

func GetTerminalSymbols

func GetTerminalSymbols() []string

GetTerminalSymbols returns the list of symbol strings used by code generation modules of the terminals

func GetTerminalTypeStrings

func GetTerminalTypeStrings() []string

GetTerminalTypeStrings returns the type strings of the terminals in order of their types.

func Init

func Init(g *ast.GoGLL)

Init initialises the symbols

func IsNonTerminal

func IsNonTerminal(sym string) bool

Types

type L

type L struct {
	// The subexpression to look ahead at
	Expr Symbol
	// true for positive (&) lookahead, false for negative (!) lookahead
	Positive bool
}

L is the type of a lookahead symbol

func (L) GoString

func (e L) GoString() string

GoString returns the Go representation of e used by code generation modules

func (L) IsLookahead

func (L) IsLookahead() bool

IsLookahead always returns true if the symbol is a lookahead expression

func (L) IsNonTerminal

func (L) IsNonTerminal() bool

IsNonTerminal always returns false if the symbol is a lookahead expression

func (L) Literal

func (e L) Literal() string

Literal returns the literal of the contained symbol, prefixed by its operator

func (L) String

func (e L) String() string

String returns the string representation of e used by code generation modules

type NT

type NT int

NT is the type of a non-terminal symbol

func GetNTType

func GetNTType(nt string) NT

GetNTType returns the NT values of nt

func GetNonTerminals

func GetNonTerminals() []NT

GetNonTerminals returns the list of non-terminals used by code generation modules

func (NT) GoString

func (nt NT) GoString() string

GoString returns the Go representation of nt used by code generation modules

func (NT) IsLookahead

func (NT) IsLookahead() bool

IsLookahead always returns false if the symbol is a non-terminal

func (NT) IsNonTerminal

func (NT) IsNonTerminal() bool

IsNonTerminal always returns true if the symbol is a non-terminal

func (NT) Literal

func (nt NT) Literal() string

Literal returns the literal value of nt in the grammar

func (NT) String

func (nt NT) String() string

String returns the string representation of nt used by code generation modules

type Symbol

type Symbol interface {

	// IsNonTerminal returns true iff this symbol is a non-terminal
	IsNonTerminal() bool

	// IsLookahead return true iff this symbol is a lookahead expression
	IsLookahead() bool

	// Literal returns the literal value of the symbol in the grammar
	Literal() string

	// GoString returns the Go representation of the symbol that is used
	// for code generation
	GoString() string

	// String returns the string representation of the symbol that is used
	// for code generation
	String() string
	// contains filtered or unexported methods
}

Symbol is T or NT or L

func FromASTString

func FromASTString(astSym string) Symbol

FromASTString translates an AST symbol string to Symbol

type Symbols

type Symbols []Symbol

Symbols is a list of Symbol

func (Symbols) Empty

func (ss Symbols) Empty() bool

Empty returns true iff ss is empty

func (Symbols) GoStrings

func (ss Symbols) GoStrings() []string

GoStrings returns a slice containing the Go representation of the the symbols in ss used by code generation modules

func (Symbols) Strings

func (ss Symbols) Strings() []string

Strings returns a slice containing the string representation of the the symbols in ss used for printing

type T

type T int

T is the type of a terminal symbol

const (
	Error T = iota
	EoF
	StartOfTokens // First user defined token
)

func GetTerminals

func GetTerminals() []T

GetTerminals returns the list of terminals used by code generation modules

func TerminalLiteralToType

func TerminalLiteralToType(s string) T

TerminalLiteralToType returns the T corresponding to the terminal litral s

func (T) GoString

func (t T) GoString() string

GoString returns the Go representation of t used by code generation modules

func (T) ID

func (t T) ID() string

func (T) IsLookahead

func (T) IsLookahead() bool

IsLookahead always returns false if the symbol is a terminal

func (T) IsNonTerminal

func (T) IsNonTerminal() bool

IsNonTerminal always returns false if the symbol is a terminal

func (T) Literal

func (t T) Literal() string

Literal returns the literal value of t in the grammar

func (T) String

func (t T) String() string

String returns the string representation of t used by code generation modules

func (T) Suppress

func (t T) Suppress() bool

Suppress returns true iff t is suppressed by the lexer

func (T) TypeString

func (t T) TypeString() string

TypeString returns the Go representation of t used by code generation modules

Jump to

Keyboard shortcuts

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