extend Clang parser.

Hi everyone

I am new to Clang, but I am trying to support the following syntax on variable declaration for a given language.

int a : qualifier;

float f(int x : qualifier) : qualifier
{

}

for qualifier a single word without spaces

Which is the best way to approach?

I see that there is an ASTConsumer, but didnt found any ParserConsumer, is there anything similar?

Hi everyone

I am new to Clang, but I am trying to support the following syntax on variable declaration for a given language.

int a : qualifier;

You may find this difficult due to ambiguities (bitfields and range based for loop) with existing c++syntax…

float f(int x : qualifier) : qualifier
{

}

for qualifier a single word without spaces

Which is the best way to approach?

I see that there is an ASTConsumer, but didnt found any ParserConsumer, is there anything similar?

Not really. Clang isn’t designed to allow pluggable arbitrary language extensions. Astconsumers are just for pluggable language consumers, they don’t get to change the language.

If you’re changing the language you’re going to have to change clang’s parsing and sema layers directly.