Debian Codegraph @

internal/config/config.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 configscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/
16
17 import (
18 "errorsscip-go gomod github.com/golang/go/src go1.24 errors/"
19 "flagscip-go gomod github.com/golang/go/src go1.24 flag/"
20 "fmtscip-go gomod github.com/golang/go/src go1.24 fmt/"
21 "go/buildscip-go gomod github.com/golang/go/src go1.24 `go/build`/"
22 "osscip-go gomod github.com/golang/go/src go1.24 os/"
23 "pathscip-go gomod github.com/golang/go/src go1.24 path/"
24 "path/filepathscip-go gomod github.com/golang/go/src go1.24 `path/filepath`/"
25 "stringsscip-go gomod github.com/golang/go/src go1.24 strings/"
26
27 "golang.org/x/mod/modfilescip-go gomod golang.org/x/mod v0.8.0 `golang.org/x/mod/modfile`/"
28 )
29
30 type Configscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config# interface {
31 Helpscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#Help.() bool
32 Verbosescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#Verbose.() bool
33 Zipscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#Zip.() bool
34 AllowUnreachablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#AllowUnreachable.() bool
35 AutoResolveLRConfscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#AutoResolveLRConf.() bool
36 SourceFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#SourceFile.() string
37 OutDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#OutDir.() string
38
39 NoLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#NoLexer.() bool
40 DebugLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#DebugLexer.() bool
41 DebugParserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#DebugParser.() bool
42
43 ErrorsDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#ErrorsDir.() string
44 ParserDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#ParserDir.() string
45 ScannerDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#ScannerDir.() string
46 TokenDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#TokenDir.() string
47
48 ProjectNamescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#ProjectName.() string
49 Packagescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#Package.() string
50
51 PrintParamsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#PrintParams.()
52 }
53
54 type ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord# struct {
55 workingDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#workingDir. string
56
57 allowUnreachablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#allowUnreachable. *bool
58 autoResolveLRConfscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#autoResolveLRConf. *bool
59 debugLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugLexer. *bool
60 debugParserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugParser. *bool
61 helpscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#help. *bool
62 noLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#noLexer. *bool
63 outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir. string
64 pkgscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#pkg. string
65 srcFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#srcFile. string
66 verbosescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#verbose. *bool
67 zipscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#zip. *bool
68 }
69
70 func Newscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/New().() (Configscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/Config#, error) {
71 wd, err := osscip-go gomod github.com/golang/go/src go1.24 os/.Getwdscip-go gomod github.com/golang/go/src go1.24 os/Getwd().()
72 if err != nil {
73 return nil, err
74 }
75
76 cfg := &ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#{
77 workingDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#workingDir.: wd,
78 }
79
80 if err := cfg.getFlagsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#getFlags().(); err != nil {
81 cfg.PrintParamsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#PrintParams().()
82 return nil, err
83 }
84
85 return cfg, nil
86 }
87
88 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) Helpscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#Help().() bool {
89 return *this.helpscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#help.
90 }
91
92 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) Verbosescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#Verbose().() bool {
93 return *this.verbosescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#verbose.
94 }
95
96 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) Zipscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#Zip().() bool {
97 return *this.zipscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#zip.
98 }
99
100 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) AllowUnreachablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#AllowUnreachable().() bool {
101 return *this.allowUnreachablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#allowUnreachable.
102 }
103
104 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) AutoResolveLRConfscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#AutoResolveLRConf().() bool {
105 return *this.autoResolveLRConfscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#autoResolveLRConf.
106 }
107
108 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) NoLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#NoLexer().() bool {
109 return *this.noLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#noLexer.
110 }
111
112 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) DebugLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#DebugLexer().() bool {
113 return *this.debugLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugLexer.
114 }
115
116 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) DebugParserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#DebugParser().() bool {
117 return *this.debugParserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugParser.
118 }
119
120 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) SourceFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#SourceFile().() string {
121 return this.srcFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#srcFile.
122 }
123
124 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) OutDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#OutDir().() string {
125 return this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir.
126 }
127
128 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) ErrorsDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#ErrorsDir().() string {
129 return pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir., "errors")
130 }
131
132 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) ParserDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#ParserDir().() string {
133 return pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir., "parser")
134 }
135
136 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) ScannerDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#ScannerDir().() string {
137 return pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir., "scanner")
138 }
139
140 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) TokenDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#TokenDir().() string {
141 return pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir., "token")
142 }
143
144 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) Packagescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#Package().() string {
145 return this.pkgscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#pkg.
146 }
147
148 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) ProjectNamescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#ProjectName().() string {
149 _, file := pathscip-go gomod github.com/golang/go/src go1.24 path/.Splitscip-go gomod github.com/golang/go/src go1.24 path/Split().(this.pkgscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#pkg.)
150 return file
151 }
152
153 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) PrintParamsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#PrintParams().() {
154 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-a = %v\n", *this.autoResolveLRConfscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#autoResolveLRConf.)
155 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-debug_lexer = %v\n", *this.debugLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugLexer.)
156 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-debug_parser = %v\n", *this.debugParserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugParser.)
157 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-h = %v\n", *this.helpscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#help.)
158 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-no_lexer = %v\n", *this.noLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#noLexer.)
159 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-o = %v\n", this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir.)
160 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-p = %v\n", this.pkgscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#pkg.)
161 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-u = %v\n", *this.allowUnreachablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#allowUnreachable.)
162 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-v = %v\n", *this.verbosescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#verbose.)
163 fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24 fmt/Printf().("-zip = %v\n", *this.zipscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#zip.)
164 }
165
166 /*** Utility routines ***/
167
168 func (this *ConfigRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#) getFlagsscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#getFlags().() error {
169 pkgDefault, _ := defaultPackagescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/defaultPackage().(this.workingDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#workingDir.)
170
171 this.autoResolveLRConfscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#autoResolveLRConf. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Boolscip-go gomod github.com/golang/go/src go1.24 flag/Bool().("a", false, "automatically resolve LR(1) conflicts")
172 this.debugLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugLexer. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Boolscip-go gomod github.com/golang/go/src go1.24 flag/Bool().("debug_lexer", false, "enable debug logging in lexer")
173 this.debugParserscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugParser. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Boolscip-go gomod github.com/golang/go/src go1.24 flag/Bool().("debug_parser", false, "enable debug logging in parser")
174 this.helpscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#help. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Boolscip-go gomod github.com/golang/go/src go1.24 flag/Bool().("h", false, "help")
175 this.noLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#noLexer. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Boolscip-go gomod github.com/golang/go/src go1.24 flag/Bool().("no_lexer", false, "do not generate a lexer")
176 flagscip-go gomod github.com/golang/go/src go1.24 flag/.StringVarscip-go gomod github.com/golang/go/src go1.24 flag/StringVar().(&this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir., "o", this.workingDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#workingDir., "output dir.")
177 flagscip-go gomod github.com/golang/go/src go1.24 flag/.StringVarscip-go gomod github.com/golang/go/src go1.24 flag/StringVar().(&this.pkgscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#pkg., "p", pkgDefault, "package")
178 this.allowUnreachablescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#allowUnreachable. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Boolscip-go gomod github.com/golang/go/src go1.24 flag/Bool().("u", false, "allow unreachable productions")
179 this.verbosescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#verbose. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Boolscip-go gomod github.com/golang/go/src go1.24 flag/Bool().("v", false, "verbose")
180 this.zipscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#zip. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Boolscip-go gomod github.com/golang/go/src go1.24 flag/Bool().("zip", false, "zip the actiontable and gototable (experimental)")
181 flagscip-go gomod github.com/golang/go/src go1.24 flag/.Parsescip-go gomod github.com/golang/go/src go1.24 flag/Parse().()
182
183 if *this.noLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#noLexer. && *this.debugLexerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#debugLexer. {
184 return errorsscip-go gomod github.com/golang/go/src go1.24 errors/.Newscip-go gomod github.com/golang/go/src go1.24 errors/New().("no_lexer and debug_lexer cannot both be set")
185 }
186
187 this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir. = getOutDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/getOutDir().(this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir., this.workingDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#workingDir.)
188 if this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir. != this.workingDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#workingDir. {
189 pkg, err := defaultPackagescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/defaultPackage().(this.outDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#outDir.)
190 if err != nil {
191 return fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24 fmt/Errorf().("getting package: %s", err)
192 }
193 this.pkgscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#pkg. = pkg
194 }
195
196 if len(flagscip-go gomod github.com/golang/go/src go1.24 flag/.Argsscip-go gomod github.com/golang/go/src go1.24 flag/Args().()) != 1 && !*this.helpscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#help. {
197 return errorsscip-go gomod github.com/golang/go/src go1.24 errors/.Newscip-go gomod github.com/golang/go/src go1.24 errors/New().("too few arguments")
198 }
199
200 this.srcFilescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/ConfigRecord#srcFile. = flagscip-go gomod github.com/golang/go/src go1.24 flag/.Argscip-go gomod github.com/golang/go/src go1.24 flag/Arg().(0)
201
202 return nil
203 }
204
205 func getOutDirscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/getOutDir().(outDirSpec, wd string) string {
206 if stringsscip-go gomod github.com/golang/go/src go1.24 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.24 strings/HasPrefix().(outDirSpec, wd) {
207 return outDirSpec
208 }
209 return pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(wd, outDirSpec)
210 }
211
212 func defaultPackagescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/defaultPackage().(wd string) (string, error) {
213 pkg, parent, err := currentModulescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/currentModule().()
214 if err == nil {
215 pkg = pkg + stringsscip-go gomod github.com/golang/go/src go1.24 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.24 strings/TrimPrefix().(wd, parent)
216 return pkg, nil
217 }
218
219 dirs := buildscip-go gomod github.com/golang/go/src go1.24 `go/build`/.Defaultscip-go gomod github.com/golang/go/src go1.24 `go/build`/Default..SrcDirsscip-go gomod github.com/golang/go/src go1.24 `go/build`/Context#SrcDirs().()
220 for _, srcDir := range dirs {
221 if stringsscip-go gomod github.com/golang/go/src go1.24 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.24 strings/HasPrefix().(wd, srcDir) {
222 pkg = stringsscip-go gomod github.com/golang/go/src go1.24 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.24 strings/TrimPrefix().(wd, srcDir)
223 pkg = sanitizePackagescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/sanitizePackage().(pkg)
224 return pkg, nil
225 }
226 }
227
228 return "", errorsscip-go gomod github.com/golang/go/src go1.24 errors/.Newscip-go gomod github.com/golang/go/src go1.24 errors/New().("can not determine default package name")
229 }
230
231 func sanitizePackagescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/sanitizePackage().(pkg string) string {
232 pkg = filepathscip-go gomod github.com/golang/go/src go1.24 `path/filepath`/.ToSlashscip-go gomod github.com/golang/go/src go1.24 `path/filepath`/ToSlash().(pkg)
233 pkg = stringsscip-go gomod github.com/golang/go/src go1.24 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.24 strings/TrimPrefix().(pkg, "/")
234 return pkg
235 }
236
237 var errNoModulesscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/errNoModules. = errorsscip-go gomod github.com/golang/go/src go1.24 errors/.Newscip-go gomod github.com/golang/go/src go1.24 errors/New().("not using modules")
238
239 // currentModule looks in all parent dirs for a go.mod file containing
240 // a module name.
241 func currentModulescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/currentModule().() (string, string, error) {
242 parent, err := osscip-go gomod github.com/golang/go/src go1.24 os/.Getwdscip-go gomod github.com/golang/go/src go1.24 os/Getwd().()
243 if err != nil {
244 // A nonexistent working directory can't be in a module.
245 return "", "", fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24 fmt/Errorf().("getting working directory: %s", err)
246 }
247
248 var info osscip-go gomod github.com/golang/go/src go1.24 os/.FileInfoscip-go gomod github.com/golang/go/src go1.24 os/FileInfo#
249 for {
250 info, err = osscip-go gomod github.com/golang/go/src go1.24 os/.Statscip-go gomod github.com/golang/go/src go1.24 os/Stat().(filepathscip-go gomod github.com/golang/go/src go1.24 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24 `path/filepath`/Join().(parent, "go.mod"))
251 if err == nil && !info.IsDirscip-go gomod github.com/golang/go/src go1.24 `io/fs`/FileInfo#IsDir().() {
252 break
253 }
254 d := filepathscip-go gomod github.com/golang/go/src go1.24 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.24 `path/filepath`/Dir().(parent)
255 if len(d) >= len(parent) {
256 return "", "", errNoModulesscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/config`/errNoModules. // reached top of file system, no go.mod
257 }
258 parent = d
259 }
260
261 full := pathscip-go gomod github.com/golang/go/src go1.24 path/.Joinscip-go gomod github.com/golang/go/src go1.24 path/Join().(parent, info.Namescip-go gomod github.com/golang/go/src go1.24 `io/fs`/FileInfo#Name().())
262 data, err := osscip-go gomod github.com/golang/go/src go1.24 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24 os/ReadFile().(full)
263 if err != nil {
264 return "", "", fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24 fmt/Errorf().("reading file '%s': %s", full, err)
265 }
266
267 f, err := modfilescip-go gomod golang.org/x/mod v0.8.0 `golang.org/x/mod/modfile`/.Parsescip-go gomod golang.org/x/mod v0.8.0 `golang.org/x/mod/modfile`/Parse().(info.Namescip-go gomod github.com/golang/go/src go1.24 `io/fs`/FileInfo#Name().(), data, nil)
268 if err != nil {
269 return "", "", fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24 fmt/Errorf().("parsing file '%s': %s", full, err)
270 }
271
272 m := f.Modulescip-go gomod golang.org/x/mod v0.8.0 `golang.org/x/mod/modfile`/File#Module..Modscip-go gomod golang.org/x/mod v0.8.0 `golang.org/x/mod/modfile`/Module#Mod..Pathscip-go gomod golang.org/x/mod v0.8.0 `golang.org/x/mod/module`/Version#Path.
273 return m, parent, nil
274 }