chore: bruno lang improve parsing logic of headers and params

This commit is contained in:
Anoop M D 2023-01-15 05:04:35 +05:30
parent 5e1d6cba4a
commit c29ab50a3d
2 changed files with 10 additions and 25 deletions

View File

@ -15,25 +15,18 @@ const {
const newline = regex(/^\r?\n/);
const newLineOrEndOfInput = choice([newline, endOfInput]);
const begin = sequenceOf([
regex(/^headers[^\S\r\n]*/),
newline
]);
const end = sequenceOf([
regex(/^\/headers[^\S\r\n]*/),
newLineOrEndOfInput
]);
const key = everyCharUntil(whitespace);
const value = everyCharUntil(whitespace);
const begin = regex(/^headers\s*\r?\n/);
const end = regex(/^[\r?\n]*\/headers\s*[\r?\n]*/);
const word = regex(/^[^\s\t\n]+/g);
const line = sequenceOf([
optionalWhitespace,
digit,
whitespace,
key,
word,
whitespace,
value,
word,
newLineOrEndOfInput
]).map(([_, enabled, __, key, ___, value]) => {
return {

View File

@ -15,25 +15,17 @@ const {
const newline = regex(/^\r?\n/);
const newLineOrEndOfInput = choice([newline, endOfInput]);
const begin = sequenceOf([
regex(/^params[^\S\r\n]*/),
newline
]);
const end = sequenceOf([
regex(/^\/params[^\S\r\n]*/),
newLineOrEndOfInput
]);
const key = everyCharUntil(whitespace);
const value = everyCharUntil(whitespace);
const begin = regex(/^params\s*\r?\n/);
const end = regex(/^[\r?\n]*\/params\s*[\r?\n]*/);
const word = regex(/^[^\s\t\n]+/g);
const line = sequenceOf([
optionalWhitespace,
digit,
whitespace,
key,
word,
whitespace,
value,
word,
newLineOrEndOfInput
]).map(([_, enabled, __, key, ___, value]) => {
return {