Exemplo n.º 1
0
parserDefinition * CParser (void)
{
	static const char * const extensions [] =
	{
		"c",
#ifndef CASE_INSENSITIVE_FILENAMES
		"C",
#endif
		NULL
	};

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

	parserDefinition* def = parserNew("C");

	def->kinds = cxxTagGetCKindOptions();
	def->kindCount = cxxTagGetCKindOptionCount();
	def->fieldSpecs = cxxTagGetCFieldSpecifiers();
	def->fieldSpecCount = cxxTagGetCFieldSpecifierCount();
	def->extensions = extensions;
	def->parser2 = cxxCParserMain;
	def->initialize = cxxCParserInitialize;
	def->finalize = cxxParserCleanup;
	def->selectLanguage = selectors;
	def->useCork = true; // We use corking to block output until the end of file

	return def;
}
Exemplo n.º 2
0
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;
}