コード例 #1
0
parserDefinition * CppParser (void)
{
	static const char * const extensions [] =
	{
		"c++", "cc", "cp", "cpp", "cxx",
		"h", "h++", "hh", "hp", "hpp", "hxx", "inl",
#ifndef CASE_INSENSITIVE_FILENAMES
		"C", "H", "CPP", "CXX",
#endif
		NULL
	};
	static parserDependency dependencies [] = {
		{ DEPTYPE_KIND_OWNER, "C" },
	};

	static selectLanguage selectors[] = { selectByObjectiveCKeywords, NULL };

	parserDefinition* def = parserNew("C++");

	def->dependencies = dependencies;
	def->dependencyCount = ARRAY_SIZE (dependencies);
	def->kinds = cxxTagGetCPPKindOptions();
	def->kindCount = cxxTagGetCPPKindOptionCount();
	def->fieldSpecs = cxxTagGetCPPFieldSpecifiers();
	def->fieldSpecCount = cxxTagGetCPPFieldSpecifierCount();
	def->extensions = extensions;
	def->parser2 = cxxCppParserMain;
	def->initialize = cxxCppParserInitialize;
	def->finalize = cxxParserCleanup;
	def->selectLanguage = selectors;
	def->useCork = true; // We use corking to block output until the end of file

	return def;
}
コード例 #2
0
ファイル: cxx_parser.c プロジェクト: Sirlsliang/ctags
static rescanReason cxxParserMain(const unsigned int passCount)
{
	cxxScopeClear();
	cxxTokenAPINewFile();
	cxxParserNewStatement();

	kindOption * kind_for_define = cxxTagGetKindOptions() + CXXTagKindMACRO;
	kindOption * kind_for_header = cxxTagGetKindOptions() + CXXTagKindINCLUDE;
	int role_for_macro_undef = CR_MACRO_UNDEF;
	int role_for_header_system = CR_HEADER_SYSTEM;
	int role_for_header_local = CR_HEADER_LOCAL;
	int end_field_type = cxxParserCurrentLanguageIsCPP()?
		cxxTagGetCPPFieldSpecifiers () [CXXTagCPPFieldEndLine].ftype:
		cxxTagGetCFieldSpecifiers ()   [CXXTagCFieldEndLine].ftype;

	Assert(passCount < 3);

	cppInit(
			(boolean) (passCount > 1),
			FALSE,
			TRUE, // raw literals
			FALSE,
			kind_for_define,
			role_for_macro_undef,
			kind_for_header,
			role_for_header_system,
			role_for_header_local,
			end_field_type
		);

	g_cxx.iChar = ' ';

	boolean bRet = cxxParserParseBlock(FALSE);

	cppTerminate ();

	cxxTokenChainClear(g_cxx.pTokenChain);
	if(g_cxx.pTemplateTokenChain)
		cxxTokenChainClear(g_cxx.pTemplateTokenChain);

	if(!bRet && (passCount == 1))
	{
		CXX_DEBUG_PRINT("Processing failed: trying to rescan");
		return RESCAN_FAILED;
	}

	return RESCAN_NONE;
}