Skip to content

Comments

Migrate GIB parser to petitparser#101

Open
vijaytogra wants to merge 102 commits intoale64bit:mainfrom
vijaytogra:migrate-gib-to-petitparser
Open

Migrate GIB parser to petitparser#101
vijaytogra wants to merge 102 commits intoale64bit:mainfrom
vijaytogra:migrate-gib-to-petitparser

Conversation

@vijaytogra
Copy link

  • Refactored GIB parser to use petitparser library (matching SGF parser)
  • Replaced hand-written imperative parser with declarative grammar
  • Removed obsolete parse_ext.dart file that was only used by GIB parser
  • Maintains same public API and data structures for backward compatibility
  • All 15 tests pass without modification

ale64bit and others added 30 commits July 2, 2025 13:58
ale64bit and others added 13 commits October 4, 2025 21:55
- Refactored GIB parser to use petitparser library (matching SGF parser)
- Replaced hand-written imperative parser with declarative grammar
- Removed obsolete parse_ext.dart file that was only used by GIB parser
- Maintains same public API and data structures for backward compatibility
- All 15 tests pass without modification
@vijaytogra
Copy link
Author

Summary

Migrated the GIB parser from a hand-written imperative parser to use the petitparser library, bringing consistency with the SGF parser implementation.

Changes

  • ✅ Refactored lib/parse/gib/gib.dart to use petitparser GrammarDefinition
  • ✅ Removed lib/parse/parse_ext.dart (no longer needed)
  • ✅ Headers section: Full declarative parser with support for key:value pairs and plain values
  • ✅ Game section: Simplified pattern-based parsing for robustness
  • ✅ Maintains same public API - no breaking changes
  • ✅ All 15 tests pass without modification

Benefits

  • Consistency: Both parsers (SGF & GIB) now use the same parsing library
  • Maintainability: Declarative grammar is easier to understand and modify
  • Reduced Code: Removed custom extension methods, cleaner codebase

Testing

All existing tests pass:

flutter test test/gib_test.dart  # ✅ Pass
flutter test                      # ✅ All 15 tests pass

@benjaminpjones
Copy link
Contributor

Hi Vijay, I'm not as familiar with the GIB side, but I want to note that the GIB test suite is not very robust. There is only one test in gib_test.dart, and the assertions are pretty loose.

If you want to be confident that this doesn't cause a regression, I recommend adding a test that exercises GameRecord.fromGib and asserts the moves that are read out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants