parser.h (4584B)
1 #ifndef PARSERH 2 #define PARSERH 3 4 #include "EasyLexer.h" 5 #include "libsheepyObject.h" 6 7 // FINAL is the state count for the array definitions 8 enum {IDLE,TYPE,TYPEID,POINTERTYPE,TYPEINIT,TYPEINITSTR,TYPEEND,CONST_,EXTERN_,VOLATILE_,STATIC_,UNSIGNED_,SIGNED_,ENUM_,ENUM_END,TYPEDEF_,TDSTRUCT,STRUCTBLOCK,STRUCTINBLOCK,UNIONINSTRUCT,STRUCTTYPE,STRUCTTYPEID,STRUCTTYPEEND,STRUCTID,STRUCTBLOCKEND,UNIONBLOCK,STRUCTINUNION,UNIONINBLOCK,UNIONTYPE,UNIONTYPEID,UNIONTYPEEND,UNIONID,UNIONBLOCKEND,FUNCOPEN,FUNCCLOSE,PROTOTYPE,CODEBLOCK,CONTINUE_,CODEBLOCKID,CALL,CALLSTR,CALLCLOSE,CALLEND,CALLENDNPOP,INCREMENT,GOTO_,GOTO_ID,GOTO_END,GOTO_ENDNPOP,COLON,COLONEND,ARRAYINDEX,ARRAYINDEXEND,ASSIGNMENT,NUMBER,ASSIGNID,QUOTED_CHAR,QUOTED_CHAR_SEMICOLON,SIZEOF_,IF_,ELSE_,FOR_,DO_,SWITCH_,SWITCH_BLOCK,CASE_,CASE_ID,CASE_BLOCK,BREAK_,SWITCH_BLOCKEND,RETURN_,RETURN_STR,RETURN_END,CODEBLOCKEND,DO_END,DO_FOR,DO_CLOSE,USE,USEID,USEDOT,USECOMMA,USEEND,FINAL}; 9 10 extern int stateM; 11 12 extern smallArrayt *generatedC; 13 extern smallArrayt *sheepyC; 14 extern smallArrayt *stateStack; 15 extern smallArrayt *textStack; 16 17 extern char *STATESSTR[FINAL]; 18 19 #define TRANSITIONS 19 20 21 extern int STATES[FINAL][TRANSITIONS*2]; 22 23 #define stateTkn(ste) STATES[stateM][ste*2] 24 #define stateNxt(ste) STATES[stateM][ste*2+1] 25 #define callNxt(ste) STATEF[stateNxt(ste)](stateNxt(ste), text) 26 27 void defaultInState(int ste, char *text); 28 void idle(int ste, char *text); 29 void type(int ste, char *text); 30 void typeid(int ste, char *text); 31 void pointertype(int ste, char *text); 32 void typeinit(int ste, char *text); 33 void typeinitstr(int ste, char *text); 34 void typeend(int ste, char *text); 35 void const_(int ste, char *text); 36 void extern_(int ste, char *text); 37 void volatile_(int ste, char *text); 38 void static_(int ste, char *text); 39 void unsigned_(int ste, char *text); 40 void signed_(int ste, char *text); 41 void enum_(int ste, char *text); 42 void enum_end(int ste, char *text); 43 void typedef_(int ste, char *text); 44 void tdstruct(int ste, char *text); 45 void structblock(int ste, char *text); 46 void structinblock(int ste, char *text); 47 void unioninstruct(int ste, char *text); 48 void structtype(int ste, char *text); 49 void structtypeid(int ste, char *text); 50 void structtypeend(int ste, char *text); 51 void structid(int ste, char *text); 52 void structblockend(int ste, char *text); 53 void unionblock(int ste, char *text); 54 void structinunion(int ste, char *text); 55 void unioninblock(int ste, char *text); 56 void uniontype(int ste, char *text); 57 void uniontypeid(int ste, char *text); 58 void uniontypeend(int ste, char *text); 59 void unionid(int ste, char *text); 60 void unionblockend(int ste, char *text); 61 void funcopen(int ste, char *text); 62 void funcclose(int ste, char *text); 63 void prototype(int ste, char *text); 64 void codeblock(int ste, char *text); 65 void continue_(int ste, char *text); 66 void codeblockid(int ste, char *text); 67 void call(int ste, char *text); 68 void callstr(int ste, char *text); 69 void callclose(int ste, char *text); 70 void callend(int ste, char *text); 71 void callendnpop(int ste, char *text); 72 void increment(int ste, char *text); 73 void goto_(int ste, char *text); 74 void goto_id(int ste, char *text); 75 void goto_end(int ste, char *text); 76 void goto_endnpop(int ste, char *text); 77 void colon(int ste, char *text); 78 void colonend(int ste, char *text); 79 void arrayindex(int ste, char *text); 80 void arrayindexend(int ste, char *text); 81 void assignment(int ste, char *text); 82 void number(int ste, char *text); 83 void assignid(int ste, char *text); 84 void quoted_char(int ste, char *text); 85 void quoted_char_semicolon(int ste, char *text); 86 void sizeof_(int ste, char *text); 87 void if_(int ste, char *text); 88 void else_(int ste, char *text); 89 void for_(int ste, char *text); 90 void do_(int ste, char *text); 91 void switch_(int ste, char *text); 92 void switch_block(int ste, char *text); 93 void case_(int ste, char *text); 94 void case_id(int ste, char *text); 95 void case_block(int ste, char *text); 96 void break_(int ste, char *text); 97 void switch_blockend(int ste, char *text); 98 void return_(int ste, char *text); 99 void return_str(int ste, char *text); 100 void return_end(int ste, char *text); 101 void codeblockend(int ste, char *text); 102 void do_end(int ste, char *text); 103 void do_for(int ste, char *text); 104 void do_close(int ste, char *text); 105 void use(int ste, char *text); 106 void useid(int ste, char *text); 107 void usedot(int ste, char *text); 108 void usecomma(int ste, char *text); 109 void useend(int ste, char *text); 110 111 // ste is the state it is transitioning to 112 // text is the token 113 typedef void (*stateFt)(int ste, char *text); 114 extern stateFt STATEF[FINAL]; 115 116 extern stateFt STATEDEFAULTF[FINAL]; 117 118 #endif //ifndef PARSERH