本文整理汇总了C++中pANTLR3_LEXER::pushCharStream方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_LEXER::pushCharStream方法的具体用法?C++ pANTLR3_LEXER::pushCharStream怎么用?C++ pANTLR3_LEXER::pushCharStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pANTLR3_LEXER
的用法示例。
在下文中一共展示了pANTLR3_LEXER::pushCharStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newInputStream
static bool newInputStream(const std::string& filename, pANTLR3_LEXER lexer) {
Debug("parser") << "Including " << filename << std::endl;
// Create a new input stream and take advantage of built in stream stacking
// in C target runtime.
//
pANTLR3_INPUT_STREAM in;
#ifdef CVC4_ANTLR3_OLD_INPUT_STREAM
in = antlr3AsciiFileStreamNew((pANTLR3_UINT8) filename.c_str());
#else /* CVC4_ANTLR3_OLD_INPUT_STREAM */
in = antlr3FileStreamNew((pANTLR3_UINT8) filename.c_str(), ANTLR3_ENC_8BIT);
#endif /* CVC4_ANTLR3_OLD_INPUT_STREAM */
if( in == NULL ) {
Debug("parser") << "Can't open " << filename << std::endl;
return false;
}
// Same thing as the predefined PUSHSTREAM(in);
lexer->pushCharStream(lexer, in);
// restart it
//lexer->rec->state->tokenStartCharIndex = -10;
//lexer->emit(lexer);
// Note that the input stream is not closed when it EOFs, I don't bother
// to do it here, but it is up to you to track streams created like this
// and destroy them when the whole parse session is complete. Remember that you
// don't want to do this until all tokens have been manipulated all the way through
// your tree parsers etc as the token does not store the text it just refers
// back to the input stream and trying to get the text for it will abort if you
// close the input stream too early.
//TODO what said before
return true;
}