spec

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	LexKindIDNil = LexKindID(0)
	LexKindIDMin = LexKindID(1)
)
View Source
const (
	LexModeKindIDNil = LexModeKindID(0)
	LexModeKindIDMin = LexModeKindID(1)
)
View Source
const (
	LexModeIDNil     = LexModeID(0)
	LexModeIDDefault = LexModeID(1)
)
View Source
const (
	LexModeNameNil     = LexModeName("")
	LexModeNameDefault = LexModeName("default")
)
View Source
const (
	// StateIDNil represents an empty entry of a transition table.
	// When the driver reads this value, it raises an error meaning lexical analysis failed.
	StateIDNil = StateID(0)

	// StateIDMin is the minimum value of the state ID. All valid state IDs are represented as
	// sequential numbers starting from this value.
	StateIDMin = StateID(1)
)
View Source
const LexKindNameNil = LexKindName("")

Variables

This section is empty.

Functions

func EscapePattern added in v0.2.0

func EscapePattern(s string) string

EscapePattern escapes the special characters. For example, EscapePattern(`+`) returns `\+`.

func FindSpellingInconsistencies added in v0.5.1

func FindSpellingInconsistencies(ids []string) [][]string

FindSpellingInconsistencies finds spelling inconsistencies in identifiers. The identifiers are considered to be the same if they are spelled the same when expressed in UpperCamelCase. For example, `left_paren` and `LeftParen` are spelled the same in UpperCamelCase. Thus they are considere to be spelling inconsistency.

func SnakeCaseToUpperCamelCase added in v0.5.1

func SnakeCaseToUpperCamelCase(snake string) string

Types

type CompiledLexModeSpec

type CompiledLexModeSpec struct {
	KindNames []LexKindName    `json:"kind_names"`
	Push      []LexModeID      `json:"push"`
	Pop       []int            `json:"pop"`
	DFA       *TransitionTable `json:"dfa"`
}

type CompiledLexSpec

type CompiledLexSpec struct {
	Name             string                 `json:"name"`
	InitialModeID    LexModeID              `json:"initial_mode_id"`
	ModeNames        []LexModeName          `json:"mode_names"`
	KindNames        []LexKindName          `json:"kind_names"`
	KindIDs          [][]LexKindID          `json:"kind_ids"`
	CompressionLevel int                    `json:"compression_level"`
	Specs            []*CompiledLexModeSpec `json:"specs"`
}

type LexEntry

type LexEntry struct {
	Kind     LexKindName   `json:"kind"`
	Pattern  LexPattern    `json:"pattern"`
	Modes    []LexModeName `json:"modes"`
	Push     LexModeName   `json:"push"`
	Pop      bool          `json:"pop"`
	Fragment bool          `json:"fragment"`
}

type LexKindID added in v0.3.0

type LexKindID int

LexKindID represents an ID of a lexical kind and is unique across all modes.

func (LexKindID) Int added in v0.3.0

func (id LexKindID) Int() int

type LexKindName added in v0.3.0

type LexKindName string

LexKindName represents a name of a lexical kind.

func (LexKindName) String added in v0.3.0

func (k LexKindName) String() string

type LexModeID added in v0.3.0

type LexModeID int

LexModeID represents an ID of a lex mode.

func (LexModeID) Int added in v0.3.0

func (n LexModeID) Int() int

func (LexModeID) IsNil added in v0.3.0

func (n LexModeID) IsNil() bool

func (LexModeID) String added in v0.3.0

func (n LexModeID) String() string

type LexModeKindID added in v0.3.0

type LexModeKindID int

LexModeKindID represents an ID of a lexical kind and is unique within a mode. Use LexKindID to identify a kind across all modes uniquely.

func (LexModeKindID) Int added in v0.3.0

func (id LexModeKindID) Int() int

type LexModeName

type LexModeName string

LexModeName represents a name of a lex mode.

func (LexModeName) String

func (m LexModeName) String() string

type LexPattern

type LexPattern string

LexPattern represents a pattern of a lexeme. The pattern is written in regular expression.

type LexSpec

type LexSpec struct {
	Name    string      `json:"name"`
	Entries []*LexEntry `json:"entries"`
}

func (*LexSpec) Validate

func (s *LexSpec) Validate() error

type RowDisplacementTable

type RowDisplacementTable struct {
	OriginalRowCount int       `json:"original_row_count"`
	OriginalColCount int       `json:"original_col_count"`
	EmptyValue       StateID   `json:"empty_value"`
	Entries          []StateID `json:"entries"`
	Bounds           []int     `json:"bounds"`
	RowDisplacement  []int     `json:"row_displacement"`
}

type StateID added in v0.3.0

type StateID int

StateID represents an ID of a state of a transition table.

func (StateID) Int added in v0.3.0

func (id StateID) Int() int

type TransitionTable

type TransitionTable struct {
	InitialStateID         StateID             `json:"initial_state_id"`
	AcceptingStates        []LexModeKindID     `json:"accepting_states"`
	RowCount               int                 `json:"row_count"`
	ColCount               int                 `json:"col_count"`
	Transition             *UniqueEntriesTable `json:"transition,omitempty"`
	UncompressedTransition []StateID           `json:"uncompressed_transition,omitempty"`
}

type UniqueEntriesTable

type UniqueEntriesTable struct {
	UniqueEntries             *RowDisplacementTable `json:"unique_entries,omitempty"`
	UncompressedUniqueEntries []StateID             `json:"uncompressed_unique_entries,omitempty"`
	RowNums                   []int                 `json:"row_nums"`
	OriginalRowCount          int                   `json:"original_row_count"`
	OriginalColCount          int                   `json:"original_col_count"`
	EmptyValue                int                   `json:"empty_value"`
}

Jump to

Keyboard shortcuts

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