Skip to content

Commit 5659f1c

Browse files
committed
chore: remove list grammar options
1 parent 5692d21 commit 5659f1c

1 file changed

Lines changed: 11 additions & 38 deletions

File tree

tools/fuzzing/cmd/fuzzer/main.go

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,31 @@ import (
99

1010
"github.com/bytebase/parser/tools/fuzzing/internal/config"
1111
"github.com/bytebase/parser/tools/fuzzing/internal/generator"
12-
"github.com/bytebase/parser/tools/fuzzing/internal/grammar"
1312
)
1413

1514
func main() {
1615
cfg := parseFlags()
17-
16+
1817
if err := cfg.Validate(); err != nil {
1918
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
2019
os.Exit(1)
2120
}
22-
21+
2322
cfg.Print()
24-
23+
2524
gen := generator.New(cfg)
2625
if err := gen.Generate(); err != nil {
2726
fmt.Fprintf(os.Stderr, "Generation failed: %v\n", err)
2827
os.Exit(1)
2928
}
30-
29+
3130
fmt.Println("Generation completed successfully!")
3231
}
3332

3433
func parseFlags() *config.Config {
3534
cfg := &config.Config{}
36-
var listGrammars bool
3735
var grammarArg string
38-
36+
3937
flag.StringVar(&grammarArg, "grammar", "", "Grammar file(s): single file or comma-separated lexer,parser files")
4038
flag.StringVar(&cfg.StartRule, "start-rule", "", "Starting grammar rule name")
4139
flag.IntVar(&cfg.Count, "count", 10, "Number of queries to generate")
@@ -46,18 +44,15 @@ func parseFlags() *config.Config {
4644
flag.IntVar(&cfg.QuantifierCount, "quantifier-count", 0, "Fixed count for all quantifiers (overrides min/max)")
4745
flag.StringVar(&cfg.Output, "output", "", "Output file path (default: stdout)")
4846
flag.Int64Var(&cfg.Seed, "seed", time.Now().UnixNano(), "Random seed for reproducible generation")
49-
flag.BoolVar(&listGrammars, "list-grammars", false, "List all available grammars and exit")
50-
47+
5148
// Custom usage message
5249
flag.Usage = func() {
5350
fmt.Fprintf(os.Stderr, "Grammar-Aware Fuzzing Tool\n\n")
5451
fmt.Fprintf(os.Stderr, "Usage: %s [options]\n\n", os.Args[0])
5552
fmt.Fprintf(os.Stderr, "Options:\n")
5653
flag.PrintDefaults()
57-
54+
5855
fmt.Fprintf(os.Stderr, "\nExamples:\n")
59-
fmt.Fprintf(os.Stderr, " # List available grammars\n")
60-
fmt.Fprintf(os.Stderr, " %s --list-grammars\n\n", os.Args[0])
6156
fmt.Fprintf(os.Stderr, " # Single combined grammar file\n")
6257
fmt.Fprintf(os.Stderr, " %s --grammar combined.g4 --start-rule selectStmt --count 10\n\n", os.Args[0])
6358
fmt.Fprintf(os.Stderr, " # Separate lexer and parser files\n")
@@ -69,31 +64,9 @@ func parseFlags() *config.Config {
6964
fmt.Fprintf(os.Stderr, " # Output to file\n")
7065
fmt.Fprintf(os.Stderr, " %s --grammar postgresql/PostgreSQLLexer.g4,postgresql/PostgreSQLParser.g4 --start-rule selectStmt --count 100 --output queries.sql\n\n", os.Args[0])
7166
}
72-
67+
7368
flag.Parse()
74-
75-
// Handle --list-grammars
76-
if listGrammars {
77-
grammars, err := grammar.ListAvailableGrammars()
78-
if err != nil {
79-
fmt.Fprintf(os.Stderr, "Error listing grammars: %v\n", err)
80-
os.Exit(1)
81-
}
82-
83-
fmt.Println("Available grammars:")
84-
for _, g := range grammars {
85-
files, err := grammar.DiscoverGrammarFiles(g)
86-
if err != nil {
87-
fmt.Printf(" %s (error: %v)\n", g, err)
88-
continue
89-
}
90-
fmt.Printf(" %s\n", g)
91-
fmt.Printf(" Lexer: %s\n", files.LexerFile)
92-
fmt.Printf(" Parser: %s\n", files.ParserFile)
93-
}
94-
os.Exit(0)
95-
}
96-
69+
9770
// Parse grammar files from comma-separated argument
9871
if grammarArg != "" {
9972
files := strings.Split(grammarArg, ",")
@@ -103,6 +76,6 @@ func parseFlags() *config.Config {
10376
}
10477
cfg.GrammarFiles = files
10578
}
106-
79+
10780
return cfg
108-
}
81+
}

0 commit comments

Comments
 (0)