feat: add http response codes
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
34
grammar.js
34
grammar.js
@@ -10,10 +10,27 @@ module.exports = grammar({
|
||||
choice($._declaration_statement),
|
||||
|
||||
_declaration_statement: ($) =>
|
||||
choice($.request_declaration),
|
||||
choice(
|
||||
$.request_declaration,
|
||||
$.header_declaration,
|
||||
alias($.http_response_declaration, $.response),
|
||||
),
|
||||
|
||||
// declarations
|
||||
|
||||
request_declaration: ($) =>
|
||||
seq($._literal, field("url", $._url)),
|
||||
seq($._literal, field("url", $.url)),
|
||||
|
||||
header_declaration: ($) =>
|
||||
seq(
|
||||
field("header_name", $.header_name),
|
||||
":",
|
||||
field("header_value", $.header_value)
|
||||
),
|
||||
|
||||
http_response_declaration: $ => seq($.scheme_literal, $._space_literal, $.status_code_pattern),
|
||||
|
||||
// literals
|
||||
|
||||
_literal: ($) => choice($.request_literal),
|
||||
|
||||
@@ -36,6 +53,17 @@ module.exports = grammar({
|
||||
"VIEW"
|
||||
),
|
||||
|
||||
_url: ($) => /\S+/,
|
||||
scheme_literal: $ => "HTTP",
|
||||
|
||||
_space_literal: $ => " ",
|
||||
|
||||
// patterns
|
||||
|
||||
status_code_pattern: $ => /[\d]{3}/,
|
||||
header_name: ($) => /[a-zA-Z-_0-9]+/,
|
||||
header_value: ($) =>
|
||||
/[a-zA-Z-_0-9\s:;\.,\\\/\"\'\?\!\(\)\{\}\[\]@<>=\-\+\*\#\$\&`|~^%]+/,
|
||||
|
||||
url: ($) => /\S+/,
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user