I am trying to allow double quotation marks into my grammar's functions. I was hoping that I could use Haskell conventions to generate something like:
> mkSentence "This is \"just\" a sentence"
> This is "just" a sentence
However, when I try this in my grammar, I am faced with errors like in the example below using the English RGL:
> cc -table ss "This is \"just\" a sentence"
constant not found: just
given Predef, Predef, CatEng, ResEng, MorphoEng, Prelude,
ParadigmsEng
A function type is expected for ss "This is " instead of type {s : Str}
0 msec
> cc -table ss "This is \"just a sentence"
lexical error
0 msec
I can see that src/common/ExtendFunctor.gf
in the RGL has an implementation of quoted
:
oper
quoted : Str -> Str = \s -> "\"" ++ s ++ "\"" ; ---- TODO bind ; move to Prelude?
I have tried to implement something similar, but "
may be used in different parts of my grammar, so ideally the double quotation marks could be escaped without special binds. I am considering defaulting to ”
to avoid the issues with "
, but maybe there is a way to escape double quotation marks "everywhere" (like in these docs)?
Any tips or reference to other docs would be very appreciated!