I am trying to write a parser for a delimited content, which content specifies the delimiting character, i.e.:
{{delimited;:Name,heading1,heading2}}
1;2;3;4
{{/delimited}}
So I got this to match the start and extract the delimiter
def csvStart: Parser[CsvHeading] = "{{delimited" ~> """.""".r ~ ":".r ~ """[^:]*""".r ~ opt(":".r ~ csvHeadings) <~ "}}" ^^ {
case delim ~ _ ~ what ~ Some(head) => …
Now – having the delimiter – how do I use it to build the NEXT parsers? Here’s the overall parser – don’t know how to make it dynamic:
def csvContent: PS = csvStart ~ csv(";") ~ csvEnd ^^ {
note the csv(“;”) which builds the content parser for the given delimiter… I need something that looks back at the result of the previous parser (csvStart) and extracts the delimiter from that result…
what to do? what to do? (insert hair pulling frowney).
Thanks,
Razie