for now no escaping comment
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
7a3c98ac76
commit
c34df2ccaa
21
corpus/extras.txt
Normal file
21
corpus/extras.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
===
|
||||||
|
Comments
|
||||||
|
===
|
||||||
|
|
||||||
|
GET https://somewhere.com # some comment
|
||||||
|
# comment
|
||||||
|
|
||||||
|
HTTP 200 # comment
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(request_declaration
|
||||||
|
(request_literal)
|
||||||
|
(url))
|
||||||
|
(comment)
|
||||||
|
(comment)
|
||||||
|
(response
|
||||||
|
(scheme_literal)
|
||||||
|
(status_code_pattern))
|
||||||
|
(comment))
|
@ -47,7 +47,7 @@ More Headers
|
|||||||
|
|
||||||
POST https://somewhere.com?query=something
|
POST https://somewhere.com?query=something
|
||||||
some: header
|
some: header
|
||||||
A123a-123: someA asdfasdf asdf c123
|
A123a-123: someAasdfasdfasdfc123
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -55,9 +55,13 @@ A123a-123: someA asdfasdf asdf c123
|
|||||||
(request_declaration
|
(request_declaration
|
||||||
(request_literal)
|
(request_literal)
|
||||||
(url))
|
(url))
|
||||||
(header_declaration
|
(header_declaration
|
||||||
(header_name)
|
(header_name)
|
||||||
(header_value)))
|
(header_value))
|
||||||
|
(header_declaration
|
||||||
|
(header_name)
|
||||||
|
(header_value))
|
||||||
|
)
|
||||||
|
|
||||||
===
|
===
|
||||||
HTTP Status codes 200
|
HTTP Status codes 200
|
||||||
@ -92,3 +96,23 @@ HTTP 302
|
|||||||
(response
|
(response
|
||||||
(scheme_literal)
|
(scheme_literal)
|
||||||
(status_code_pattern)))
|
(status_code_pattern)))
|
||||||
|
|
||||||
|
===
|
||||||
|
HTTP Status codes 302
|
||||||
|
===
|
||||||
|
|
||||||
|
POST https://somewhere.com?query=something
|
||||||
|
Header: something
|
||||||
|
HTTP 302
|
||||||
|
---
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(request_declaration
|
||||||
|
(request_literal)
|
||||||
|
(url))
|
||||||
|
(header_declaration
|
||||||
|
(header_name)
|
||||||
|
(header_value))
|
||||||
|
(response
|
||||||
|
(scheme_literal)
|
||||||
|
(status_code_pattern)))
|
||||||
|
14
grammar.js
14
grammar.js
@ -1,6 +1,11 @@
|
|||||||
module.exports = grammar({
|
module.exports = grammar({
|
||||||
name: "hurl",
|
name: "hurl",
|
||||||
|
|
||||||
|
extras: $ => [
|
||||||
|
$.comment,
|
||||||
|
/\s/
|
||||||
|
],
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
source_file: ($) => repeat($._statement),
|
source_file: ($) => repeat($._statement),
|
||||||
|
|
||||||
@ -28,7 +33,7 @@ module.exports = grammar({
|
|||||||
field("header_value", $.header_value)
|
field("header_value", $.header_value)
|
||||||
),
|
),
|
||||||
|
|
||||||
http_response_declaration: $ => seq($.scheme_literal, $._space_literal, $.status_code_pattern),
|
http_response_declaration: $ => seq($.scheme_literal, $.status_code_pattern),
|
||||||
|
|
||||||
// literals
|
// literals
|
||||||
|
|
||||||
@ -55,14 +60,15 @@ module.exports = grammar({
|
|||||||
|
|
||||||
scheme_literal: $ => "HTTP",
|
scheme_literal: $ => "HTTP",
|
||||||
|
|
||||||
_space_literal: $ => " ",
|
|
||||||
|
|
||||||
// patterns
|
// patterns
|
||||||
|
|
||||||
|
comment: $ => token(prec(-10, /#.*/)),
|
||||||
|
|
||||||
|
|
||||||
status_code_pattern: $ => /[\d]{3}/,
|
status_code_pattern: $ => /[\d]{3}/,
|
||||||
header_name: ($) => /[a-zA-Z-_0-9]+/,
|
header_name: ($) => /[a-zA-Z-_0-9]+/,
|
||||||
header_value: ($) =>
|
header_value: ($) =>
|
||||||
/[a-zA-Z-_0-9\s:;\.,\\\/\"\'\?\!\(\)\{\}\[\]@<>=\-\+\*\#\$\&`|~^%]+/,
|
/[a-zA-Z\-_0-9\/\\]+/,
|
||||||
|
|
||||||
url: ($) => /\S+/,
|
url: ($) => /\S+/,
|
||||||
},
|
},
|
||||||
|
@ -88,10 +88,6 @@
|
|||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "scheme_literal"
|
"name": "scheme_literal"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_space_literal"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "status_code_pattern"
|
"name": "status_code_pattern"
|
||||||
@ -176,9 +172,16 @@
|
|||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "HTTP"
|
"value": "HTTP"
|
||||||
},
|
},
|
||||||
"_space_literal": {
|
"comment": {
|
||||||
"type": "STRING",
|
"type": "TOKEN",
|
||||||
"value": " "
|
"content": {
|
||||||
|
"type": "PREC",
|
||||||
|
"value": -10,
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "#.*"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"status_code_pattern": {
|
"status_code_pattern": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
@ -190,7 +193,7 @@
|
|||||||
},
|
},
|
||||||
"header_value": {
|
"header_value": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[a-zA-Z-_0-9\\s:;\\.,\\\\\\/\\\"\\'\\?\\!\\(\\)\\{\\}\\[\\]@<>=\\-\\+\\*\\#\\$\\&`|~^%]+"
|
"value": "[a-zA-Z\\-_0-9\\/\\\\]+"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
@ -198,6 +201,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extras": [
|
"extras": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "comment"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "\\s"
|
"value": "\\s"
|
||||||
|
@ -162,6 +162,10 @@
|
|||||||
"type": "VIEW",
|
"type": "VIEW",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "comment",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "header_name",
|
"type": "header_name",
|
||||||
"named": true
|
"named": true
|
||||||
|
1062
src/parser.c
1062
src/parser.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user