@@ -59,10 +59,12 @@ type Gop = modfile.Go
59
59
60
60
// A Class is the work class statement.
61
61
type Class struct {
62
- Ext string // can be "_[class].gox" or ".[class]", eg. "_yap.gox" or ".spx"
63
- Class string // "Sprite"
64
- Proto string // prototype of the work class (not empty if multiple work classes)
65
- Syntax * Line
62
+ Ext string // can be "_[class].gox" or ".[class]", eg. "_yap.gox" or ".spx"
63
+ FullExt string // can be "*_[class].gox", "_[class].gox", "*.[class]" or ".[class]"
64
+ Class string // "Sprite"
65
+ Proto string // prototype of the work class (not empty if multiple work classes)
66
+ Embedded bool // if true, the class instance will be embedded in the project
67
+ Syntax * Line
66
68
}
67
69
68
70
// A Import is the import statement.
@@ -75,6 +77,7 @@ type Import struct {
75
77
// A Project is the project statement.
76
78
type Project struct {
77
79
Ext string // can be "_[class].gox" or ".[class]", eg. "_yap.gox" or ".gmx"
80
+ FullExt string // can be "main_[class].gox", "*_[class].gox", "_[class].gox", "main.[class]", "*.[class]" or ".[class]"
78
81
Class string // "Game"
79
82
Works []* Class // work class of classfile
80
83
PkgPaths []string // package paths of classfile and optional inline-imported packages.
@@ -199,15 +202,15 @@ func (f *File) parseVerb(errs *ErrorList, verb string, line *Line, args []string
199
202
f .Gop .Version = args [0 ]
200
203
case "project" :
201
204
if len (args ) < 1 {
202
- errorf ("usage: project [.projExt ProjClass] classFilePkgPath ..." )
205
+ errorf ("usage: project [* .projExt ProjClass] classFilePkgPath ..." )
203
206
return
204
207
}
205
- if isExt (args [0 ]) {
208
+ if isExt (args [0 ], true ) {
206
209
if len (args ) < 3 || strings .Contains (args [1 ], "/" ) {
207
- errorf ("usage: project [.projExt ProjClass] classFilePkgPath ..." )
210
+ errorf ("usage: project [* .projExt ProjClass] classFilePkgPath ..." )
208
211
return
209
212
}
210
- ext , err := parseExt (& args [0 ])
213
+ ext , fullExt , err := parseExt (& args [0 ], true )
211
214
if err != nil {
212
215
wrapError (err )
213
216
return
@@ -223,7 +226,7 @@ func (f *File) parseVerb(errs *ErrorList, verb string, line *Line, args []string
223
226
return
224
227
}
225
228
f .addProj (& Project {
226
- Ext : ext , Class : class , PkgPaths : pkgPaths , Syntax : line ,
229
+ Ext : ext , FullExt : fullExt , Class : class , PkgPaths : pkgPaths , Syntax : line ,
227
230
})
228
231
return
229
232
}
@@ -245,7 +248,7 @@ func (f *File) parseVerb(errs *ErrorList, verb string, line *Line, args []string
245
248
errorf ("usage: class .workExt WorkClass [ProjClass]" )
246
249
return
247
250
}
248
- workExt , err := parseExt (& args [0 ])
251
+ workExt , fullExt , err := parseExt (& args [0 ], false )
249
252
if err != nil {
250
253
wrapError (err )
251
254
return
@@ -264,10 +267,11 @@ func (f *File) parseVerb(errs *ErrorList, verb string, line *Line, args []string
264
267
}
265
268
}
266
269
proj .Works = append (proj .Works , & Class {
267
- Ext : workExt ,
268
- Class : class ,
269
- Proto : protoClass ,
270
- Syntax : line ,
270
+ Ext : workExt ,
271
+ FullExt : fullExt ,
272
+ Class : class ,
273
+ Proto : protoClass ,
274
+ Syntax : line ,
271
275
})
272
276
case "import" :
273
277
proj := f .proj ()
@@ -329,7 +333,7 @@ func AutoQuote(s string) string {
329
333
}
330
334
331
335
var (
332
- symbolRE = regexp .MustCompile (" \\ *?[A-Z]\\ w*" )
336
+ symbolRE = regexp .MustCompile (`\ *?[A-Z]\w*` )
333
337
)
334
338
335
339
// TODO: to be optimized
0 commit comments