[cfe-dev] RFC: YAML as an intermediate format for clang::tooling::Replacement data on disk

Sean Silva silvas at purdue.edu
Thu Aug 1 13:11:25 PDT 2013


On Thu, Aug 1, 2013 at 7:00 AM, Vane, Edwin <edwin.vane at intel.com> wrote:

>
>
> > -----Original Message-----
> > From: Manuel Klimek [mailto:klimek at google.com]
> > Sent: Thursday, August 01, 2013 9:40 AM
> > To: Vane, Edwin
> > Cc: Alex Rosenberg; Clang Dev List (cfe-dev at cs.uiuc.edu)
> > Subject: Re: [cfe-dev] RFC: YAML as an intermediate format for
> > clang::tooling::Replacement data on disk
>
> ...
>
> > Note that the compilation databases use the YAML parser. JSON is a
> subset of
> > YAML. I'd also (slightly) prefer to use JSON over YAML for the
> intermediate
> > representation.
>
> Is it enough to hard-code the output into JSON format


Unfortunately YAMLIO doesn't support JSON-formatted output. I had a brief
interchange with Nick Kledzik about this a while back, and he seemed to
have a pretty clear idea of how to cleanly and "properly" implement this
within the YAMLIO framework, but it seemed like it would still require some
dedicated work before becoming a reality.

TBH, outputting JSON isn't that hard really. I believe we already have
somewhere in LLVM that does this. The most complicated part is probably
escaping strings, which is basically just the "usual" (C-like) escapes.
Probably a single function `writeAsEscapedJSONString(raw_ostream &OS,
StringRef Str)` would be all the "abstraction" you need.


> and just use the YAML parser for reading? Or should we aim for a general
> purpose JSON reader/writer as with YAML in LLVM? Either way, I think the
> general purpose parser is beyond scope for what we want to achieve at this
> time with the migrator.
>

As Manuel already pointed out, YAML is a superset of JSON, so the YAML
parser serves as a perfectly adequate JSON parser (YAMLIO should also work
fine for the reading side as well).

-- Sean Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130801/fdc66d31/attachment.html>


More information about the cfe-dev mailing list