[cfe-dev] Lenient lexing/parsing of code snippets

Guilherme guibufolo at gmail.com
Sun Dec 7 06:21:07 PST 2014


Take a look a this interesting summer of code project. I think it goes
into the same direction as yours, flexible parsing of incomplete code.

https://www.google-melange.com/gsoc/project/details/google/gsoc2014/kapf/5643440998055936

On Sun, Dec 7, 2014 at 10:55 AM, David Chisnall
<David.Chisnall at cl.cam.ac.uk> wrote:
> On 7 Dec 2014, at 02:55, Will Hawkins <whh8b at virginia.edu> wrote:
>
>> I'm trying to use cfe to lex/parse code snippets. The snippets will be
>> complete functions but they will be taken mostly out of their original
>> context. I'd like to generate an AST for the code
>
> This problem doesn't sound possible.  When you have a code snippet taken out of any context, then you have no information about the types of any variable (or the definition of most of the types).  This makes constructing an AST impossible (you don't say what language you're using, but if it's C++ then you don't even know from a snippet whether a+b is an arithmetic operation or a method invocation, even if it's C, then you don't know what the type promotion should be).
>
> I think, to answer the question that you want to be asking, we need to know what you want to do with the AST.
>
> David
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list