Format grammar.js with prettier
This commit is contained in:
parent
6c1ef89aa8
commit
f3a88aa686
428
grammar.js
428
grammar.js
|
@ -1,16 +1,13 @@
|
||||||
module.exports = grammar({
|
module.exports = grammar({
|
||||||
name: 'dockerfile',
|
name: "dockerfile",
|
||||||
|
|
||||||
extras: $ => [
|
extras: ($) => [$.comment, /\s+/, "\\\n"],
|
||||||
$.comment,
|
|
||||||
/\s+/,
|
|
||||||
'\\\n'
|
|
||||||
],
|
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
source_file: $ => repeat(seq($._instruction, "\n")),
|
source_file: ($) => repeat(seq($._instruction, "\n")),
|
||||||
|
|
||||||
_instruction: $ => choice(
|
_instruction: ($) =>
|
||||||
|
choice(
|
||||||
$.from_instruction,
|
$.from_instruction,
|
||||||
$.run_instruction,
|
$.run_instruction,
|
||||||
$.cmd_instruction,
|
$.cmd_instruction,
|
||||||
|
@ -29,324 +26,295 @@ module.exports = grammar({
|
||||||
$.healthcheck_instruction,
|
$.healthcheck_instruction,
|
||||||
$.shell_instruction,
|
$.shell_instruction,
|
||||||
$.maintainer_instruction,
|
$.maintainer_instruction,
|
||||||
$.cross_build_instruction,
|
$.cross_build_instruction
|
||||||
),
|
),
|
||||||
|
|
||||||
from_instruction: $ => seq(
|
from_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[fF][rR][oO][mM]/, "FROM"),
|
alias(/[fF][rR][oO][mM]/, "FROM"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
optional($.param),
|
optional($.param),
|
||||||
$.image_spec,
|
$.image_spec,
|
||||||
optional(seq(
|
optional(seq(alias(/[aA][sS]/, "AS"), field("as", $.image_alias)))
|
||||||
alias(/[aA][sS]/, "AS"),
|
|
||||||
field("as", $.image_alias),
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
run_instruction: $ => seq(
|
run_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[rR][uU][nN]/, "RUN"),
|
alias(/[rR][uU][nN]/, "RUN"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
choice(
|
choice($.string_array, $.shell_command)
|
||||||
$.string_array,
|
|
||||||
$.shell_command,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
cmd_instruction: $ => seq(
|
cmd_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[cC][mM][dD]/, "CMD"),
|
alias(/[cC][mM][dD]/, "CMD"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
choice(
|
choice($.string_array, $.shell_command)
|
||||||
$.string_array,
|
|
||||||
$.shell_command,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
label_instruction: $ => seq(
|
label_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[lL][aA][bB][eE][lL]/, "LABEL"),
|
alias(/[lL][aA][bB][eE][lL]/, "LABEL"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
repeat1($.label_pair),
|
repeat1($.label_pair)
|
||||||
),
|
),
|
||||||
|
|
||||||
expose_instruction: $ => seq(
|
expose_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[eE][xX][pP][oO][sS][eE]/, "EXPOSE"),
|
alias(/[eE][xX][pP][oO][sS][eE]/, "EXPOSE"),
|
||||||
repeat1(choice($.expose_port, $.expansion)),
|
repeat1(choice($.expose_port, $.expansion))
|
||||||
),
|
),
|
||||||
|
|
||||||
env_instruction: $ => seq(
|
env_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[eE][nN][vV]/, "ENV"),
|
alias(/[eE][nN][vV]/, "ENV"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
choice(
|
choice(repeat1($.env_pair), alias($._spaced_env_pair, $.env_pair))
|
||||||
repeat1($.env_pair),
|
|
||||||
alias($._spaced_env_pair, $.env_pair),
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
|
|
||||||
add_instruction: $ => seq(
|
add_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[aA][dD][dD]/, "ADD"),
|
alias(/[aA][dD][dD]/, "ADD"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
optional($.param),
|
optional($.param),
|
||||||
$.path,
|
$.path,
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
$.path,
|
$.path
|
||||||
),
|
),
|
||||||
|
|
||||||
copy_instruction: $ => seq(
|
copy_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[cC][oO][pP][yY]/, "COPY"),
|
alias(/[cC][oO][pP][yY]/, "COPY"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
optional($.param),
|
optional($.param),
|
||||||
$.path,
|
$.path,
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
$.path,
|
$.path
|
||||||
),
|
),
|
||||||
|
|
||||||
entrypoint_instruction: $ => seq(
|
entrypoint_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[eE][nN][tT][rR][yY][pP][oO][iI][nN][tT]/, "ENTRYPOINT"),
|
alias(/[eE][nN][tT][rR][yY][pP][oO][iI][nN][tT]/, "ENTRYPOINT"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
choice(
|
choice($.string_array, $.shell_command)
|
||||||
$.string_array,
|
|
||||||
$.shell_command,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
volume_instruction: $ => seq(
|
volume_instruction: ($) =>
|
||||||
|
seq(
|
||||||
alias(/[vV][oO][lL][uU][mM][eE]/, "VOLUME"),
|
alias(/[vV][oO][lL][uU][mM][eE]/, "VOLUME"),
|
||||||
$._non_newline_whitespace,
|
$._non_newline_whitespace,
|
||||||
choice(
|
choice(
|
||||||
$.string_array,
|
$.string_array,
|
||||||
seq(
|
seq($.path, repeat(seq($._non_newline_whitespace, $.path)))
|
||||||
$.path,
|
|
||||||
repeat(seq($._non_newline_whitespace, $.path)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
user_instruction: $ => seq(
|
|
||||||
alias(/[uU][sS][eE][rR]/, "USER"),
|
|
||||||
$._non_newline_whitespace,
|
|
||||||
field("user", alias($._user_name_group, $.unquoted_string)),
|
|
||||||
optional(seq(
|
|
||||||
token.immediate(":"),
|
|
||||||
field("group", alias($._user_name_group, $.unquoted_string)),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
|
|
||||||
_user_name_group: $ => repeat1(choice(
|
|
||||||
token.immediate(/[a-z][-a-z0-9_]*/),
|
|
||||||
$.expansion,
|
|
||||||
)),
|
|
||||||
|
|
||||||
workdir_instruction: $ => seq(
|
|
||||||
alias(/[wW][oO][rR][kK][dD][iI][rR]/, "WORKDIR"),
|
|
||||||
$._non_newline_whitespace,
|
|
||||||
$.path,
|
|
||||||
),
|
|
||||||
|
|
||||||
arg_instruction: $ => seq(
|
|
||||||
alias(/[aA][rR][gG]/, "ARG"),
|
|
||||||
$._non_newline_whitespace,
|
|
||||||
field("name", alias(/[a-zA-Z0-9_]+/, $.unquoted_string)),
|
|
||||||
optional(seq(
|
|
||||||
token.immediate("="),
|
|
||||||
field("default", choice(
|
|
||||||
$.double_quoted_string,
|
|
||||||
$.unquoted_string,
|
|
||||||
)),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
|
|
||||||
onbuild_instruction: $ => seq(
|
|
||||||
alias(/[oO][nN][bB][uU][iI][lL][dD]/, "ONBUILD"),
|
|
||||||
$._non_newline_whitespace,
|
|
||||||
$._instruction,
|
|
||||||
),
|
|
||||||
|
|
||||||
stopsignal_instruction: $ => seq(
|
|
||||||
alias(/[sS][tT][oO][pP][sS][iI][gG][nN][aA][lL]/, "STOPSIGNAL"),
|
|
||||||
$._non_newline_whitespace,
|
|
||||||
$._stopsignal_value,
|
|
||||||
),
|
|
||||||
|
|
||||||
_stopsignal_value: $ => repeat1(choice(
|
|
||||||
/[A-Z0-9]+/,
|
|
||||||
$.expansion,
|
|
||||||
)),
|
|
||||||
|
|
||||||
healthcheck_instruction: $ => seq(
|
|
||||||
alias(/[hH][eE][aA][lL][tT][hH][cC][hH][eE][cC][kK]/, "HEALTHCHECK"),
|
|
||||||
$._non_newline_whitespace,
|
|
||||||
choice(
|
|
||||||
"NONE",
|
|
||||||
seq(
|
|
||||||
repeat($.param),
|
|
||||||
$.cmd_instruction,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
shell_instruction: $ => seq(
|
|
||||||
alias(/[sS][hH][eE][lL][lL]/, "SHELL"),
|
|
||||||
$._non_newline_whitespace,
|
|
||||||
$.string_array,
|
|
||||||
),
|
|
||||||
|
|
||||||
maintainer_instruction: $ => seq(
|
|
||||||
alias(/[mM][aA][iI][nN][tT][aA][iI][nN][eE][rR]/, "MAINTAINER"),
|
|
||||||
/.*/,
|
|
||||||
),
|
|
||||||
|
|
||||||
cross_build_instruction: $ => seq(
|
|
||||||
alias(/[cC][rR][oO][sS][sS]_[bB][uU][iI][lL][dD][a-zA-Z_]*/, "CROSS_BUILD"),
|
|
||||||
/.*/,
|
|
||||||
),
|
|
||||||
|
|
||||||
path: $ => seq(
|
|
||||||
choice(
|
|
||||||
/[^-\s\$]/, // cannot start with a '-' to avoid conflicts with params
|
|
||||||
$.expansion,
|
|
||||||
),
|
|
||||||
repeat(choice(
|
|
||||||
/[^\s\$]+/,
|
|
||||||
$.expansion,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
|
|
||||||
expansion: $ => seq(
|
|
||||||
'$',
|
|
||||||
choice(
|
|
||||||
$.variable,
|
|
||||||
seq('{', alias(/[^\}]+/, $.variable), '}'),
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
variable: $ => /[a-zA-Z][a-zA-Z0-9_]*/,
|
user_instruction: ($) =>
|
||||||
|
seq(
|
||||||
env_pair: $ => seq(
|
alias(/[uU][sS][eE][rR]/, "USER"),
|
||||||
field("name", $._env_key),
|
$._non_newline_whitespace,
|
||||||
token.immediate("="),
|
field("user", alias($._user_name_group, $.unquoted_string)),
|
||||||
field("value", choice(
|
optional(
|
||||||
$.double_quoted_string,
|
seq(
|
||||||
$.unquoted_string,
|
token.immediate(":"),
|
||||||
)),
|
field("group", alias($._user_name_group, $.unquoted_string))
|
||||||
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
_spaced_env_pair: $ => seq(
|
_user_name_group: ($) =>
|
||||||
|
repeat1(choice(token.immediate(/[a-z][-a-z0-9_]*/), $.expansion)),
|
||||||
|
|
||||||
|
workdir_instruction: ($) =>
|
||||||
|
seq(
|
||||||
|
alias(/[wW][oO][rR][kK][dD][iI][rR]/, "WORKDIR"),
|
||||||
|
$._non_newline_whitespace,
|
||||||
|
$.path
|
||||||
|
),
|
||||||
|
|
||||||
|
arg_instruction: ($) =>
|
||||||
|
seq(
|
||||||
|
alias(/[aA][rR][gG]/, "ARG"),
|
||||||
|
$._non_newline_whitespace,
|
||||||
|
field("name", alias(/[a-zA-Z0-9_]+/, $.unquoted_string)),
|
||||||
|
optional(
|
||||||
|
seq(
|
||||||
|
token.immediate("="),
|
||||||
|
field("default", choice($.double_quoted_string, $.unquoted_string))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
onbuild_instruction: ($) =>
|
||||||
|
seq(
|
||||||
|
alias(/[oO][nN][bB][uU][iI][lL][dD]/, "ONBUILD"),
|
||||||
|
$._non_newline_whitespace,
|
||||||
|
$._instruction
|
||||||
|
),
|
||||||
|
|
||||||
|
stopsignal_instruction: ($) =>
|
||||||
|
seq(
|
||||||
|
alias(/[sS][tT][oO][pP][sS][iI][gG][nN][aA][lL]/, "STOPSIGNAL"),
|
||||||
|
$._non_newline_whitespace,
|
||||||
|
$._stopsignal_value
|
||||||
|
),
|
||||||
|
|
||||||
|
_stopsignal_value: ($) => repeat1(choice(/[A-Z0-9]+/, $.expansion)),
|
||||||
|
|
||||||
|
healthcheck_instruction: ($) =>
|
||||||
|
seq(
|
||||||
|
alias(/[hH][eE][aA][lL][tT][hH][cC][hH][eE][cC][kK]/, "HEALTHCHECK"),
|
||||||
|
$._non_newline_whitespace,
|
||||||
|
choice("NONE", seq(repeat($.param), $.cmd_instruction))
|
||||||
|
),
|
||||||
|
|
||||||
|
shell_instruction: ($) =>
|
||||||
|
seq(
|
||||||
|
alias(/[sS][hH][eE][lL][lL]/, "SHELL"),
|
||||||
|
$._non_newline_whitespace,
|
||||||
|
$.string_array
|
||||||
|
),
|
||||||
|
|
||||||
|
maintainer_instruction: ($) =>
|
||||||
|
seq(
|
||||||
|
alias(/[mM][aA][iI][nN][tT][aA][iI][nN][eE][rR]/, "MAINTAINER"),
|
||||||
|
/.*/
|
||||||
|
),
|
||||||
|
|
||||||
|
cross_build_instruction: ($) =>
|
||||||
|
seq(
|
||||||
|
alias(
|
||||||
|
/[cC][rR][oO][sS][sS]_[bB][uU][iI][lL][dD][a-zA-Z_]*/,
|
||||||
|
"CROSS_BUILD"
|
||||||
|
),
|
||||||
|
/.*/
|
||||||
|
),
|
||||||
|
|
||||||
|
path: ($) =>
|
||||||
|
seq(
|
||||||
|
choice(
|
||||||
|
/[^-\s\$]/, // cannot start with a '-' to avoid conflicts with params
|
||||||
|
$.expansion
|
||||||
|
),
|
||||||
|
repeat(choice(/[^\s\$]+/, $.expansion))
|
||||||
|
),
|
||||||
|
|
||||||
|
expansion: ($) =>
|
||||||
|
seq("$", choice($.variable, seq("{", alias(/[^\}]+/, $.variable), "}"))),
|
||||||
|
|
||||||
|
variable: ($) => /[a-zA-Z][a-zA-Z0-9_]*/,
|
||||||
|
|
||||||
|
env_pair: ($) =>
|
||||||
|
seq(
|
||||||
|
field("name", $._env_key),
|
||||||
|
token.immediate("="),
|
||||||
|
field("value", choice($.double_quoted_string, $.unquoted_string))
|
||||||
|
),
|
||||||
|
|
||||||
|
_spaced_env_pair: ($) =>
|
||||||
|
seq(
|
||||||
field("name", $._env_key),
|
field("name", $._env_key),
|
||||||
token.immediate(/\s+/),
|
token.immediate(/\s+/),
|
||||||
field("value", choice(
|
field("value", choice($.double_quoted_string, $.unquoted_string))
|
||||||
$.double_quoted_string,
|
|
||||||
$.unquoted_string,
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
_env_key: $ => alias(/[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]/, $.unquoted_string),
|
_env_key: ($) =>
|
||||||
|
alias(/[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z0-9]/, $.unquoted_string),
|
||||||
|
|
||||||
expose_port: $ => seq(
|
expose_port: ($) => seq(/\d+/, optional(choice("/tcp", "/udp"))),
|
||||||
/\d+/,
|
|
||||||
optional(choice(
|
|
||||||
"/tcp",
|
|
||||||
"/udp",
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
|
|
||||||
label_pair: $ => seq(
|
label_pair: ($) =>
|
||||||
|
seq(
|
||||||
field("key", alias(/[-a-zA-Z0-9\._]+/, $.unquoted_string)),
|
field("key", alias(/[-a-zA-Z0-9\._]+/, $.unquoted_string)),
|
||||||
token.immediate("="),
|
token.immediate("="),
|
||||||
field("value", choice(
|
field("value", choice($.double_quoted_string, $.unquoted_string))
|
||||||
$.double_quoted_string,
|
|
||||||
$.unquoted_string,
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
image_spec: $ => seq(
|
image_spec: ($) =>
|
||||||
|
seq(
|
||||||
field("name", $.image_name),
|
field("name", $.image_name),
|
||||||
seq(
|
seq(
|
||||||
field("tag", optional($.image_tag)),
|
field("tag", optional($.image_tag)),
|
||||||
field("digest", optional($.image_digest)),
|
field("digest", optional($.image_digest))
|
||||||
),
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
image_name: $ => repeat1(choice(
|
image_name: ($) =>
|
||||||
token.immediate(/[^@:\s\$]+/),
|
repeat1(choice(token.immediate(/[^@:\s\$]+/), $.expansion)),
|
||||||
$.expansion,
|
|
||||||
)),
|
|
||||||
|
|
||||||
image_tag: $ => seq(
|
image_tag: ($) =>
|
||||||
|
seq(
|
||||||
token.immediate(":"),
|
token.immediate(":"),
|
||||||
repeat1(choice(
|
repeat1(choice(token.immediate(/[^@\s\$]+/), $.expansion))
|
||||||
token.immediate(/[^@\s\$]+/),
|
|
||||||
$.expansion,
|
|
||||||
))
|
|
||||||
),
|
),
|
||||||
|
|
||||||
image_digest: $ => seq(
|
image_digest: ($) =>
|
||||||
|
seq(
|
||||||
token.immediate("@"),
|
token.immediate("@"),
|
||||||
repeat1(choice(
|
repeat1(choice(token.immediate(/[a-zA-Z0-9:]+/), $.expansion))
|
||||||
token.immediate(/[a-zA-Z0-9:]+/),
|
|
||||||
$.expansion,
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
param: $ => seq(
|
param: ($) =>
|
||||||
|
seq(
|
||||||
"--",
|
"--",
|
||||||
field("name", token.immediate(/[a-z][-a-z]*/)),
|
field("name", token.immediate(/[a-z][-a-z]*/)),
|
||||||
token.immediate("="),
|
token.immediate("="),
|
||||||
field("value", token.immediate(/[^\s]+/)),
|
field("value", token.immediate(/[^\s]+/))
|
||||||
),
|
),
|
||||||
|
|
||||||
image_alias: $ => repeat1(choice(
|
image_alias: ($) => repeat1(choice(/[-a-zA-Z0-9_]+/, $.expansion)),
|
||||||
/[-a-zA-Z0-9_]+/,
|
|
||||||
$.expansion,
|
|
||||||
)),
|
|
||||||
|
|
||||||
string_array: $ => seq(
|
string_array: ($) =>
|
||||||
|
seq(
|
||||||
"[",
|
"[",
|
||||||
optional(seq(
|
optional(
|
||||||
$.double_quoted_string,
|
seq($.double_quoted_string, repeat(seq(",", $.double_quoted_string)))
|
||||||
repeat(seq(",", $.double_quoted_string)),
|
),
|
||||||
)),
|
"]"
|
||||||
"]",
|
|
||||||
),
|
),
|
||||||
|
|
||||||
shell_command: $ => seq(
|
shell_command: ($) =>
|
||||||
|
seq(
|
||||||
$.shell_fragment,
|
$.shell_fragment,
|
||||||
repeat(seq(
|
repeat(
|
||||||
$.line_continuation,
|
seq($.line_continuation, repeat($._comment_line), $.shell_fragment)
|
||||||
repeat($._comment_line),
|
)
|
||||||
$.shell_fragment,
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
shell_fragment: $ => repeat1(choice(
|
shell_fragment: ($) => repeat1(choice(/[^\\\[\n#\s][^\\\n]*/, /\\[^\n]/)),
|
||||||
/[^\\\[\n#\s][^\\\n]*/,
|
|
||||||
/\\[^\n]/,
|
|
||||||
)),
|
|
||||||
|
|
||||||
line_continuation: $ => '\\\n',
|
line_continuation: ($) => "\\\n",
|
||||||
|
|
||||||
_comment_line: $ => seq(
|
_comment_line: ($) => seq(alias($._anon_comment, $.comment), "\n"),
|
||||||
alias($._anon_comment, $.comment), '\n'
|
|
||||||
),
|
|
||||||
|
|
||||||
_anon_comment: $ => seq('#', /.*/),
|
_anon_comment: ($) => seq("#", /.*/),
|
||||||
|
|
||||||
double_quoted_string: $ => seq(
|
double_quoted_string: ($) =>
|
||||||
|
seq(
|
||||||
'"',
|
'"',
|
||||||
repeat(choice(
|
repeat(
|
||||||
|
choice(
|
||||||
token.immediate(prec(1, /[^"\n\\\$]+/)),
|
token.immediate(prec(1, /[^"\n\\\$]+/)),
|
||||||
$.escape_sequence,
|
$.escape_sequence,
|
||||||
$.expansion,
|
$.expansion
|
||||||
)),
|
)
|
||||||
|
),
|
||||||
'"'
|
'"'
|
||||||
),
|
),
|
||||||
|
|
||||||
unquoted_string: $ => repeat1(choice(
|
unquoted_string: ($) =>
|
||||||
|
repeat1(
|
||||||
|
choice(
|
||||||
token.immediate(/[^\s\n\"\\\$]+/),
|
token.immediate(/[^\s\n\"\\\$]+/),
|
||||||
token.immediate("\\ "),
|
token.immediate("\\ "),
|
||||||
$.expansion,
|
$.expansion
|
||||||
)),
|
)
|
||||||
|
),
|
||||||
|
|
||||||
escape_sequence: $ => token.immediate(seq(
|
escape_sequence: ($) =>
|
||||||
'\\',
|
token.immediate(
|
||||||
|
seq(
|
||||||
|
"\\",
|
||||||
choice(
|
choice(
|
||||||
/[^xuU]/,
|
/[^xuU]/,
|
||||||
/\d{2,3}/,
|
/\d{2,3}/,
|
||||||
|
@ -354,11 +322,11 @@ module.exports = grammar({
|
||||||
/u[0-9a-fA-F]{4}/,
|
/u[0-9a-fA-F]{4}/,
|
||||||
/U[0-9a-fA-F]{8}/
|
/U[0-9a-fA-F]{8}/
|
||||||
)
|
)
|
||||||
)),
|
)
|
||||||
|
),
|
||||||
|
|
||||||
_non_newline_whitespace: $ => /[\t ]+/,
|
_non_newline_whitespace: ($) => /[\t ]+/,
|
||||||
|
|
||||||
comment: $ => seq("#", /.*/),
|
comment: ($) => seq("#", /.*/),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue