Skip to content

Commit

Permalink
allow asterisk bullet and versions without patch (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus authored and SeanTAllen committed Jan 6, 2018
1 parent b8c2525 commit a3267ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions changelog_parser.pony
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ primitive ChangelogParser
fun version(): Parser val =>
recover
let frac = L(".") * digits()
(digits() * frac * frac).term(TVersion)
(digits() * frac * frac.opt()).term(TVersion)
end

fun date(): Parser val =>
Expand All @@ -53,10 +53,11 @@ primitive ChangelogParser

fun entries(): Parser val =>
recover
let bullet = L("-") / L("*")
let line = Forward
line() = L("\n") / (Unicode * line)
let sep = L("-") / L("#") / L("\n")
let entry = L("- ") * line * (not sep * line).many()
let sep = bullet / L("#") / L("\n")
let entry = bullet * L(" ") * line * (not sep * line).many()
(entry.term(TEntry) * -L("\n").many()).many1().node(TEntries)
end

Expand Down
12 changes: 7 additions & 5 deletions tests/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class iso _TestParseVersion is UnitTest
fun apply(h: TestHelper) =>
ParseTest(h, ChangelogParser.version()).run(
[ ("0.0.0", "$(Version$0.0.0)")
("0.0", "$(Version$0.0)")
("1.23.9", "$(Version$1.23.9)")
("1.23", "$(Version$1.23)")
("0..0", "")
(".0.0", "")
("0..", "")
Expand Down Expand Up @@ -52,28 +54,28 @@ class iso _TestParseEntries is UnitTest
("- abc\n - def\n\n", "$(Entries$(Entry$- abc\n - def\n))")
( """
- abc
- def
* def
- ghi
- jkl
""",
"$(Entries$(Entry$- abc\n - def\n - ghi\n))" )
"$(Entries$(Entry$- abc\n * def\n - ghi\n))" )
( "- @fowles: handle regex empty match.\n",
"$(Entries$(Entry$- @fowles: handle regex empty match.\n))" )
( "- Upgrade to LLVM 3.9.1 ([PR #1498](https://github.com/ponylang/ponyc/pull/1498))\n",
"$(Entries$(Entry$- Upgrade to LLVM 3.9.1 ([PR #1498](https://github.com/ponylang/ponyc/pull/1498))\n))" )
( """
- stuff
* stuff
- things
* things
- more things
#
""",
"$(Entries$(Entry$- stuff\n)$(Entry$- things\n)$(Entry$- more things\n))"
"$(Entries$(Entry$* stuff\n)$(Entry$* things\n)$(Entry$- more things\n))"
)
])

Expand Down

0 comments on commit a3267ee

Please sign in to comment.