Skip to content

Commit

Permalink
Merge pull request #366 from hildjj/multi-semi
Browse files Browse the repository at this point in the history
Allow extra semicolons between rules.
  • Loading branch information
hildjj authored Mar 4, 2023
2 parents 6066dbf + deca52a commit 2439e4a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Released: TBD
could have successfully used these in the past. From @hildjj.
- [#364](https://github.com/peggyjs/peggy/issues/364) Fix passing an incorrect
external label to the expression inside the `repeated` node. From @Mingun.
- [#346](https://github.com/peggyjs/peggy/issues/346)] Allow extra semicolons
between rules. From @hildjj.

3.0.0
-----
Expand Down
40 changes: 32 additions & 8 deletions lib/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/parser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ _
// Automatic Semicolon Insertion

EOS
= __ ";"
= (__ ";")+
/ _ SingleLineComment? LineTerminatorSequence
/ __ EOF

Expand Down
2 changes: 1 addition & 1 deletion test/unit/parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe("Peggy grammar parser", () => {
expect("\na = 'abcd';\n").to.parseAs(
{ type: "grammar", topLevelInitializer: null, initializer: null, rules: [ruleA] }
);
expect("\na = 'abcd';\nb = 'efgh';\nc = 'ijkl';\n").to.parseAs(
expect("\na = 'abcd'; /* comment */; // comment\n;\nb = 'efgh';\nc = 'ijkl';\n").to.parseAs(
{ type: "grammar", topLevelInitializer: null, initializer: null, rules: [ruleA, ruleB, ruleC] }
);
expect("\n{ code };\na = 'abcd';\n").to.parseAs(
Expand Down

0 comments on commit 2439e4a

Please sign in to comment.