Debian Codegraph @

internal/parser/gen/golang/actiontable.go

raw symbols SCIP
1 //Copyright 2013 Vastech SA (PTY) LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package golangscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/
16
17 import (
18 "bytesscip-go gomod github.com/golang/go/src go1.24 bytes/"
19 "fmtscip-go gomod github.com/golang/go/src go1.24 fmt/"
20 "mathscip-go gomod github.com/golang/go/src go1.24 math/"
21 "pathscip-go gomod github.com/golang/go/src go1.24 path/"
22 "text/templatescip-go gomod github.com/golang/go/src go1.24 `text/template`/"
23
24 "github.com/goccmack/gocc/internal/astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/"
25 "github.com/goccmack/gocc/internal/ioscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/"
26 "github.com/goccmack/gocc/internal/parser/lr1/actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/"
27 "github.com/goccmack/gocc/internal/parser/lr1/itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/"
28 "github.com/goccmack/gocc/internal/tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/"
29 )
30
31 func GenActionTablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/GenActionTable().(outDir string, prods astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/.SyntaxProdListscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/SyntaxProdList#, itemSets *itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.ItemSetsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSets#, tokMap *tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/.TokenMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#, zip bool) map[int]itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts# {
32 if zip {
33 return GenCompActionTablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/GenCompActionTable().(outDir, prods, itemSets, tokMap)
34 }
35 tmpl, err := templatescip-go gomod github.com/golang/go/src go1.24 `text/template`/.Newscip-go gomod github.com/golang/go/src go1.24 `text/template`/New().("parser action table").Parsescip-go gomod github.com/golang/go/src go1.24 `text/template`/Template#Parse().(actionTableSrcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableSrc.[1:])
36 if err != nil {
37 panic(err)
38 }
39 wr := new(bytesscip-go gomod github.com/golang/go/src go1.24 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24 bytes/Buffer#)
40 data, conflicts := getActionTableDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/getActionTableData().(prods, itemSets, tokMap)
41 if err := tmpl.Executescip-go gomod github.com/golang/go/src go1.24 `text/template`/Template#Execute().(wr, data); err != nil {
42 panic(err)
43 }
44 ioscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/.WriteFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/WriteFile().(pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(outDir, "parser", "actiontable.go"), wr.Bytesscip-go gomod github.com/golang/go/src go1.24 bytes/Buffer#Bytes().())
45 return conflicts
46 }
47
48 type actionTableDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableData# struct {
49 Rowsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableData#Rows. []*actRowscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#
50 }
51
52 func getActionTableDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/getActionTableData().(prods astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/.SyntaxProdListscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/SyntaxProdList#, itemSets *itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.ItemSetsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSets#,
53 tokMap *tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/.TokenMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#) (actTab *actionTableDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableData#, conflicts map[int]itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts#) {
54 actTab = &actionTableDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableData#{
55 Rowsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableData#Rows.: make([]*actRowscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#, itemSets.Sizescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSets#Size().()),
56 }
57 conflicts = make(map[int]itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts#)
58 var cnflcts itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts#
59 var row *actRowscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#
60 for i := range actTab.Rowsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableData#Rows. {
61 if row, cnflcts = getActionRowDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/getActionRowData().(prods, itemSets.Setscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSets#Set().(i), tokMap); len(cnflcts) > 0 {
62 conflicts[i] = cnflcts
63 }
64 actTab.Rowsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableData#Rows.[i] = row
65 }
66 return
67 }
68
69 type actRowscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow# struct {
70 CanRecoverscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#CanRecover. bool
71 Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#Actions. []string
72 }
73
74 func getActionRowDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/getActionRowData().(prods astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/.SyntaxProdListscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/SyntaxProdList#, set *itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.ItemSetscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSet#, tokMap *tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/.TokenMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#) (data *actRowscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#, conflicts itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts#) {
75 data = &actRowscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#{
76 CanRecoverscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#CanRecover.: set.CanRecoverscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSet#CanRecover().(),
77 Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#Actions.: make([]string, len(tokMap.TypeMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#TypeMap.)),
78 }
79 conflicts = make(itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts#)
80 var max int
81 // calculate padding.
82 for _, sym := range tokMap.TypeMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#TypeMap. {
83 act, _ := set.Actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSet#Action().(sym)
84 switch act1 := act.(type) {
85 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Accept#:
86 n := len("accept(true),")
87 if n > max {
88 max = n
89 }
90 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Errorscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Error#:
91 n := len("nil,")
92 if n > max {
93 max = n
94 }
95 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Reducescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Reduce#:
96 n := len("reduce(") + nbytesscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/nbytes().(int(act1)) + len("),")
97 if n > max {
98 max = n
99 }
100 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Shiftscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Shift#:
101 n := len("shift(") + nbytesscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/nbytes().(int(act1)) + len("),")
102 if n > max {
103 max = n
104 }
105 default:
106 panic(fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("Unknown action type: %T", act1))
107 }
108 }
109 for i, sym := range tokMap.TypeMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#TypeMap. {
110 act, symConflicts := set.Actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSet#Action().(sym)
111 if len(symConflicts) > 0 {
112 conflicts[sym] = symConflicts
113 }
114 switch act1 := act.(type) {
115 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Accept#:
116 pad := max + 1 - len("accept(true),")
117 data.Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#Actions.[i] = fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("accept(true),%*c// %s", pad, ' ', sym)
118 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Errorscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Error#:
119 pad := max + 1 - len("nil,")
120 data.Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#Actions.[i] = fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("nil,%*c// %s", pad, ' ', sym)
121 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Reducescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Reduce#:
122 pad := max + 1 - (len("reduce(") + nbytesscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/nbytes().(int(act1)) + len("),"))
123 data.Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#Actions.[i] = fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("reduce(%d),%*c// %s, reduce: %s", int(act1), pad, ' ', sym, prods[int(act1)].Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/SyntaxProd#Id.)
124 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Shiftscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Shift#:
125 pad := max + 1 - (len("shift(") + nbytesscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/nbytes().(int(act1)) + len("),"))
126 data.Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actRow#Actions.[i] = fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("shift(%d),%*c// %s", int(act1), pad, ' ', sym)
127 default:
128 panic(fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("Unknown action type: %T", act1))
129 }
130 }
131 return
132 }
133
134 const actionTableSrcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionTableSrc. = `
135 // Code generated by gocc; DO NOT EDIT.
136
137 package parser
138
139 type (
140 actionTable [numStates]actionRow
141 actionRow struct {
142 canRecover bool
143 actions [numSymbols]action
144 }
145 )
146
147 var actionTab = actionTable{
148 {{- range $i, $r := .Rows }}
149 actionRow{ // S{{$i}}
150 canRecover: {{printf "%t" .CanRecover}},
151 actions: [numSymbols]action{
152 {{- range $a := .Actions }}
153 {{$a}}
154 {{- end }}
155 },
156 },
157 {{- end }}
158 }
159 `
160
161 func GenCompActionTablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/GenCompActionTable().(outDir string, prods astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/.SyntaxProdListscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/SyntaxProdList#, itemSets *itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.ItemSetsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSets#, tokMap *tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/.TokenMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#) map[int]itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts# {
162 tab := make([]struct {
163 CanRecover bool
164 Actions []struct {
165 Index int
166 Action int
167 Amount int
168 }
169 }, itemSets.Sizescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSets#Size().())
170 conflictss := make(map[int]itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts#)
171 for i := range tab {
172 set := itemSets.Setscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSets#Set().(i)
173 tab[i].CanRecover = set.CanRecoverscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSet#CanRecover().()
174 conflicts := make(itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/.RowConflictsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/RowConflicts#)
175 for j, sym := range tokMap.TypeMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#TypeMap. {
176 act, symConflicts := set.Actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/items`/ItemSet#Action().(sym)
177 if len(symConflicts) > 0 {
178 conflicts[sym] = symConflicts
179 }
180 switch act1 := act.(type) {
181 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Accept#:
182 tab[i].Actions = append(tab[i].Actions, struct {
183 Index int
184 Action int
185 Amount int
186 }{Index: j, Action: 0, Amount: 0})
187 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Errorscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Error#:
188 // skip
189 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Reducescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Reduce#:
190 tab[i].Actions = append(tab[i].Actions, struct {
191 Index int
192 Action int
193 Amount int
194 }{Index: j, Action: 1, Amount: int(act1)})
195 case actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/.Shiftscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/lr1/action`/Shift#:
196 tab[i].Actions = append(tab[i].Actions, struct {
197 Index int
198 Action int
199 Amount int
200 }{Index: j, Action: 2, Amount: int(act1)})
201 default:
202 panic(fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("Unknown action type: %T", act1))
203 }
204 }
205 if len(conflicts) > 0 {
206 conflictss[i] = conflicts
207 }
208 }
209 bytesStr := genEncscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/genEnc().(tab)
210 tmpl, err := templatescip-go gomod github.com/golang/go/src go1.24 `text/template`/.Newscip-go gomod github.com/golang/go/src go1.24 `text/template`/New().("parser action table").Parsescip-go gomod github.com/golang/go/src go1.24 `text/template`/Template#Parse().(actionCompTableSrcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionCompTableSrc.[1:])
211 if err != nil {
212 panic(err)
213 }
214 wr := new(bytesscip-go gomod github.com/golang/go/src go1.24 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24 bytes/Buffer#)
215 if err := tmpl.Executescip-go gomod github.com/golang/go/src go1.24 `text/template`/Template#Execute().(wr, bytesStr); err != nil {
216 panic(err)
217 }
218 ioscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/.WriteFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/WriteFile().(pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(outDir, "parser", "actiontable.go"), wr.Bytesscip-go gomod github.com/golang/go/src go1.24 bytes/Buffer#Bytes().())
219 return conflictss
220 }
221
222 const actionCompTableSrcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/actionCompTableSrc. = `
223 // Code generated by gocc; DO NOT EDIT.
224
225 package parser
226
227 import (
228 "bytes"
229 "compress/gzip"
230 "encoding/gob"
231 )
232
233 type (
234 actionTable [numStates]actionRow
235 actionRow struct {
236 canRecover bool
237 actions [numSymbols]action
238 }
239 )
240
241 var actionTab = actionTable{}
242
243 func init() {
244 tab := []struct {
245 CanRecover bool
246 Actions []struct {
247 Index int
248 Action int
249 Amount int
250 }
251 }{}
252 data := {{.}}
253 buf, err := gzip.NewReader(bytes.NewBuffer(data))
254 if err != nil {
255 panic(err)
256 }
257 dec := gob.NewDecoder(buf)
258 if err := dec.Decode(&tab); err != nil {
259 panic(err)
260 }
261
262 for i, row := range tab {
263 actionTab[i].canRecover = row.CanRecover
264 for _, a := range row.Actions {
265 switch a.Action {
266 case 0:
267 actionTab[i].actions[a.Index] = accept(true)
268 case 1:
269 actionTab[i].actions[a.Index] = reduce(a.Amount)
270 case 2:
271 actionTab[i].actions[a.Index] = shift(a.Amount)
272 }
273 }
274 }
275 }
276 `
277
278 // nbytes returns the number of bytes required to output the integer x.
279 func nbytesscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/parser/gen/golang`/nbytes().(x int) int {
280 if x == 0 {
281 return 1
282 }
283 n := 0
284 if x < 0 {
285 x = -x
286 n++
287 }
288 n += int(mathscip-go gomod github.com/golang/go/src go1.24 math/.Log10scip-go gomod github.com/golang/go/src go1.24 math/Log10().(float64(x))) + 1
289 return n
290 }