I am writing a syntax checker for a new language using the clang front-end. I have added some keywords and some grammar rules, but I don't know how to invoke the tools down to the level of parsing only. I am merely interested in checking the correctness of syntax at the moment.
I tried ParseAST(), but that returns a NULL pointer for the new type definitions, since their semantics are not defined. What other option do I have?
I would appreciate your kind help.
You could use clang’s -fsyntax-only command-line argument to perform only syntactic and semantic analysis steps. There are some other tips here:
So basically I need to add the semantics and AST nodes for my new expression as well, because -“fsyntax-only” uses those.
I read somewhere that adding an attribute has the advantage of propagating through the code, and I might not therefore need to add AST support. Is that right? In general would it be easier to accomplish syntax checking by adding some attributes?
Thanks for you help,