Parameter* cFP_varpar::parseNext( const String &next, state& st ) { if( next == ")" ) { // the only thing that can't be const if( st.m_bConst ) { tpe( __LINE__ ); } // we're done... and can't be forming return new Parameter( Parameter::e_varpar, false, "" ); } else tpe( __LINE__ ); return 0; // just to make the compiler happy }
Parameter* cFP_tagdef::parseNext( const String &next, FormingParam::state& st ) { if( isKwordOrPunc( next ) ) tpe( __LINE__ ); st.m_tag = next; st.nextState = &FP_paramname; return 0; }
Parameter* cFP_funcdecl_1::parseNext( const String &next, state& st ) { if( isKwordOrPunc(next) ) tpe( __LINE__ ); else { st.m_name = next; st.nextState = &FP_funcdecl_2; } return 0; }
Parameter* cFP_postsubscript::parseNext( const String &next, state& st ) { if( next == "]" ) { st.nextState = &FP_paramcomplete; } else tpe( __LINE__ ); return 0; }
Parameter* cFP_funcdecl::parseNext( const String &next, state& st ) { // TODO: Should we accept also void (funcname)(...) ? if( next != "*" ) tpe( __LINE__ ); else { st.nextState = &FP_funcdecl_1; } return 0; }
Parameter* cFP_funcdecl_2::parseNext( const String &next, state& st ) { if( next != ")" ) tpe( __LINE__ ); else { st.m_bFunc = true; // seeing the "forming parameter" non-empty, the upper parser will // start a sub-parameter list loop. st.m_forming = st.makeParameter(); // prepare as we should be called after the sub-loop, that is, as post name. st.nextState = &FP_postname; } return 0; }
Parameter* cFP_paramname::parseNext( const String &next, state& st ) { if( next == "*" ) { st.m_nPointers++; } else if ( isKwordOrPunc(next) ) { tpe( __LINE__ ); } else { st.m_name = next; st.nextState = &FP_postname; } return 0; }
Parameter* cFP_subscript::parseNext( const String &next, state& st ) { int64 subCount; if( next == "]" ) { st.m_nSubscripts = -1; st.nextState = &FP_paramcomplete; } else if ( next.parseInt( subCount ) ) { st.m_nSubscripts = (int) subCount; st.nextState = &FP_postsubscript; } else tpe( __LINE__ ); return 0; }
Parameter* cFP_paramcomplete::parseNext( const String &next, state& st ) { if( next == ")" || next == "," ) { if( st.m_forming ) { Parameter* p = st.m_forming; st.m_forming = 0; p->m_subscript = st.m_nSubscripts; return p; } // we're done... return st.makeParameter(); } else tpe( __LINE__ ); return 0; // just to make the compiler happy }
inline void parseTerminal( const String& next, FormingParam::state& st ) { if ( next == "*" ) { st.m_nPointers = 1; st.nextState = &FP_paramname; } else if ( next == "(" ) { // it's a function declaration. st.nextState = &FP_funcdecl; } else if ( isKwordOrPunc(next) ) tpe( __LINE__ ); else { st.m_name = next; st.nextState = &FP_postname; } }
int ui_tpe(int argc, char **argv)/*{{{*/ { struct tower_table *table; struct tower2 *tow; struct node *top; struct cli *cli; int i; cli = parse_args(argc, argv, &sub_tpe); if (cli->n_datafiles == 0) { usage_tpe(); exit(2); } top = load_all_dbs(cli); table = read_towers2("towers.dat"); resolve_towers(cli, table); /* Also make active any towers with no existing estimate, or no hexcode. The * latter allows you to get a tower re-run by deleting the hexcode line from * the file, whilst still getting a report of the distance that the estimate * has moved by. */ for (i=0; i<table->n_towers; i++) { struct tower2 *tow = table->towers[i]; if (!tow->has_estimated || !tow->hexcode) { tow->active_flag = 1; } } /* Do filtering */ temporal_merge_2(top); tpe(top, table); write_towers2("new_towers.dat", table); free_tower_table(table); free(top); return 0; }
Parameter* FunctionDef::parseNextParam( Tokenizer& tok, bool isFuncName ) { FormingParam::state state; Parameter *ret = 0; state.nextState = &FP_start; while( tok.hasCurrent() ) { String next = tok.getToken(); ret = state.nextState->parseNext( next, state ); if ( state.m_forming != 0 ) { // ok, we should parse the parameter list of this parameter. if( tok.next() ) { // this is to skip the initial "(". if ( tok.getToken() != "(" || ! tok.next() ) tpe( __LINE__ ); parseFuncParams( state.m_forming->m_funcParams, tok ); } } else if ( ret != 0 ) { return ret; } tok.next(); if( isFuncName && tok.getToken() == "(" ) { return state.makeParameter(); } } return ret; }
Parameter* cFP_postname::parseNext( const String &next, state& st ) { if( next == "," || next == ")" ) { if( st.m_forming ) { Parameter* p = st.m_forming; st.m_forming = 0; return p; } // we're done... return st.makeParameter(); } else if ( next == "[" ) { st.nextState = &FP_subscript; } else tpe( __LINE__ ); return 0; }
Parameter* cFP_start::parseNext( const String &next, FormingParam::state& st ) { if ( next == "const" ) { if( st.m_bConst ) tpe( __LINE__ ); st.m_bConst = true; } else if ( next == "signed" ) { st.nextState = &FP_signed; } else if ( next == "void" ) { st.nextState = &FP_void; } else if ( next == "unsigned" ) { st.nextState = &FP_unsigned; } else if ( next == "char" ) { st.nextState = &FP_char; } else if ( next == "wchar_t" ) { st.nextState = &FP_wchar_t; } else if ( next == "short" ) { st.nextState = &FP_short; } else if ( next == "int" ) { st.nextState = &FP_int; } else if ( next == "long" ) { st.nextState = &FP_long; } else if ( next == "float" ) { st.nextState = &FP_float; } else if ( next == "double" ) { st.nextState = &FP_double; } else if ( next == "struct" ) { st.m_type = Parameter::e_struct; st.nextState = &FP_tagdef; } else if ( next == "union" ) { st.m_type = Parameter::e_union; st.nextState = &FP_tagdef; } else if ( next == "enum" ) { st.m_type = Parameter::e_enum; st.nextState = &FP_tagdef; } else if ( next == "..." ) { st.nextState = &FP_varpar; } else if ( next == "WORD" ) { st.nextState = &FP_unsigned_short; } else if ( next == "DWORD" ) { st.nextState = &FP_unsigned_int; } else if ( next == "HANDLE" ) { st.nextState = &FP_unsigned_long; } else if ( next == "__int64" ) { st.nextState = &FP_long_long; } else tpe( __LINE__ ); return 0; }