Skip to content

Commit

Permalink
Parse files that end without a newline or semicolon
Browse files Browse the repository at this point in the history
See alex-pinkus#166

```
$ echo -n "print(3)" > nonewline.swift
$ npx tree-sitter parse nonewline.swift # No parse error
```
  • Loading branch information
nmote committed Apr 27, 2022
1 parent a58ff96 commit b47c0dd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ module.exports = grammar({
source_file: ($) =>
seq(
optional($.shebang_line),
repeat(seq($._top_level_statement, $._semi))
optional(
seq(
$._top_level_statement,
repeat(seq($._semi, $._top_level_statement)),
optional($._semi)
)
)
),
shebang_line: ($) => seq("#!", /[^\r\n]*/),
////////////////////////////////
Expand Down

0 comments on commit b47c0dd

Please sign in to comment.