diff options
Diffstat (limited to 'grammar')
-rw-r--r-- | grammar/grammar.go | 20 | ||||
-rw-r--r-- | grammar/parsing_table.go | 4 |
2 files changed, 12 insertions, 12 deletions
diff --git a/grammar/grammar.go b/grammar/grammar.go index a5d6cb7..0cde454 100644 --- a/grammar/grammar.go +++ b/grammar/grammar.go @@ -1206,15 +1206,15 @@ const ( ) type compileConfig struct { - descriptionFileName string - class Class + reportFileName string + class Class } type CompileOption func(config *compileConfig) -func EnableDescription(fileName string) CompileOption { +func EnableReporting(fileName string) CompileOption { return func(config *compileConfig) { - config.descriptionFileName = fileName + config.reportFileName = fileName } } @@ -1342,31 +1342,31 @@ func Compile(gram *Grammar, opts ...CompileOption) (*spec.CompiledGrammar, error return nil, err } - desc, err := b.genDescription(tab, gram) + report, err := b.genReport(tab, gram) if err != nil { return nil, err } - if config.descriptionFileName != "" { - f, err := os.OpenFile(config.descriptionFileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + if config.reportFileName != "" { + f, err := os.OpenFile(config.reportFileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { return nil, err } defer f.Close() - d, err := json.Marshal(desc) + d, err := json.Marshal(report) if err != nil { return nil, err } _, err = f.Write(d) if err != nil { - return nil, fmt.Errorf("failed to write a description file: %w", err) + return nil, fmt.Errorf("failed to write a report: %w", err) } } var implicitlyResolvedCount int - for _, s := range desc.States { + for _, s := range report.States { for _, c := range s.SRConflict { if c.ResolvedBy == ResolvedByShift.Int() { implicitlyResolvedCount++ diff --git a/grammar/parsing_table.go b/grammar/parsing_table.go index 1e3930b..57badd5 100644 --- a/grammar/parsing_table.go +++ b/grammar/parsing_table.go @@ -312,7 +312,7 @@ func (b *lrTableBuilder) resolveSRConflict(sym symbolNum, prod productionNum) (A return ActionTypeReduce, ResolvedByPrec } -func (b *lrTableBuilder) genDescription(tab *ParsingTable, gram *Grammar) (*spec.Description, error) { +func (b *lrTableBuilder) genReport(tab *ParsingTable, gram *Grammar) (*spec.Report, error) { var terms []*spec.Terminal { termSyms := b.symTab.terminalSymbols() @@ -552,7 +552,7 @@ func (b *lrTableBuilder) genDescription(tab *ParsingTable, gram *Grammar) (*spec } } - return &spec.Description{ + return &spec.Report{ Class: string(b.class), Terminals: terms, NonTerminals: nonTerms, |