Optimize compile-time performance with defcombinatorp/3
masterBy default, NimbleParsec inlines combinators. If you reuse the same combinator (e.g., date) in multiple places within a single defparsec call, it will be compiled multiple times, increasing memory usage and compile times.
To prevent this, use defcombinatorp/3 to define a reusable, pre-compiled combinator. You can then reference it using parsec(:name) within your main parser definition.
# Instead of reusing raw combinators:
# date_then_time = concat(date, time)
# time_then_date = concat(time, date)
# defparsec :combinations, choice([date_then_time, time_then_date])
# Use defcombinatorp for reuse:
defcombinatorp :date, ...
defcombinatorp :time, ...
date_then_time = concat(parsec(:date), parsec(:time))
time_then_date = concat(parsec(:time), parsec(:date))
defparsec :combinations, choice([date_then_time, time_then_date])