Fix csv rules parsing #407

Merged
merged 2 commits into from Sep 25, 2016

Projects

None yet

2 participants

@hpdeifel
Collaborator

A single line containing account1 (note the space at the end) should
parse as assignment of the empty string to account1. At least it did
until commit 4141067.

The problem is that megaparsec's space parses multiple space
characters as opposed to parsec. So in the example above it would
incorrectly consume the newline.

hpdeifel added some commits Sep 24, 2016
@hpdeifel hpdeifel csv rules: Show prettier parsing errors
This goes from

  hledger: user error ("ParseError {errorPos = SourcePos {sourceName = \"foo.csv.rules\",
  sourceLine = Pos 20, sourceColumn = Pos 1} :| [], errorUnexpected =
  fromList [Tokens (' ' :| \"\")], errorExpected = fromList [Label ('b' :| \"lank or comment
  line\"),EndOfInput], errorCustom = fromList []}")

to

  hledger: user error (foo.csv.rules:20:1:
  unexpected space
  expecting blank or comment line or end of input
  )
f4f1a97
@hpdeifel hpdeifel csv rules: Fix parsing of empty field values
A single line containing `account1 ` (note the space at the end) should
parse as assignment of the empty string to account1. At least it did
until commit 4141067.

The problem is that megaparsec's `space` parses multiple space
characters as opposed to parsec. So in the example above it would
incorrectly consume the newline.

This commit also adds a new test case for this bug.
d1ae630
@simonmichael simonmichael merged commit ae73c52 into simonmichael:master Sep 25, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@simonmichael
Owner

Nice, thank you!

@mstksg mstksg added a commit to mstksg/hledger that referenced this pull request Feb 3, 2017
@hpdeifel @mstksg hpdeifel + mstksg Fix csv rules parsing (#407)
* csv rules: Show prettier parsing errors

This goes from

  hledger: user error ("ParseError {errorPos = SourcePos {sourceName = \"foo.csv.rules\",
  sourceLine = Pos 20, sourceColumn = Pos 1} :| [], errorUnexpected =
  fromList [Tokens (' ' :| \"\")], errorExpected = fromList [Label ('b' :| \"lank or comment
  line\"),EndOfInput], errorCustom = fromList []}")

to

  hledger: user error (foo.csv.rules:20:1:
  unexpected space
  expecting blank or comment line or end of input
  )

* csv rules: Fix parsing of empty field values

A single line containing `account1 ` (note the space at the end) should
parse as assignment of the empty string to account1. At least it did
until commit 4141067.

The problem is that megaparsec's `space` parses multiple space
characters as opposed to parsec. So in the example above it would
incorrectly consume the newline.

This commit also adds a new test case for this bug.
73902c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment