first

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const EMPTY = "empty"

Variables

This section is empty.

Functions

This section is empty.

Types

type FirstSets

type FirstSets struct {
	// contains filtered or unexported fields
}

FirstSets represents a map of id->production.

func GetFirstSets

func GetFirstSets(g *ast.Grammar, symbols *symbols.Symbols) *FirstSets

GetFirstSets returns the FirstSets of the Grammar.

func (*FirstSets) AddSet

func (this *FirstSets) AddSet(prodName string, terminals SymbolSet) (symbolsAdded bool)

func (*FirstSets) AddToken

func (this *FirstSets) AddToken(prodName string, terminal string) (symbolAdded bool)

func (*FirstSets) GetSet

func (this *FirstSets) GetSet(prodName string) SymbolSet

GetSet will return the SymbolSet corresponding to `prodName` or nil.

func (*FirstSets) String

func (this *FirstSets) String() string

String will return the string representing the FirstSets.

type SymbolSet

type SymbolSet map[string]bool

key: symbol string

func First

func First(fs *FirstSets, sym string) SymbolSet

First returns the first `SymbolSet` given the ast.SyntaxSymbol.

func FirstS

func FirstS(firstSets *FirstSets, symbols []string) (first SymbolSet)

Returns First of the string, xyz, e.g.: for the item,

  X  : w • xyz

  Let x, y, z be strings from the union of T and NT.
  First(xy...z) =
	First(x) if First(x) does not contain ϵ
 	First(x) + First(y) if First(x) contains ϵ but First(y) does not contain ϵ
 	...
 	First(x) + First(y) + ... + First(z)

func (SymbolSet) AddSet

func (this SymbolSet) AddSet(that SymbolSet)

func (SymbolSet) Equal

func (this SymbolSet) Equal(that SymbolSet) bool

func (SymbolSet) String

func (this SymbolSet) String() string

Jump to

Keyboard shortcuts

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