Skip to content

Commit

Permalink
use extra to allow comments anywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed Apr 19, 2024
1 parent b4a90e2 commit 439c3e7
Show file tree
Hide file tree
Showing 6 changed files with 5,200 additions and 5,053 deletions.
10 changes: 2 additions & 8 deletions grammar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = grammar({
name: "dockerfile",

extras: ($) => [/\s+/, $.line_continuation],
extras: ($) => [/\s+/, $.line_continuation, $.comment],
externals: ($) => [
$.heredoc_marker,
$.heredoc_line,
Expand All @@ -11,7 +11,7 @@ module.exports = grammar({
],

rules: {
source_file: ($) => repeat(seq(choice($._instruction, $.comment), "\n")),
source_file: ($) => repeat(seq($._instruction, "\n")),

_instruction: ($) =>
choice(
Expand Down Expand Up @@ -373,12 +373,10 @@ module.exports = grammar({

shell_command: ($) =>
seq(
repeat($._comment_line),
$.shell_fragment,
repeat(
seq(
alias($.required_line_continuation, $.line_continuation),
repeat($._comment_line),
$.shell_fragment
)
)
Expand Down Expand Up @@ -408,10 +406,6 @@ module.exports = grammar({
line_continuation: () => /\\[ \t]*\n/,
required_line_continuation: () => "\\\n",

_comment_line: ($) => seq(alias($._anon_comment, $.comment), "\n"),

_anon_comment: () => seq("#", /.*/),

json_string_array: ($) =>
seq(
"[",
Expand Down
62 changes: 6 additions & 56 deletions src/grammar.json

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

21 changes: 4 additions & 17 deletions src/node-types.json

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

Loading

0 comments on commit 439c3e7

Please sign in to comment.