Skip to content

Commit 3629e6e

Browse files
committed
fix grammar regression
1 parent 44e24eb commit 3629e6e

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

grammars/tree-sitter-ssh-server-config/grammar.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@ export default grammar({
1818

1919
// check for an empty line that is just a /n character
2020
_empty_line: $ => '\n',
21-
comment: $ => /#.*/,
21+
comment: $ => seq(/#.*/, '\n'),
22+
_inline_comment: $ => /#.*/,
2223

2324
keyword: $ => seq(
2425
field('keyword', $.alphanumeric),
2526
choice(seq(/[ \t]/, optional('=')), '='),
2627
optional(field('operator', $.operator)),
2728
field('arguments', $.arguments),
28-
optional($.comment),
29+
optional(alias($._inline_comment, $.comment)),
2930
"\n"
3031
),
3132

3233
match: $ => seq(
3334
token(prec(PREC.MATCH, /match/i)),
34-
seq(repeat1($.criteria), optional($.comment), $._empty_line),
35+
seq(repeat1($.criteria), optional(alias($._inline_comment, $.comment)), $._empty_line),
3536
repeat1(choice($.comment, $.keyword)),
3637
optional($._empty_line)
3738
),

grammars/tree-sitter-ssh-server-config/test/corpus/valid_expressions.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,22 @@ match Address 192.168.1.0/24
543543
(alphanumeric)
544544
(arguments
545545
(number)))))
546+
====
547+
parse comment within match block
548+
====
549+
match user developer
550+
# Enable password authentication for developers - comment ignored
551+
passwordauthentication yes
552+
553+
---
554+
(server_config
555+
(match
556+
(criteria
557+
(alpha)
558+
(argument
559+
(string)))
560+
(comment)
561+
(keyword
562+
(alphanumeric)
563+
(arguments
564+
(boolean)))))

0 commit comments

Comments
 (0)