I want to parse a GraphQL document using Dart PetitParser. To be able to support BlockString (multi-line string) I'm looking for a way to get
from
"""
abc
\"""
def
"""
this part out
abc
\"""
def
Full syntax https://facebook.github.io/graphql/draft/#sec-String-Value
I am on a mobile Phone and I don't have a computer to test, but something along these lines should work:
string('"""') & (string(r'\"""') | any()).starLazy(string('"""')) & string('"""')
This parses the triple quotes, followed by any sequence of the escaped triple quotes or other characters, until we reach the ending triple quotes. Possibly you want to also add a .flatten()
to the inner part to get a plain string as return value.