jemc / crystal-pegmatite

A high-performance Parsing Expression Grammar (PEG) library for the Crystal language. :gem: :capital_abcd:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convenience DSL for ignored whitespace between patterns

watzon opened this issue · comments

It would be ideal if parsers didn't have to manually define a whitespace pattern and use it throughout. Instead we could have a special infix operator that tells pegmatite whether or not to ignore the whitepsace between two rules.

For example:

my_rule = str("hello") ^ str("world")

would match both "hello world" and "helloworld". Ideally we should also be able to define an ignore pattern, since all whitespace is not created equally. Maybe having a special whitespace_chars method or something.