hide uninteresting nodes
This commit is contained in:
@@ -8,18 +8,8 @@ echo "hello, world!"
|
||||
---
|
||||
|
||||
(source_file
|
||||
(first_line
|
||||
(shebang_open)
|
||||
(opt_ws)
|
||||
(env)
|
||||
(ws)
|
||||
(nix_shell))
|
||||
(first_line)
|
||||
(next_line
|
||||
(newline)
|
||||
(annotation_line
|
||||
(shebang_open)
|
||||
(opt_ws)
|
||||
(nix_shell)
|
||||
(nix_shell_args)))
|
||||
(next_line
|
||||
(newline)))
|
||||
(next_line))
|
||||
|
@@ -6,9 +6,4 @@ nix-shell shebang without any interpreter option
|
||||
---
|
||||
|
||||
(source_file
|
||||
(first_line
|
||||
(shebang_open)
|
||||
(opt_ws)
|
||||
(env)
|
||||
(ws)
|
||||
(nix_shell)))
|
||||
(first_line))
|
||||
|
@@ -7,16 +7,7 @@ Minimal nix-shell invocation
|
||||
---
|
||||
|
||||
(source_file
|
||||
(first_line
|
||||
(shebang_open)
|
||||
(opt_ws)
|
||||
(env)
|
||||
(ws)
|
||||
(nix_shell))
|
||||
(first_line)
|
||||
(next_line
|
||||
(newline)
|
||||
(annotation_line
|
||||
(shebang_open)
|
||||
(opt_ws)
|
||||
(nix_shell)
|
||||
(nix_shell_args))))
|
||||
|
24
grammar.js
24
grammar.js
@@ -4,28 +4,22 @@ module.exports = grammar({
|
||||
rules: {
|
||||
source_file: $ => seq($.first_line, repeat($.next_line)),
|
||||
|
||||
first_line: $ => seq($.shebang_open, $.opt_ws, optional(seq($.env, $.ws)), $.nix_shell),
|
||||
next_line: $ => seq($.newline, choice(
|
||||
first_line: $ => seq($._shebang_open, $._opt_ws, optional(seq($._env, $._ws)), $._nix_shell),
|
||||
next_line: $ => seq($._newline, choice(
|
||||
$.annotation_line,
|
||||
// TODO: capture this
|
||||
repeat(/./),
|
||||
)),
|
||||
annotation_line: $ => seq($.shebang_open, $.opt_ws, $.nix_shell, $.nix_shell_args),
|
||||
// payload_next_line: $ => /\n.*/,
|
||||
// payload_line: $ => /.*/,
|
||||
// payload_line: $ => repeat(/./),
|
||||
annotation_line: $ => seq($._shebang_open, $._opt_ws, $._nix_shell, $.nix_shell_args),
|
||||
|
||||
// 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: $ => '#!',
|
||||
_shebang_open: $ => '#!',
|
||||
// TODO: allow `usr/bin/env`, `env`
|
||||
env: $ => '/usr/bin/env',
|
||||
nix_shell: $ => 'nix-shell',
|
||||
ws: $ => / +/,
|
||||
opt_ws: $ => / */,
|
||||
newline: $ => '\n',
|
||||
_env: $ => '/usr/bin/env',
|
||||
_nix_shell: $ => 'nix-shell',
|
||||
_ws: $ => / +/,
|
||||
_opt_ws: $ => / */,
|
||||
_newline: $ => '\n',
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user