int yyparse(void) { printf("yyparse: entering\n"); get_token(); translation_unit(); printf("yyparse: exiting\n"); return 0; }
const char* libclang_vim::at_specific_location( const location_tuple& location_tuple, const std::function<std::string(CXCursor const&)>& predicate) { static std::string vimson; char const* file_name = location_tuple.file.c_str(); auto const args_ptrs = get_args_ptrs(location_tuple.args); cxindex_ptr index = clang_createIndex(/*excludeDeclsFromPCH*/ 1, /*displayDiagnostics*/ 0); std::vector<CXUnsavedFile> unsaved_files = create_unsaved_files(location_tuple); cxtranslation_unit_ptr translation_unit(clang_parseTranslationUnit( index, file_name, args_ptrs.data(), args_ptrs.size(), unsaved_files.data(), unsaved_files.size(), CXTranslationUnit_Incomplete)); if (!translation_unit) return "{}"; CXFile file = clang_getFile(translation_unit, file_name); auto const location = clang_getLocation( translation_unit, file, location_tuple.line, location_tuple.col); CXCursor const cursor = clang_getCursor(translation_unit, location); vimson = predicate(cursor); return vimson.c_str(); }
int translation_unit(void) { if( external_declaration() ) { } else if( translation_unit() ) { external_declaration(); } else { abort(); } }
/*********************************************************** * 功能: main主函数 **********************************************************/ int main(int argc, char ** argv) { fin = fopen(argv[1],"rb"); if(!fin) { printf("不能打开SC源文件!\n"); return 0; } init(); getch(); get_token(); translation_unit(); cleanup(); printf("\n%s 语法分析通过!\n",argv[1]); fclose(fin); return 1; }
TOKEN translation_unit(void) { TOKEN trans_unit = NULL; TOKEN next = NULL; TOKEN tok = peek_token(); if(tok != NULL) { trans_unit = external_declaration(); next = translation_unit(); if(trans_unit != NULL) { set_token_link(trans_unit, next); } else { trans_unit = next; } } return trans_unit; }
void CAipi_ExpParser::initExpParser() { //g_currentTimeTag = 0; g_currentId_IForm = 1000; CAipi_Lexer lex; if( g_dataSource == DATA_GUI ) { getToken(); } else { TCHAR symbol = _gettc(g_fp); m_lookahead = lex.getTokenFile(symbol); } translation_unit(); }
void cpp_languaget::modules_provided(std::set<std::string> &modules) { modules.insert(translation_unit(parse_path)); }
//parses the program TOKEN parse(void) { TOKEN parse_tree = translation_unit(); parse_tree = make_translation_unit(parse_tree); return parse_tree; }
void CAipi_ExpParser::translation_unit() { if( m_lookahead != _TEOF ) { if( m_lookahead == COMMENT ) { getToken(); } if( m_lookahead == C_VOID || m_lookahead == C_CHAR || m_lookahead == C_SHORT || m_lookahead == C_INT || m_lookahead == C_LONG || m_lookahead == C_FLOAT || m_lookahead == C_DOUBLE ) { declaration(); translation_unit(); } else if ( m_lookahead == IDENTIFIER || m_lookahead == DIGIT ) { expression(); translation_unit(); } else { CAipi_Error err; err.displayFileError(ABNORMAL_STOP, WARNING_ERROR, _T("The parser was not able to finish the depuration process. The initialization sintax is incorrect.") ); } } else { TCHAR buffer[8]; unsigned int nError = g_LexError + g_SintaxError + g_SemantError; unsigned int nWarning = g_WarningError + g_QuestionError; CString str_nError = _itot( nError, buffer, 10 ); CString str_nWarning = _itot( nWarning, buffer, 10 ); CString strLex = _itot( g_LexError, buffer, 10 ); CString strSintax = _itot( g_SintaxError, buffer, 10 ); CString strSemant = _itot( g_SemantError, buffer, 10 ); CString strWarning = _itot( g_WarningError, buffer, 10); CString strQuestion = _itot( g_QuestionError, buffer, 10); //CString strInfo = _itot( g_InfoError, buffer, 10); //CString strStop = _itot( g_SintaxError, buffer, 10 ); CAipi_Error err; err.displayFileError(EMPTY_MSG, -1, _T(" *************************************************************************************************************")); err.displayFileError(ERROR_COUNT, INFO_ERROR, _T(" Lexical errors:...") + strLex + _T(" Sintax errors:...") + strSintax + _T(" Semantic errors:...") + strSemant + _T(" *Total errors:...") + str_nError ); err.displayFileError(WARNING_COUNT, INFO_ERROR, _T(" Warnings:...") + strWarning + _T(" Warning questions:...") + strQuestion + _T(" *Total warnings:...") + str_nWarning ); err.displayFileError(FINISH, INFO_ERROR, _T(" **** Debug Summary:- ") + str_nError + _T(" error(s), ") + str_nWarning + _T(" warning(s). ****" )); CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd(); pMainFrame->m_wndOutputTabView.AddMsg1(_T("Debug Summary:- ") + str_nError + _T(" error(s), ") + str_nWarning + _T(" warning(s). ****" )); } }