Documentation ¶
Overview ¶
Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.
Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.
Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.
Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.
Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.
Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.
Index ¶
- Constants
- func Digraph(X []int, R []Relation, Fp map[int][]int, F *map[int][]int)
- func Traverse(x int, R []Relation, FP map[int][]int, F *map[int][]int, N map[int]int, ...)
- func Union(a []int, b []int) []int
- type Action
- type E_ActionType
- type LALR1
- func (lalr *LALR1) BuildTrans()
- func (lalr *LALR1) CaclIncludeRelation(tr int) []Relation
- func (lalr *LALR1) CaclIncludes() []Relation
- func (lalr *LALR1) CalcAllReadRelations() []Relation
- func (lalr *LALR1) CalcDR()
- func (lalr *LALR1) CalcFollowSet()
- func (lalr *LALR1) CalcLookAheadSet()
- func (lalr *LALR1) CalcLookbacks() []Relation
- func (lalr *LALR1) CalcReadSet()
- func (lalr *LALR1) CheckAndResolveConflict(state int, tranlist []Transistor) (map[int][]*Action, error)
- func (lalr *LALR1) DrawGrammar(tab [][]int) *gographviz.Graph
- func (lalr *LALR1) GenAcceptCode() int
- func (lalr *LALR1) GenErrorCode() int
- func (lalr *LALR1) GenTable() ([][]int, error)
- func (lalr *LALR1) ResolveConflict(act01, act02 *Action) (*Action, error)
- func (lalr *LALR1) ShowAndCheckConflict(state int, tranlist []Transistor)
- func (lalr *LALR1) ShowDrSet()
- func (lalr *LALR1) ShowFollowSet()
- func (lalr *LALR1) ShowIncludes(R Relation)
- func (lalr *LALR1) ShowLookAheadSet()
- func (lalr *LALR1) ShowLookbacks(R Relation)
- func (lalr *LALR1) ShowReadSet()
- func (lalr *LALR1) ShowReads(R Relation)
- func (lalr *LALR1) SplitActionAndGotoTable(tab [][]int) ([][]int, [][]int)
- func (lalr *LALR1) TryPackedTable(tab [][]int) error
- func (lalr *LALR1) TrySplitTable(tab [][]int) error
- func (lalr *LALR1) UseDefaultResolveConflict(act01, act02 *Action) *Action
- type Relation
- type Transistor
Constants ¶
const ( MaxInt = 1<<(UintSize-1) - 1 // 1<<31 - 1 or 1<<63 - 1 MinInt = -MaxInt - 1 // -1 << 31 or -1 << 63 MaxUint = 1<<UintSize - 1 // 1<<32 - 1 or 1<<64 - 1 Mask = ^(uint(1) << 32) CheckMask = (uint(1) << 32) )
const UintSize = 32 << (^uint(0) >> 32 & 1) // 32 or 64
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct { Sym *symbol.Symbol ActionType E_ActionType ActionIndex int PrecType symbol.E_Precedence Prec int }
type E_ActionType ¶
type E_ActionType int
const ( SHIFT E_ActionType = iota REDUCE ERROR SHIFT_REDUCE_CONFLICT REDUCE_REDUCE_CONFLICT )
type LALR1 ¶
type LALR1 struct { G *grammar.Grammar GTable [][]int DRSet, ReadSet, FollowSet, LookAheadSet map[int][]int NumOfStates int //States number // The last is for pack table NeedPacked bool ActionTable []int OffsetTable []int CheckTable []int ActionDef []int GoToDef []int // contains filtered or unexported fields }
func ComputeLALR ¶
func (*LALR1) BuildTrans ¶
func (lalr *LALR1) BuildTrans()
func (*LALR1) CaclIncludeRelation ¶
-----------------Caculate the Includes relation------------- B-> beta A gama if gama can episilon, p' --- beta --> p (p, A) includes (p', B)
calculate the include Relation.
func (*LALR1) CalcAllReadRelations ¶
func calc all reads relations
func (*LALR1) CalcLookbacks ¶
calculate lookback relation
func (*LALR1) CheckAndResolveConflict ¶
func (lalr *LALR1) CheckAndResolveConflict(state int, tranlist []Transistor) (map[int][]*Action, error)
check weath it has shift/reduce conflict or reduce/reduce conflict
func (*LALR1) DrawGrammar ¶
func (lalr *LALR1) DrawGrammar(tab [][]int) *gographviz.Graph
func (*LALR1) GenErrorCode ¶
Get the error action code Max State + 100 is the error
func (*LALR1) ResolveConflict ¶
Resolve the conflict by Prec
func (*LALR1) ShowAndCheckConflict ¶
func (lalr *LALR1) ShowAndCheckConflict(state int, tranlist []Transistor)
func (*LALR1) ShowFollowSet ¶
func (lalr *LALR1) ShowFollowSet()
func (*LALR1) ShowReadSet ¶
func (lalr *LALR1) ShowReadSet()
func (*LALR1) SplitActionAndGotoTable ¶
func (*LALR1) TryPackedTable ¶
the table is packed
func (*LALR1) TrySplitTable ¶
Try to split the table, and pack it
func (*LALR1) UseDefaultResolveConflict ¶
resolve with default method shift/reduce , resolve it with shift reduce/reduce , resolve it with rule which is first defined
type Transistor ¶
type Transistor struct { Index int // contains filtered or unexported fields }
q --t--> p