• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rm-hull / jasengo / 19393309254

15 Nov 2025 05:39PM UTC coverage: 88.475% (+13.8%) from 74.667%
19393309254

push

github

web-flow
feat: Add worked example + some needed parser combinators (#3)

* feat: Add worked example + some needed parser combinators

Introduce several common parser primitives and combinators
essential for building practical parsers.

New primitives in `basic.go`:
*   `Lower`, `Upper`: Match corresponding character types.
*   `Whitespace`: Matches spaces, tabs, newlines.
*   `Return`: Lifts a value into a successful parser result.

New combinators in `combinators.go`:
*   `Token`, `Symb`: Handle tokenizing and symbol matching,
    consuming trailing whitespace automatically.
*   `Left`, `Right`, `Between`: Control result selection in sequence.
*   `Rec`: Enables definition of recursive parsers.
*   `SepBy1`: Parses one or more items separated by a delimiter.

A new test (`TestSearchGrammar`) demonstrates the usage of
these tools to parse complex boolean search expressions.

* test: Rename TestSearchGrammar

* Update parser_test/example1_test.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* refactor: Abstract binary expression parsing logic

Introduces `buildExprParser` to DRY up the construction of
precedence chains (like `AND` and `OR` expressions) in the
example parser test file.

This change also:
*   Includes `parser.Upper()` in the definition of
    `alphaNum` tokens, allowing uppercase words in expressions.
*   Fixes a typo in the description of `Upper()`:
    "upperrcase letter" -> "uppercase letter".

* refactor: Use concrete AST nodes for parser output

Introduces dedicated Abstract Syntax Tree (AST) structures for
boolean search expressions (`AndNode`, `OrNode`, `NotNode`,
`TermNode`).

Updates `example1_test.go` to use these specific types instead
of generic `any` or `[]any` for representing the parsed output.
This improves type safety and readability.

* refactor: Rename `Symb` to `Symbol`

The parser combinator function `Symb` has been renamed to
`Symbol` to improve clarity and API consis... (continued)

58 of 70 new or added lines in 3 files covered. (82.86%)

261 of 295 relevant lines covered (88.47%)

1.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/parser_test/ast/ast.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc