@@ -12,6 +12,7 @@ module.exports = grammar({
1212 conflicts : ( $ ) => [
1313 [ $ . target_url ] ,
1414 [ $ . _raw_body ] ,
15+ [ $ . _section_content ] ,
1516 ] ,
1617 inline : ( $ ) => [ $ . _target_url_line ] ,
1718
@@ -51,6 +52,21 @@ module.exports = grammar({
5152 LINE_TAIL ,
5253 ) ,
5354 ) ,
55+ var_comment : ( $ ) =>
56+ seq (
57+ $ . _comment_prefix ,
58+ token ( prec ( 2 , "@" ) ) ,
59+ field ( "name" , $ . identifier ) ,
60+ optional (
61+ seq (
62+ choice ( WS , "=" ) ,
63+ optional ( token ( prec ( 1 , WS ) ) ) ,
64+ field ( "value" , $ . value ) ,
65+ ) ,
66+ ) ,
67+ NL ,
68+ ) ,
69+
5470 request_separator : ( $ ) =>
5571 seq (
5672 token ( prec ( 3 , / # # # + \p{ Zs} * / ) ) ,
@@ -71,16 +87,21 @@ module.exports = grammar({
7187 // NOTE: grammatically, each request section should contain only single `$.request` node
7288 // we are allowing multiple `$.request` nodes here to lower the parser size
7389 _section_content : ( $ ) =>
74- repeat1 (
75- choice (
76- $ . _blank_line ,
77- $ . comment ,
78- $ . variable_declaration ,
79- $ . pre_request_script ,
90+ choice (
91+ seq ( $ . _blank_line , $ . _section_content ) ,
92+ seq ( $ . comment , $ . _section_content ) ,
93+ seq ( $ . variable_declaration , $ . _section_content ) ,
94+ seq ( $ . pre_request_script , $ . _section_content ) ,
95+ seq (
8096 // field to easily find request node in each section
8197 field ( "request" , $ . request ) ,
82- $ . res_handler_script ,
83- )
98+ repeat (
99+ choice (
100+ seq ( alias ( $ . var_comment , $ . comment ) , repeat ( NL ) ) ,
101+ seq ( $ . res_handler_script , repeat ( NL ) ) ,
102+ ) ,
103+ ) ,
104+ ) ,
84105 ) ,
85106
86107 // LIST http verb is arbitrary and required to use vaultproject
@@ -126,7 +147,8 @@ module.exports = grammar({
126147 optional (
127148 seq (
128149 repeat1 ( $ . _blank_line ) ,
129- repeat ( $ . comment ) ,
150+ // repeat($.comment),
151+ repeat ( alias ( $ . var_comment , $ . comment ) ) ,
130152 optional (
131153 field ( "body" , choice (
132154 $ . raw_body ,
0 commit comments