你怎么能添加一个新的关键字铛,将被视为主要的关键字? [英] How can you add a new keyword to clang, a keyword that would be treated as main?
问题描述
如何一个新的关键字加入到铛?新的关键字应该是一个函数限定符。会在哪里声明部分去了?
How can a new keyword be added to clang? The new keyword should be a function qualifier. Where would the declaration part go?
感谢。
推荐答案
您必须将其添加到包含/铛/基本/ TokenKinds.def,然后添加一个新的情况ParseDeclarationSpecifiers(...)。
You have to add it to include/clang/Basic/TokenKinds.def, and then add a new case to ParseDeclarationSpecifiers(...).
也许更容易的选择是定义一个新的属性,然后使用
Probably an easier option would be to define a new attribute, and then use
的#define your_new_qualifier __attribute __((your_new_attribute))
否则你不得不加入到AST,这可能是容易出错的这个预选赛的支持,而属性在相同功能的各种声明的自动传播。
Otherwise you'd have to add this qualifier support to the AST, which could be error-prone, whereas attributes are propagated automatically across various declarations of the same function.
这篇关于你怎么能添加一个新的关键字铛,将被视为主要的关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!