Debian Codegraph @

internal/lexer/gen/golang/acttab.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/lexer/gen/golang`/
16
17 import (
18 "bytesscip-go gomod github.com/golang/go/src go1.24 bytes/"
19 "pathscip-go gomod github.com/golang/go/src go1.24 path/"
20 "text/templatescip-go gomod github.com/golang/go/src go1.24 `text/template`/"
21
22 "github.com/goccmack/gocc/internal/ioscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/io`/"
23 "github.com/goccmack/gocc/internal/lexer/itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/"
24 "github.com/goccmack/gocc/internal/tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/"
25 )
26
27 func genActionTablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/genActionTable().(pkg, outDir string, itemsets *itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/.ItemSetsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/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#) {
28 fname := pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(outDir, "lexer", "acttab.go")
29 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().("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/lexer/gen/golang`/actionTableSrc.[1:])
30 if err != nil {
31 panic(err)
32 }
33 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#)
34 if err := tmpl.Executescip-go gomod github.com/golang/go/src go1.24 `text/template`/Template#Execute().(wr, getActTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/getActTab().(pkg, itemsets, tokMap)); err != nil {
35 panic(err)
36 }
37 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().(fname, wr.Bytesscip-go gomod github.com/golang/go/src go1.24 bytes/Buffer#Bytes().())
38 }
39
40 func getActTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/getActTab().(pkg string, itemsets *itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/.ItemSetsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/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#) *actTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab# {
41 actab := &actTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#{
42 TokenImportscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#TokenImport.: pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(pkg, "token"),
43 Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#Actions.: make([]actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action#, itemsets.Sizescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSets#Size().()),
44 }
45 for sno, set := range itemsets.Listscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSets#List().() {
46 if act := set.Actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/ItemSet#Action().(); act != nil {
47 switch act1 := act.(type) {
48 case itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/.Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/Accept#:
49 actab.Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#Actions.[sno].Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action#Accept. = tokMap.IdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/token`/TokenMap#IdMap.[string(act1)]
50 actab.Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#Actions.[sno].Ignorescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action#Ignore. = ""
51 case itemsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/.Ignorescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/items`/Ignore#:
52 actab.Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#Actions.[sno].Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action#Accept. = -1
53 actab.Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#Actions.[sno].Ignorescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action#Ignore. = string(act1)
54 }
55 }
56 }
57 return actab
58 }
59
60 type actTabscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab# struct {
61 TokenImportscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#TokenImport. string
62 Actionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actTab#Actions. []actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action#
63 }
64
65 type actionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action# struct {
66 Acceptscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action#Accept. int
67 Ignorescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/action#Ignore. string
68 }
69
70 const actionTableSrcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/lexer/gen/golang`/actionTableSrc. = `
71 // Code generated by gocc; DO NOT EDIT.
72
73 package lexer
74
75 import (
76 "fmt"
77
78 "{{.TokenImport}}"
79 )
80
81 type ActionTable [NumStates]ActionRow
82
83 type ActionRow struct {
84 Accept token.Type
85 Ignore string
86 }
87
88 func (a ActionRow) String() string {
89 return fmt.Sprintf("Accept=%d, Ignore=%s", a.Accept, a.Ignore)
90 }
91
92 var ActTab = ActionTable{
93 {{- range $s, $act := .Actions}}
94 ActionRow{ // S{{$s}}
95 Accept: {{$act.Accept}},
96 Ignore: "{{$act.Ignore}}",
97 },
98 {{- end}}
99 }
100 `