Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow asterisk bullet and versions without patch #20

Merged
merged 1 commit into from
Jan 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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