New to Nearley grammar, not sure what is going wrong here. Here is my grammar to get whatever is placed inside an opening and closing parenthesis.
@builtin "whitespace.ne"
with_in_brackets ->
"(" _ args _ ")" {% d => ({
type: 'inside_brackets',
argumentstring: d[2]
})%}
args -> .:* {% d => d[0].join("") %}
(hello, " ", world){type: "inside_brackets", argumentstring: "hello, " ", world"}{type: "inside_brackets", argumentstring: "hello, " ", world"}Notice - the actual result is compacting 4 whitespaces to 1 whitespace. Not sure why this is happening.
Any thoughts? FYI - I am using Nearley Playground to test my grammer on Safari v15 browser.