Skip to content

Commit f8a30df

Browse files
committed
Add shebang rule
1 parent 778e585 commit f8a30df

File tree

5 files changed

+6538
-12562
lines changed

5 files changed

+6538
-12562
lines changed

grammar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const WHITESPACE = /\s/;
1717
const IDENTIFIER = /[a-zA-Z_][0-9a-zA-Z_]*/;
1818
const DECIMAL_DIGIT = /[0-9]/;
1919
const HEXADECIMAL_DIGIT = /[0-9a-fA-F]/;
20+
const SHEBANG = /#!.*/;
2021

2122
const _numeral = (digit) =>
2223
choice(
@@ -38,10 +39,11 @@ module.exports = grammar({
3839
name: "lua",
3940

4041
rules: {
41-
chunk: ($) => optional($._block),
42+
chunk: ($) => seq(optional($.shebang), optional($._block)),
4243

43-
block: ($) => $._block,
44+
shebang: ($) => SHEBANG,
4445

46+
block: ($) => $._block,
4547
_block: ($) =>
4648
choice(
4749
$.return_statement,

src/grammar.json

Lines changed: 25 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)