| 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 | "stringsscip-go gomod github.com/golang/go/src go1.24 strings/" |
| 20 | ) |
| 21 | |
| 22 | type LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports# struct { |
| 23 | Importsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#Imports. map[string]*LexImportscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport# |
| 24 | } |
| 25 | |
| 26 | func NewLexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/NewLexImports().(lexImport interface{}) (*LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#, error) { |
| 27 | imports, err := newLexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/newLexImports().().Addscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#Add().(lexImport.(*LexImportscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport#)) |
| 28 | return imports, err |
| 29 | } |
| 30 | |
| 31 | func newLexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/newLexImports().() *LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports# { |
| 32 | return &LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#{ |
| 33 | Importsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#Imports.: make(map[string]*LexImportscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport#), |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func AddLexImportscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/AddLexImport().(imports, lexImport interface{}) (*LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#, error) { |
| 38 | return imports.(*LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#).Addscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#Add().(lexImport.(*LexImportscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport#)) |
| 39 | } |
| 40 | |
| 41 | // Add will return true if a new lex import has been added, otherwise false. |
| 42 | func (this *LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#) Addscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#Add().(lexImport *LexImportscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport#) (*LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#, error) { |
| 43 | if _, exist := this.Importsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#Imports.[lexImport.Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport#Id.]; exist { |
| 44 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24 fmt/Errorf().("duplicate builtin declaration: %s", lexImport.Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport#String().()) |
| 45 | } |
| 46 | this.Importsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#Imports.[lexImport.Idscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport#Id.] = lexImport |
| 47 | return this, nil |
| 48 | } |
| 49 | |
| 50 | func (this *LexImportsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#) Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#String().() string { |
| 51 | w := new(stringsscip-go gomod github.com/golang/go/src go1.24 strings/.Builderscip-go gomod github.com/golang/go/src go1.24 strings/Builder#) |
| 52 | fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Fprintf().(w, "import(\n") |
| 53 | for _, imp := range this.Importsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImports#Imports. { |
| 54 | fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Fprintf().(w, "\t%s\n", imp.Stringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/ast`/LexImport#String().()) |
| 55 | } |
| 56 | fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Fprintf().(w, ")") |
| 57 | return w.Stringscip-go gomod github.com/golang/go/src go1.24 strings/Builder#String().() |
| 58 | } |