I want to ignore whitespaces and new lines with my grammar so they are missing in the PEG.js output. Also, a literal within brackets should be returned in a new array.
Grammar
start
= 'a'? sep+ ('cat'/'dog') sep* '(' sep* stmt_list sep* ')'
stmt_list
= exp: [a-zA-Z]+ { return new Array(exp.join('')) }
sep
= [' '\t\r\n]
Test case
a dog( Harry )
Output
[
"a",
[
" "
],
"dog",
[],
"(",
[
" "
],
[
"Harry"
],
[
" "
],
")"
]
Output I want
[
"a",
"dog",
[
"Harry"
]
]