[cfe-dev] RFC: Extend clang-format to support more/all C-like languages

Chandler Carruth chandlerc at google.com
Fri Nov 1 13:02:08 PDT 2013


On Fri, Nov 1, 2013 at 11:12 AM, Chris Lattner <clattner at apple.com> wrote:

> This sounds pretty interesting to me.  The only concern I would have is
> that we don't want Clang's lexer to have to become a "Grand unified lexer
> for all languages".  The token rules of languages in these families are
> related, but different.  Would it be better to have clang-format support
> using multiple different lexers?


Daniel should give the definitive answer, but my feeling is that the
interesting commonality with all of these languages is that the lexing
rules (both token and comment) are more similar than different.

The Clang lexer is *really* nice, and I wouldn't want to see us ending up
with hand written lexers that largely duplicate the interesting logic of
Clang's.

I would suggest waiting to see. Essentially, if we try this out, and we end
up with a big or ugly patch to the lexer than doesn't very cleanly factor
out a minor difference for a particular language, then that'll be the sign
that we need to have a separate lexer and abstract across them in
clang-format. Until then, we re-use the existing lexer and make the minor
extensions needed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131101/ec79f58c/attachment.html>


More information about the cfe-dev mailing list