handle embedded script payload
This commit is contained in:
20
grammar.js
20
grammar.js
@@ -2,18 +2,28 @@ module.exports = grammar({
|
||||
name: 'nixshell',
|
||||
|
||||
rules: {
|
||||
source_file: $ => seq($.first_line, repeat($.non_first_line)),
|
||||
source_file: $ => seq($.first_line, repeat($.next_line)),
|
||||
|
||||
first_line: $ => seq($.shebang_open, $.opt_ws, optional(seq($.env, $.ws)), $.nix_shell),
|
||||
non_first_line: $ => seq($.newline, $.annotation_line),
|
||||
next_line: $ => seq($.newline, choice(
|
||||
$.annotation_line,
|
||||
// TODO: capture this
|
||||
repeat(/./),
|
||||
)),
|
||||
annotation_line: $ => seq($.shebang_open, $.opt_ws, $.nix_shell, $.nix_shell_args),
|
||||
embedded_script_line: $ => /.*/,
|
||||
// payload_next_line: $ => /\n.*/,
|
||||
// payload_line: $ => /.*/,
|
||||
// payload_line: $ => repeat(/./),
|
||||
|
||||
shebang_open: $ => /#!/,
|
||||
// nix_shell_directive_open: $ => '#!nix-shell',
|
||||
// TODO: actually parse nix-shell arguments
|
||||
nix_shell_args: $ => ' -i bash',
|
||||
|
||||
// TODO: hide these (prefix with underscore)
|
||||
shebang_open: $ => '#!',
|
||||
// TODO: allow `usr/bin/env`, `env`
|
||||
env: $ => '/usr/bin/env',
|
||||
nix_shell: $ => 'nix-shell',
|
||||
nix_shell_args: $ => ' -i bash',
|
||||
ws: $ => / +/,
|
||||
opt_ws: $ => / */,
|
||||
newline: $ => '\n',
|
||||
|
Reference in New Issue
Block a user