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
|
||||
some: header
|
||||
A123a-123: someA asdfasdf asdf c123
|
||||
A123a-123: someAasdfasdfasdfc123
|
||||
|
||||
---
|
||||
|
||||
@ -55,9 +55,13 @@ A123a-123: someA asdfasdf asdf c123
|
||||
(request_declaration
|
||||
(request_literal)
|
||||
(url))
|
||||
(header_declaration
|
||||
(header_name)
|
||||
(header_value)))
|
||||
(header_declaration
|
||||
(header_name)
|
||||
(header_value))
|
||||
(header_declaration
|
||||
(header_name)
|
||||
(header_value))
|
||||
)
|
||||
|
||||
===
|
||||
HTTP Status codes 200
|
||||
@ -92,3 +96,23 @@ HTTP 302
|
||||
(response
|
||||
(scheme_literal)
|
||||
(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({
|
||||
name: "hurl",
|
||||
|
||||
extras: $ => [
|
||||
$.comment,
|
||||
/\s/
|
||||
],
|
||||
|
||||
rules: {
|
||||
source_file: ($) => repeat($._statement),
|
||||
|
||||
@ -28,7 +33,7 @@ module.exports = grammar({
|
||||
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
|
||||
|
||||
@ -55,14 +60,15 @@ module.exports = grammar({
|
||||
|
||||
scheme_literal: $ => "HTTP",
|
||||
|
||||
_space_literal: $ => " ",
|
||||
|
||||
// patterns
|
||||
|
||||
comment: $ => token(prec(-10, /#.*/)),
|
||||
|
||||
|
||||
status_code_pattern: $ => /[\d]{3}/,
|
||||
header_name: ($) => /[a-zA-Z-_0-9]+/,
|
||||
header_value: ($) =>
|
||||
/[a-zA-Z-_0-9\s:;\.,\\\/\"\'\?\!\(\)\{\}\[\]@<>=\-\+\*\#\$\&`|~^%]+/,
|
||||
/[a-zA-Z\-_0-9\/\\]+/,
|
||||
|
||||
url: ($) => /\S+/,
|
||||
},
|
||||
|
@ -88,10 +88,6 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "scheme_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_space_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "status_code_pattern"
|
||||
@ -176,9 +172,16 @@
|
||||
"type": "STRING",
|
||||
"value": "HTTP"
|
||||
},
|
||||
"_space_literal": {
|
||||
"type": "STRING",
|
||||
"value": " "
|
||||
"comment": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "PREC",
|
||||
"value": -10,
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "#.*"
|
||||
}
|
||||
}
|
||||
},
|
||||
"status_code_pattern": {
|
||||
"type": "PATTERN",
|
||||
@ -190,7 +193,7 @@
|
||||
},
|
||||
"header_value": {
|
||||
"type": "PATTERN",
|
||||
"value": "[a-zA-Z-_0-9\\s:;\\.,\\\\\\/\\\"\\'\\?\\!\\(\\)\\{\\}\\[\\]@<>=\\-\\+\\*\\#\\$\\&`|~^%]+"
|
||||
"value": "[a-zA-Z\\-_0-9\\/\\\\]+"
|
||||
},
|
||||
"url": {
|
||||
"type": "PATTERN",
|
||||
@ -198,6 +201,10 @@
|
||||
}
|
||||
},
|
||||
"extras": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "comment"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "\\s"
|
||||
|
@ -162,6 +162,10 @@
|
||||
"type": "VIEW",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "header_name",
|
||||
"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