This splits up the parser logic: a lower level helper breaks up the input bytes in useful ways and tracks source information for error reports. The main parser uses the helper, so that it can focus on the "business logic" of checking the format and linting, without being polluted with tracking offsets and partial state and stuff.
The PR is in 2 commits, each one is ~50% of the change: the first adds the new helper without using it, in text.go and text_test.go. The second commit updates parser.go to use the helper.
The helper has a bunch more unit tests, but the parser functionality is unchanged, and all pre-existing tests pass without modification. Later PRs (see todo) will add missing features, this is just a cleanup to prepare for that.
This splits up the parser logic: a lower level helper breaks up the input bytes in useful ways and tracks source information for error reports. The main parser uses the helper, so that it can focus on the "business logic" of checking the format and linting, without being polluted with tracking offsets and partial state and stuff.
The PR is in 2 commits, each one is ~50% of the change: the first adds the new helper without using it, in
text.go
andtext_test.go
. The second commit updatesparser.go
to use the helper.The helper has a bunch more unit tests, but the parser functionality is unchanged, and all pre-existing tests pass without modification. Later PRs (see todo) will add missing features, this is just a cleanup to prepare for that.