@@ -30,7 +30,7 @@ module.exports = grammar({
3030 [ $ . _raw_body ] ,
3131 [ $ . _section_content ] ,
3232 ] ,
33- inline : ( $ ) => [ $ . _target_url_line ] ,
33+ inline : ( $ ) => [ $ . _target_url_line , $ . __body ] ,
3434
3535 rules : {
3636 document : ( $ ) => repeat ( $ . section ) ,
@@ -43,28 +43,19 @@ module.exports = grammar({
4343 COMMENT_PREFIX : ( _ ) => COMMENT_PREFIX ,
4444
4545 comment : ( $ ) =>
46+ choice (
47+ $ . _plain_comment ,
48+ $ . _var_comment ,
49+ ) ,
50+ _plain_comment : ( _ ) =>
4651 seq (
4752 COMMENT_PREFIX ,
48- choice (
49- seq (
50- token ( prec ( 2 , "@" ) ) ,
51- field ( "name" , $ . identifier ) ,
52- optional (
53- seq (
54- choice ( WS , "=" ) ,
55- optional ( token ( prec ( 1 , WS ) ) ) ,
56- field ( "value" , $ . value ) ,
57- ) ,
58- ) ,
59- NL ,
60- ) ,
61- LINE_TAIL ,
62- ) ,
53+ LINE_TAIL ,
6354 ) ,
64- var_comment : ( $ ) =>
55+ _var_comment : ( $ ) =>
6556 seq (
6657 COMMENT_PREFIX ,
67- token ( prec ( 2 , "@" ) ) ,
58+ token ( prec ( PREC . VAR_COMMENT_PREFIX , "@" ) ) ,
6859 field ( "name" , $ . identifier ) ,
6960 optional (
7061 seq (
@@ -100,10 +91,9 @@ module.exports = grammar({
10091 seq ( $ . comment , optional ( $ . _section_content ) ) ,
10192 seq ( $ . variable_declaration , optional ( $ . _section_content ) ) ,
10293 seq ( $ . pre_request_script , optional ( $ . _section_content ) ) ,
103- seq (
104- // field to easily find request node in each section
105- field ( "request" , $ . request ) ,
106- ) ,
94+ // field to easily find request node in each section
95+ field ( "request" , $ . request ) ,
96+ field ( "response" , $ . response ) ,
10797 ) ,
10898
10999 // LIST http verb is arbitrary and required to use vaultproject
@@ -120,14 +110,43 @@ module.exports = grammar({
120110 status_code : ( _ ) => / [ 1 - 5 ] \d { 2 } / ,
121111 status_text : ( _ ) =>
122112 / ( C o n t i n u e | S w i t c h i n g P r o t o c o l s | P r o c e s s i n g | O K | C r e a t e d | A c c e p t e d | N o n - A u t h o r i t a t i v e I n f o r m a t i o n | N o C o n t e n t | R e s e t C o n t e n t | P a r t i a l C o n t e n t | M u l t i - S t a t u s | A l r e a d y R e p o r t e d | I M U s e d | M u l t i p l e C h o i c e s | M o v e d P e r m a n e n t l y | F o u n d | S e e O t h e r | N o t M o d i f i e d | U s e P r o x y | S w i t c h P r o x y | T e m p o r a r y R e d i r e c t | P e r m a n e n t R e d i r e c t | B a d R e q u e s t | U n a u t h o r i z e d | P a y m e n t R e q u i r e d | F o r b i d d e n | N o t F o u n d | M e t h o d N o t A l l o w e d | N o t A c c e p t a b l e | P r o x y A u t h e n t i c a t i o n R e q u i r e d | R e q u e s t T i m e o u t | C o n f l i c t | G o n e | L e n g t h R e q u i r e d | P r e c o n d i t i o n F a i l e d | P a y l o a d T o o L a r g e | U R I T o o L o n g | U n s u p p o r t e d M e d i a T y p e | R a n g e N o t S a t i s f i a b l e | E x p e c t a t i o n F a i l e d | I ' m a t e a p o t | M i s d i r e c t e d R e q u e s t | U n p r o c e s s a b l e E n t i t y | L o c k e d | F a i l e d D e p e n d e n c y | T o o E a r l y | U p g r a d e R e q u i r e d | P r e c o n d i t i o n R e q u i r e d | T o o M a n y R e q u e s t s | R e q u e s t H e a d e r F i e l d s T o o L a r g e | U n a v a i l a b l e F o r L e g a l R e a s o n s | I n t e r n a l S e r v e r E r r o r | N o t I m p l e m e n t e d | B a d G a t e w a y | S e r v i c e U n a v a i l a b l e | G a t e w a y T i m e o u t | H T T P V e r s i o n N o t S u p p o r t e d | V a r i a n t A l s o N e g o t i a t e s | I n s u f f i c i e n t S t o r a g e | L o o p D e t e c t e d | N o t E x t e n d e d | N e t w o r k A u t h e n t i c a t i o n R e q u i r e d ) / ,
123- response : ( $ ) =>
113+ __body : ( $ ) =>
124114 seq (
125- $ . http_version ,
126- WS ,
127- $ . status_code ,
128- WS ,
129- optional ( $ . status_text ) ,
130- NL ,
115+ repeat1 ( $ . _blank_line ) ,
116+ prec . right (
117+ repeat (
118+ choice (
119+ alias ( $ . _var_comment , $ . comment ) ,
120+ field (
121+ "body" ,
122+ choice (
123+ $ . raw_body ,
124+ $ . multipart_form_data ,
125+ $ . xml_body ,
126+ $ . json_body ,
127+ $ . graphql_body ,
128+ $ . _external_body ,
129+ ) ,
130+ ) ,
131+ NL ,
132+ $ . res_handler_script ,
133+ $ . res_redirect ,
134+ ) ,
135+ ) ,
136+ ) ,
137+ ) ,
138+ response : ( $ ) =>
139+ prec . right (
140+ seq (
141+ $ . http_version ,
142+ WS ,
143+ $ . status_code ,
144+ WS ,
145+ optional ( $ . status_text ) ,
146+ NL ,
147+ repeat ( field ( "header" , $ . header ) ) ,
148+ optional ( $ . __body ) ,
149+ ) ,
131150 ) ,
132151
133152 request : ( $ ) =>
@@ -137,35 +156,13 @@ module.exports = grammar({
137156 field ( "url" , $ . target_url ) ,
138157 optional ( seq ( WS , field ( "version" , $ . http_version ) ) ) ,
139158 NL ,
140- repeat ( $ . comment ) ,
141- optional ( $ . response ) ,
142- repeat ( field ( "header" , $ . header ) ) ,
143- optional (
144- seq (
145- repeat1 ( $ . _blank_line ) ,
146- prec . right (
147- repeat (
148- choice (
149- alias ( $ . var_comment , $ . comment ) ,
150- field (
151- "body" ,
152- choice (
153- $ . raw_body ,
154- $ . multipart_form_data ,
155- $ . xml_body ,
156- $ . json_body ,
157- $ . graphql_body ,
158- $ . _external_body ,
159- ) ,
160- ) ,
161- NL ,
162- $ . res_handler_script ,
163- $ . res_redirect ,
164- ) ,
165- ) ,
166- ) ,
159+ repeat (
160+ choice (
161+ $ . comment ,
162+ field ( "header" , $ . header )
167163 ) ,
168164 ) ,
165+ optional ( $ . __body ) ,
169166 ) ,
170167 ) ,
171168
0 commit comments