2024-05-21 22:14:16 +00:00
|
|
|
package functions
|
|
|
|
|
|
|
|
type GrammarOption struct {
|
2024-05-23 17:16:08 +00:00
|
|
|
PropOrder string
|
2024-05-31 07:36:27 +00:00
|
|
|
Prefix string
|
2024-05-23 17:16:08 +00:00
|
|
|
MaybeArray bool
|
|
|
|
DisableParallelNewLines bool
|
|
|
|
MaybeString bool
|
|
|
|
NoMixedFreeString bool
|
2024-05-31 07:36:27 +00:00
|
|
|
ExpectStringsAfterJSON bool
|
2024-05-21 22:14:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (o *GrammarOption) Apply(options ...func(*GrammarOption)) {
|
|
|
|
for _, l := range options {
|
|
|
|
l(o)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var EnableMaybeArray = func(o *GrammarOption) {
|
|
|
|
o.MaybeArray = true
|
|
|
|
}
|
|
|
|
|
2024-05-23 17:16:08 +00:00
|
|
|
var DisableParallelNewLines = func(o *GrammarOption) {
|
|
|
|
o.DisableParallelNewLines = true
|
|
|
|
}
|
|
|
|
|
2024-05-21 22:14:16 +00:00
|
|
|
var EnableMaybeString = func(o *GrammarOption) {
|
|
|
|
o.MaybeString = true
|
|
|
|
}
|
|
|
|
|
|
|
|
var NoMixedFreeString func(*GrammarOption) = func(o *GrammarOption) {
|
|
|
|
o.NoMixedFreeString = true
|
|
|
|
}
|
|
|
|
|
2024-05-31 07:36:27 +00:00
|
|
|
// ExpectStringsAfterJSON enables mixed string suffix
|
|
|
|
var ExpectStringsAfterJSON func(*GrammarOption) = func(o *GrammarOption) {
|
|
|
|
o.ExpectStringsAfterJSON = true
|
|
|
|
}
|
|
|
|
|
2024-05-21 22:14:16 +00:00
|
|
|
func SetPrefix(suffix string) func(*GrammarOption) {
|
|
|
|
return func(o *GrammarOption) {
|
2024-05-31 07:36:27 +00:00
|
|
|
o.Prefix = suffix
|
2024-05-21 22:14:16 +00:00
|
|
|
}
|
|
|
|
}
|