BAM Weblog

GLL Combinators - Whitespace Fix

Brian McKenna2012-08-26

This has been my second week at Precog. During my first week I wrote a patch for the gll-combinators project to fix a whitespace handling issue.

The issue occurred when using the ^# (mapWithTail) combinator, which passes column and line information to a function:

case class A(loc: LineStream, x: String)
literal("daniel") ^# { (loc, x) => A(loc, x) }

The symptom was that the RegexParser class wouldn't strip whitespace from the beginning of the location. So an input with prefix whitespace like:


Would be turned into:

A("    daniel", 0, 0)

But it should have been:

A("daniel", 0, 4)

I just refactored whitespace handling out of RegexParser and into the generic Parser class. Merged into master this week.

Pretty trivial fix but it feels good to be able to work on an open-source parser combinator library!

Please enable JavaScript to view the comments powered by Disqus.