本文整理汇总了C++中RefAST类的典型用法代码示例。如果您正苦于以下问题:C++ RefAST类的具体用法?C++ RefAST怎么用?C++ RefAST使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RefAST类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFirstChild
void BinaryCompArithOpAST::renameAttrRef(const SchemaMapString* schemaMap) {
RefAST childAST = getFirstChild();
assert (childAST);
(RefBasicAST(childAST))->renameAttrRef(schemaMap);
if (childAST->getNextSibling()) {
(RefBasicAST(childAST->getNextSibling()))->renameAttrRef(schemaMap);
}
}
示例2: main
int main(int argc, char *argv[])
{
if (argc < 1)
return 0;
ANTLR_USING_NAMESPACE(std);
ANTLR_USING_NAMESPACE(antlr);
ANTLR_USING_NAMESPACE(Asm);
char *filename = argv[1];
if (!filename)
exit(1);
try {
ifstream input(filename);
AsmLexer lexer(input);
TokenBuffer buffer(lexer);
AsmParser parser(buffer);
ASTFactory ast_factory;
parser.initializeASTFactory(ast_factory);
parser.setASTFactory(&ast_factory);
parser.asmFile();
RefAST a = parser.getAST();
AsmTreeParser tree_parser;
tree_parser.init(false, false, false);
tree_parser.initializeASTFactory(ast_factory);
tree_parser.setASTFactory(&ast_factory);
tree_parser.asmFile(a);
#if 0
cout << "List:" << endl;
cout << a->toStringList() << endl;
cout << "Tree:" << endl;
cout << a->toStringTree() << endl;
#endif
} catch (ANTLRException& e) {
cerr << "exception: " << e.getMessage() << endl;
return 2;
} catch (exception& e) {
cerr << "exception: " << e.what() << endl;
return 3;
}
return 0;
}
示例3: matchNot
void TreeParser::matchNot(RefAST t, int ttype)
{
//ANTLR_USE_NAMESPACE(std)cout << "match(" << ttype << "); cursor is " << t.toString() << ANTLR_USE_NAMESPACE(std)endl;
if ( !t || t==ASTNULL || t->getType()==ttype ) {
throw MismatchedTokenException();
}
}
示例4: RecognitionException
// Expected BitSet / not BitSet
MismatchedTokenException::MismatchedTokenException(
const char* const* tokenNames_,
const int numTokens_,
RefAST node_,
BitSet set_,
bool matchNot
) : RecognitionException("Mismatched Token","<AST>",-1,-1)
, token(0)
, node(node_)
, tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) )
, mismatchType(matchNot ? NOT_SET : SET)
, set(set_)
, tokenNames(tokenNames_)
, numTokens(numTokens_)
{
}
示例5: create
/** Create a new empty AST node; if the user did not specify
* an AST node type, then create a default one: CommonAST.
*/
RefAST ASTFactory::create()
{
RefAST node = nodeFactories[0]->second();
node->setType(Token::INVALID_TYPE);
return node;
}
示例6: match
/**Make sure current lookahead symbol matches the given set
* Throw an exception upon mismatch, which is caught by either the
* error handler or by the syntactic predicate.
*/
void TreeParser::match(RefAST t, const BitSet& b)
{
if ( !t || t==ASTNULL || !b.member(t->getType()) ) {
throw MismatchedTokenException();
}
}
示例7: create
RefAST ASTFactory::create(int type)
{
RefAST t = create();
t->initialize(type,"");
return t;
}
示例8: nodeFactory
/** Create a new empty AST node; if the user did not specify
* an AST node type, then create a default one: CommonAST.
*/
RefAST ASTFactory::create()
{
RefAST node = nodeFactory(); //new CommonASTNode();
node->setType(Token::INVALID_TYPE);
return node;
}
示例9: matchNot
void TreeParser::matchNot(RefAST t, int ttype)
{
if ( !t || t == ASTNULL || t->getType() == ttype )
throw MismatchedTokenException( getTokenNames(), getNumTokens(),
t, ttype, true );
}
示例10: match
/** Make sure current lookahead symbol matches the given set
* Throw an exception upon mismatch, which is caught by either the
* error handler or by the syntactic predicate.
*/
void TreeParser::match(RefAST t, const BitSet& b)
{
if ( !t || t==ASTNULL || !b.member(t->getType()) )
throw MismatchedTokenException( getTokenNames(), getNumTokens(),
t, b, false );
}
示例11: match
virtual void match(RefAST t, int ttype)
{
if (!t || t == ASTNULL || t->getType() != ttype )
throw MismatchedTokenException( getTokenNames(), getNumTokens(),
t, ttype, false );
}
示例12: while
while( t->right )
{
t = t->right;
n++;
}
return n;
}
return n;
}
void BaseAST::doWorkForFindAll(
ANTLR_USE_NAMESPACE(std)vector<RefAST>& v,
RefAST target,bool partialMatch)
{
// Start walking sibling lists, looking for matches.
for (RefAST sibling=this;
sibling;
sibling=sibling->getNextSibling())
{
if ( (partialMatch && sibling->equalsTreePartial(target)) ||
(!partialMatch && sibling->equalsTree(target)) ) {
v.push_back(sibling);
}
// regardless of match or not, check any children for matches
if ( sibling->getFirstChild() ) {
RefBaseAST(sibling->getFirstChild())->doWorkForFindAll(v, target, partialMatch);
}
}
}
/** Is t an exact structural and equals() match of this tree. The
示例13: initialize
void CommonAST::initialize(RefAST t)
{
setType(t->getType());
setText(t->getText());
}