Fork me on GitHub
#instaparse
<
2020-11-16
>
misha13:11:58

greetings! is there a way to specify "greedy" matches in the grammar (instead of the tree transforming) other than using inline regex-es? (insta/parse (insta/parser "S = 'a'+") "aaaa") to get => [:S "aaaa"] instead of: => [:S "a" "a" "a" "a"] my actual use case is: I have a bunch of rules wrapped in <> (for "documentation"), so the tags will not show up in output tree, so I'd line to have a single match string in the output (like "aaaaa"). I'd like to avoid tree transforming, because grammar is "up for extension" for someone else, and making sure they update transformers as well add a line to grammar - is extra point of potential failure

misha13:11:19

and inline regexes do not compose well at all:

<phrase> =    #'\w+(\s+\w+)*'
text     = #'\s*\w+(\s+\w+)*\s*'
instead of
<space>  = #'\s+'
<word>   = #'\w+'
<phrase> = word (space word)*
text     = space? phrase space?