Debian Codegraph @

internal/ast/lexprodmap.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 astscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/
16
17 import (
18 "fmtscip-go gomod github.com/golang/go/src go1.24 fmt/"
19 )
20
21 type LexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap# struct {
22 //key: production id
23 idMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idMap. map[string]LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#
24
25 //value: lex production id
26 idxMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idxMap. map[LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#]string
27 }
28
29 type LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex# int
30
31 func NewLexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/NewLexProdMap().(prodList *LexProductionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProductions#) *LexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap# {
32 lpm := &LexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#{
33 idMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idMap.: make(map[string]LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#),
34 idxMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idxMap.: make(map[LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#]string),
35 }
36 lpm.Addscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#Add().(prodList.Productionsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProductions#Productions....)
37
38 return lpm
39 }
40
41 func newLexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/newLexProdMap().() *LexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap# {
42 return &LexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#{
43 idMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idMap.: make(map[string]LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#),
44 idxMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idxMap.: make(map[LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#]string),
45 }
46 }
47
48 func (this *LexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#) Indexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#Index().(id string) LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex# {
49 idx, exist := this.idMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idMap.[id]
50 if exist {
51 return idx
52 }
53 return -1
54 }
55
56 func (this *LexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#) Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#Id().(index LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#) string {
57 id, exist := this.idxMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idxMap.[index]
58 if exist {
59 return id
60 }
61 return ""
62 }
63
64 func (this *LexProdMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#) Addscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#Add().(prods ...LexProductionscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProduction#) {
65 for _, prod := range prods {
66 if _, exist := this.idMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idMap.[prod.Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProduction#Id.()]; exist {
67 panic(fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("Production %s already exists", prod.Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProduction#Id.()))
68 }
69 idx := len(this.idxMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idxMap.)
70 this.idMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idMap.[prod.Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProduction#Id.()] = LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#(idx)
71 this.idxMapscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdMap#idxMap.[LexProdIndexscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProdIndex#(idx)] = prod.Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexProduction#Id.()
72 }
73 }