/* * process all input text * * at this level, only static declarations, defines, includes, * and function definitions are legal. * */ void parse (void) { if (!startup_incl) { inc_startup(); incl_globals(); } while (1) { blanks(); if (feof(input)) break; // Note: // At beginning of 'parse' call, the header has been output to '.s' // file, as well as all the -Asym=val operands from command line. // // But initial '#include "startup.asm"' statement was not yet output // (allowing for additional asm define's to be parsed and output first. // // We can parse some trivial tokens first (including the asmdef...), // but the #include "startup.asm" line must be output before actual code // (And only once...) // if (amatch("#asmdef", 7)) { doasmdef(); continue; } if (amatch("extern", 6)) dodcls(EXTERN, NULL_TAG, 0); else if (amatch("static", 6)) { if (amatch("const", 5)) { /* XXX: what about the static part? */ dodcls(CONST, NULL_TAG, 0); } else dodcls(STATIC, NULL_TAG, 0); } else if (amatch("const", 5)) dodcls(CONST, NULL_TAG, 0); else if (amatch("typedef", 7)) dotypedef(); else if (dodcls(PUBLIC, NULL_TAG, 0)) ; else if (match("#asm")) doasm(); else if (match("#include")) doinclude(); else if (match("#inc")) dopsdinc(); else if (match("#def")) dopsddef(); else newfunc(NULL, 0, 0, 0, 0); } if (optimize) flush_ins(); }
/** * non-declaration statement */ do_statement () { if (amatch ("if", 2)) { doif (); lastst = STIF; } else if (amatch ("while", 5)) { dowhile (); lastst = STWHILE; } else if (amatch ("switch", 6)) { doswitch (); lastst = STSWITCH; } else if (amatch ("do", 2)) { dodo (); need_semicolon (); lastst = STDO; } else if (amatch ("for", 3)) { dofor (); lastst = STFOR; } else if (amatch ("return", 6)) { doreturn (); need_semicolon (); lastst = STRETURN; } else if (amatch ("break", 5)) { dobreak (); need_semicolon (); lastst = STBREAK; } else if (amatch ("continue", 8)) { docont (); need_semicolon (); lastst = STCONT; } else if (match (";")) ; else if (amatch ("case", 4)) { docase (); lastst = statement (NO); } else if (amatch ("default", 7)) { dodefault (); lastst = statement (NO); } else if (match ("__asm__")) { doasm (); lastst = STASM; } else if (match("#")) { kill(); } else if (match ("{")) do_compound (NO); else { expression (YES); /* if (match (":")) { dolabel (); lastst = statement (NO); } else { */ need_semicolon (); lastst = STEXP; /* } */ } }
/* definitions are legal... */ parse() { while (eof==0) /* do until no more input */ { if(amatch("char",4)){declglb(cchar);ns();} else if(amatch("int",3)){declglb(cint);ns();} else if(match("#asm"))doasm(); else if(match("#include"))doinclude(); else if(match("#define"))addmac(); else newfunc(); blanks(); /* force eof if pending */ } }
static int dofort(char *s) { int nparms, i; char *params[MAXARGS]; nparms = 0; ADD(FCOM); for (i = 0; i < ffmax; i++) ADD(ffary[i]); ADD(s); ADD(asmfname); ADD(NULL); infname = s; if (callsys(fcom, params)) errorx("Error. No assembly."); doasm(s); if (saveasmflag == NO) rmf(asmfname); return(0); }
void parse() { while ( eof == 0 ) { /* do until no more input */ if ( amatch("extern") ) dodeclare(EXTERNAL, NULL_TAG, 0) ; else if (amatch("static")) dodeclare(LSTATIC, NULL_TAG, 0) ; else if (amatch("typedef")) dodeclare(TYPDEF,NULL_TAG,0) ; else if (dodeclare(STATIK, NULL_TAG, 0) ) ; else if ( ch() == '#' ) { if (match("#asm")) doasm(); else if (match("#include")) doinclude() ; else if (match("#define") ) addmac() ; else { clear(); blanks(); } } else newfunc(); blanks(); /* force eof if pending */ } }
/** * process all input text * at this level, only static declarations, defines, includes, * and function definitions are legal. */ void parse(void) { while (!input_eof) { if (match("#")) { if (match("asm")) doasm(); else if (match("include")) doinclude(); else if (match("define")) dodefine(); else if (match("undef")) doundef(); } else if (amatch("extern", 6)) do_declarations(EXTERN, NULL_TAG, 0); else if (amatch("static", 6)) do_declarations(STATIC, NULL_TAG, 0); else if (do_declarations(PUBLIC, NULL_TAG, 0)) ; else { newfunc(); } blanks(); } }