nfa

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const InitNFASize = 3

Variables

This section is empty.

Functions

func DumpInfo

func DumpInfo(info InfoType) string

func IsInArray

func IsInArray(n int, arr []int) bool

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Types

type InfoType

type InfoType struct {
	Action       int
	MatchLength  int
	NextState    int
	HardMatch    bool
	ReplStr      string
	ReservedWord bool //
}

type NFA_PoolType

type NFA_PoolType struct {
	Pool      []NFA_Type
	Cur       int
	Top       int
	NextFree  int
	InitState int
	Sigma     string //
	ReSet     []*ReSetType
	IsDirty   bool
}

func NewNFA_Pool

func NewNFA_Pool() *NFA_PoolType

Create a new NFA pool

func (*NFA_PoolType) AddEdge

func (nn *NFA_PoolType) AddEdge(fr, to int, on string)

func (*NFA_PoolType) AddLambda

func (nn *NFA_PoolType) AddLambda(fr, to int)

func (*NFA_PoolType) AddLambdaSpecial

func (nn *NFA_PoolType) AddLambdaSpecial(fr, to int)

func (*NFA_PoolType) AddReInfo

func (nn *NFA_PoolType) AddReInfo(Re string, reFlags string, tRuleMatchId int, tRv int, info InfoType) int

func (*NFA_PoolType) ChangeRe

func (nn *NFA_PoolType) ChangeRe(oldRe string, newRe string)

func (*NFA_PoolType) ConvParsedReToNFA

func (nn *NFA_PoolType) ConvParsedReToNFA(depth int, lr *re.LexReType, CurIn int, Children []re.ReTreeNodeType) (int, int)

func (*NFA_PoolType) DeleteRe

func (nn *NFA_PoolType) DeleteRe(oldRe string)

func (*NFA_PoolType) DiscardPool

func (nn *NFA_PoolType) DiscardPool()

func (*NFA_PoolType) DumpPool

func (nn *NFA_PoolType) DumpPool(all bool)

func (*NFA_PoolType) DumpPoolJSON

func (nn *NFA_PoolType) DumpPoolJSON(fo io.Writer, td string, tn int)

func (*NFA_PoolType) EdgeExists

func (nn *NFA_PoolType) EdgeExists(fr, to int, on string, lambda bool) bool

func (*NFA_PoolType) FinializeNFA

func (nn *NFA_PoolType) FinializeNFA()

func (*NFA_PoolType) FreeNFA

func (nn *NFA_PoolType) FreeNFA(ii int)

Free an NFA tree node

func (*NFA_PoolType) GenerateGVFile

func (nn *NFA_PoolType) GenerateGVFile(fo io.Writer, td string, tn int)

func (*NFA_PoolType) GenerateSigma

func (nn *NFA_PoolType) GenerateSigma() (s string)

Set of possible input tokens Walk the NFA and collect all unique tokens that are not lambda and have a transition

func (*NFA_PoolType) GetNFA

func (nn *NFA_PoolType) GetNFA() int

Allocate an NFA tree node

func (*NFA_PoolType) HasTauEdge

func (nn *NFA_PoolType) HasTauEdge(StateSet []int) (Is0Ch bool)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func (*NFA_PoolType) IsNonTerminalPushPopState

func (nn *NFA_PoolType) IsNonTerminalPushPopState(StateSet []int) (rv int, is bool, info InfoType, Is0Ch bool)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func (*NFA_PoolType) IsTerminalState

func (nn *NFA_PoolType) IsTerminalState(StateSet []int) (rv int, is bool, info InfoType, Is0Ch bool)

func (*NFA_PoolType) LambdaClosure

func (nn *NFA_PoolType) LambdaClosure(startState []int) (setLambda []int)

Given an initial set of startState, calculate the set of states that can be reached via a lambda (empty string).

func (*NFA_PoolType) LambdaClosureSet

func (nn *NFA_PoolType) LambdaClosureSet(startState []int, S string) (setLambda []int)

t1 := nn.LambdaClosureSet ( dfa_set, string(S) )

func (*NFA_PoolType) Mark

func (nn *NFA_PoolType) Mark(cur int, t re.LR_TokType)

func (*NFA_PoolType) NoneVisited

func (nn *NFA_PoolType) NoneVisited()

func (*NFA_PoolType) Pos0Start

func (nn *NFA_PoolType) Pos0Start() int

Return the start state number

func (*NFA_PoolType) SetReservedWord

func (nn *NFA_PoolType) SetReservedWord(Cur int)

func (*NFA_PoolType) UnDeleteRe

func (nn *NFA_PoolType) UnDeleteRe(oldRe string)

func (*NFA_PoolType) UniqSigma

func (nn *NFA_PoolType) UniqSigma() (rv string)

type NFA_Type

type NFA_Type struct {
	Next2      []TransitionType //
	Rv         int              // 0 indicates not assigned, non-terminal
	Info       InfoType         //
	TRuleMatch int              // Order that stuff was creaed in
	NextFree   int              //		For free list
	IsUsed     bool             //		For Free list
	A_IAm      int              //		Debug Usage
	LineNo     string           // LineNo where added
	Visited    bool             // Visited Marker
	TokType    re.LR_TokType    // Type of token, marked for LR_STAR, LR_PLUS, LR_QUEST, LR_OP_BR etc.
}

type NNPairType

type NNPairType struct {
	StateSetIdx   int
	TRuleMatchVal int
	MatchLength   int
}

type ReSetType

type ReSetType struct {
	Re         string        //		String this RE is from
	Rv         int           //		Terminal value to return if it matches
	TRuleMatch int           // Order that stuff was created in
	IsDirty    bool          //		Indicates "Re" has been chagned without rebuilding ParsedRe
	HasDot     bool          //		Indicates that completed ParsedRe has a DOT in it
	HasNCCL    bool          //		Indicates that completed ParsedRe has a NCCL in it
	Deleted    bool          //		Inidiates that this item has been deleted
	ParsedRe   *re.LexReType //		Parsed Tree
	Info       InfoType      //
}

type TransitionType

type TransitionType struct {
	On         string
	IsLambda   bool
	Is0ChMatch bool // false(default) => not set,       true(set) => match occures on any char that is not an accepted char (a*)-> next state on 'b'
	From       int
	To         int
	LineNo     string // LineNo where added
}

Jump to

Keyboard shortcuts

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