Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# ext/ripper/eventids2.c

Go to the documentation of this file.

    00001 #define tIGNORED_NL      (tLAST_TOKEN + 1)
    00002 #define tCOMMENT         (tLAST_TOKEN + 2)
    00003 #define tEMBDOC_BEG      (tLAST_TOKEN + 3)
    00004 #define tEMBDOC          (tLAST_TOKEN + 4)
    00005 #define tEMBDOC_END      (tLAST_TOKEN + 5)
    00006 #define tSP              (tLAST_TOKEN + 6)
    00007 #define tHEREDOC_BEG     (tLAST_TOKEN + 7)
    00008 #define tHEREDOC_END     (tLAST_TOKEN + 8)
    00009 #define k__END__         (tLAST_TOKEN + 9)
    00010
    00011 static ID ripper_id_backref;
    00012 static ID ripper_id_backtick;
    00013 static ID ripper_id_comma;
    00014 static ID ripper_id_const;
    00015 static ID ripper_id_cvar;
    00016 static ID ripper_id_embexpr_beg;
    00017 static ID ripper_id_embexpr_end;
    00018 static ID ripper_id_embvar;
    00019 static ID ripper_id_float;
    00020 static ID ripper_id_gvar;
    00021 static ID ripper_id_ident;
    00022 static ID ripper_id_int;
    00023 static ID ripper_id_ivar;
    00024 static ID ripper_id_kw;
    00025 static ID ripper_id_lbrace;
    00026 static ID ripper_id_lbracket;
    00027 static ID ripper_id_lparen;
    00028 static ID ripper_id_nl;
    00029 static ID ripper_id_op;
    00030 static ID ripper_id_period;
    00031 static ID ripper_id_rbrace;
    00032 static ID ripper_id_rbracket;
    00033 static ID ripper_id_rparen;
    00034 static ID ripper_id_semicolon;
    00035 static ID ripper_id_symbeg;
    00036 static ID ripper_id_tstring_beg;
    00037 static ID ripper_id_tstring_content;
    00038 static ID ripper_id_tstring_end;
    00039 static ID ripper_id_words_beg;
    00040 static ID ripper_id_qwords_beg;
    00041 static ID ripper_id_words_sep;
    00042 static ID ripper_id_regexp_beg;
    00043 static ID ripper_id_regexp_end;
    00044 static ID ripper_id_label;
    00045 static ID ripper_id_tlambda;
    00046 static ID ripper_id_tlambeg;
    00047
    00048 static ID ripper_id_ignored_nl;
    00049 static ID ripper_id_comment;
    00050 static ID ripper_id_embdoc_beg;
    00051 static ID ripper_id_embdoc;
    00052 static ID ripper_id_embdoc_end;
    00053 static ID ripper_id_sp;
    00054 static ID ripper_id_heredoc_beg;
    00055 static ID ripper_id_heredoc_end;
    00056 static ID ripper_id___end__;
    00057 static ID ripper_id_CHAR;
    00058
    00059 #include "eventids2table.c"
    00060
    00061 static void
    00062 ripper_init_eventids2(VALUE self)
    00063 {
    00064     ripper_id_backref = rb_intern_const("on_backref");
    00065     ripper_id_backtick = rb_intern_const("on_backtick");
    00066     ripper_id_comma = rb_intern_const("on_comma");
    00067     ripper_id_const = rb_intern_const("on_const");
    00068     ripper_id_cvar = rb_intern_const("on_cvar");
    00069     ripper_id_embexpr_beg = rb_intern_const("on_embexpr_beg");
    00070     ripper_id_embexpr_end = rb_intern_const("on_embexpr_end");
    00071     ripper_id_embvar = rb_intern_const("on_embvar");
    00072     ripper_id_float = rb_intern_const("on_float");
    00073     ripper_id_gvar = rb_intern_const("on_gvar");
    00074     ripper_id_ident = rb_intern_const("on_ident");
    00075     ripper_id_int = rb_intern_const("on_int");
    00076     ripper_id_ivar = rb_intern_const("on_ivar");
    00077     ripper_id_kw = rb_intern_const("on_kw");
    00078     ripper_id_lbrace = rb_intern_const("on_lbrace");
    00079     ripper_id_lbracket = rb_intern_const("on_lbracket");
    00080     ripper_id_lparen = rb_intern_const("on_lparen");
    00081     ripper_id_nl = rb_intern_const("on_nl");
    00082     ripper_id_op = rb_intern_const("on_op");
    00083     ripper_id_period = rb_intern_const("on_period");
    00084     ripper_id_rbrace = rb_intern_const("on_rbrace");
    00085     ripper_id_rbracket = rb_intern_const("on_rbracket");
    00086     ripper_id_rparen = rb_intern_const("on_rparen");
    00087     ripper_id_semicolon = rb_intern_const("on_semicolon");
    00088     ripper_id_symbeg = rb_intern_const("on_symbeg");
    00089     ripper_id_tstring_beg = rb_intern_const("on_tstring_beg");
    00090     ripper_id_tstring_content = rb_intern_const("on_tstring_content");
    00091     ripper_id_tstring_end = rb_intern_const("on_tstring_end");
    00092     ripper_id_words_beg = rb_intern_const("on_words_beg");
    00093     ripper_id_qwords_beg = rb_intern_const("on_qwords_beg");
    00094     ripper_id_words_sep = rb_intern_const("on_words_sep");
    00095     ripper_id_regexp_beg = rb_intern_const("on_regexp_beg");
    00096     ripper_id_regexp_end = rb_intern_const("on_regexp_end");
    00097     ripper_id_label = rb_intern_const("on_label");
    00098     ripper_id_tlambda = rb_intern_const("on_tlambda");
    00099     ripper_id_tlambeg = rb_intern_const("on_tlambeg");
    00100
    00101     ripper_id_ignored_nl = rb_intern_const("on_ignored_nl");
    00102     ripper_id_comment = rb_intern_const("on_comment");
    00103     ripper_id_embdoc_beg = rb_intern_const("on_embdoc_beg");
    00104     ripper_id_embdoc = rb_intern_const("on_embdoc");
    00105     ripper_id_embdoc_end = rb_intern_const("on_embdoc_end");
    00106     ripper_id_sp = rb_intern_const("on_sp");
    00107     ripper_id_heredoc_beg = rb_intern_const("on_heredoc_beg");
    00108     ripper_id_heredoc_end = rb_intern_const("on_heredoc_end");
    00109     ripper_id___end__ = rb_intern_const("on___end__");
    00110     ripper_id_CHAR = rb_intern_const("on_CHAR");
    00111
    00112     ripper_init_eventids2_table(self);
    00113 }
    00114
    00115 static const struct token_assoc {
    00116     int token;
    00117     ID *id;
    00118 } token_to_eventid[] = {
    00119     {' ',               &ripper_id_words_sep},
    00120     {'!',               &ripper_id_op},
    00121     {'%',               &ripper_id_op},
    00122     {'&',               &ripper_id_op},
    00123     {'*',               &ripper_id_op},
    00124     {'+',               &ripper_id_op},
    00125     {'-',               &ripper_id_op},
    00126     {'/',               &ripper_id_op},
    00127     {'<',               &ripper_id_op},
    00128     {'=',               &ripper_id_op},
    00129     {'>',               &ripper_id_op},
    00130     {'?',               &ripper_id_op},
    00131     {'^',               &ripper_id_op},
    00132     {'|',               &ripper_id_op},
    00133     {'~',               &ripper_id_op},
    00134     {':',               &ripper_id_op},
    00135     {',',               &ripper_id_comma},
    00136     {'.',               &ripper_id_period},
    00137     {';',               &ripper_id_semicolon},
    00138     {'`',               &ripper_id_backtick},
    00139     {'\n',              &ripper_id_nl},
    00140     {keyword_alias,     &ripper_id_kw},
    00141     {keyword_and,       &ripper_id_kw},
    00142     {keyword_begin,     &ripper_id_kw},
    00143     {keyword_break,     &ripper_id_kw},
    00144     {keyword_case,      &ripper_id_kw},
    00145     {keyword_class,     &ripper_id_kw},
    00146     {keyword_def,       &ripper_id_kw},
    00147     {keyword_defined,   &ripper_id_kw},
    00148     {keyword_do,        &ripper_id_kw},
    00149     {keyword_do_block,  &ripper_id_kw},
    00150     {keyword_do_cond,   &ripper_id_kw},
    00151     {keyword_else,      &ripper_id_kw},
    00152     {keyword_elsif,     &ripper_id_kw},
    00153     {keyword_end,       &ripper_id_kw},
    00154     {keyword_ensure,    &ripper_id_kw},
    00155     {keyword_false,     &ripper_id_kw},
    00156     {keyword_for,       &ripper_id_kw},
    00157     {keyword_if,        &ripper_id_kw},
    00158     {modifier_if,       &ripper_id_kw},
    00159     {keyword_in,        &ripper_id_kw},
    00160     {keyword_module,    &ripper_id_kw},
    00161     {keyword_next,      &ripper_id_kw},
    00162     {keyword_nil,       &ripper_id_kw},
    00163     {keyword_not,       &ripper_id_kw},
    00164     {keyword_or,        &ripper_id_kw},
    00165     {keyword_redo,      &ripper_id_kw},
    00166     {keyword_rescue,    &ripper_id_kw},
    00167     {modifier_rescue,   &ripper_id_kw},
    00168     {keyword_retry,     &ripper_id_kw},
    00169     {keyword_return,    &ripper_id_kw},
    00170     {keyword_self,      &ripper_id_kw},
    00171     {keyword_super,     &ripper_id_kw},
    00172     {keyword_then,      &ripper_id_kw},
    00173     {keyword_true,      &ripper_id_kw},
    00174     {keyword_undef,     &ripper_id_kw},
    00175     {keyword_unless,    &ripper_id_kw},
    00176     {modifier_unless,   &ripper_id_kw},
    00177     {keyword_until,     &ripper_id_kw},
    00178     {modifier_until,    &ripper_id_kw},
    00179     {keyword_when,      &ripper_id_kw},
    00180     {keyword_while,     &ripper_id_kw},
    00181     {modifier_while,    &ripper_id_kw},
    00182     {keyword_yield,     &ripper_id_kw},
    00183     {keyword__FILE__,   &ripper_id_kw},
    00184     {keyword__LINE__,   &ripper_id_kw},
    00185     {keyword__ENCODING__, &ripper_id_kw},
    00186     {keyword_BEGIN,     &ripper_id_kw},
    00187     {keyword_END,       &ripper_id_kw},
    00188     {keyword_do_LAMBDA, &ripper_id_kw},
    00189     {tAMPER,            &ripper_id_op},
    00190     {tANDOP,            &ripper_id_op},
    00191     {tAREF,             &ripper_id_op},
    00192     {tASET,             &ripper_id_op},
    00193     {tASSOC,            &ripper_id_op},
    00194     {tBACK_REF,         &ripper_id_backref},
    00195     {tCHAR,             &ripper_id_CHAR},
    00196     {tCMP,              &ripper_id_op},
    00197     {tCOLON2,           &ripper_id_op},
    00198     {tCOLON3,           &ripper_id_op},
    00199     {tCONSTANT,         &ripper_id_const},
    00200     {tCVAR,             &ripper_id_cvar},
    00201     {tDOT2,             &ripper_id_op},
    00202     {tDOT3,             &ripper_id_op},
    00203     {tEQ,               &ripper_id_op},
    00204     {tEQQ,              &ripper_id_op},
    00205     {tFID,              &ripper_id_ident},
    00206     {tFLOAT,            &ripper_id_float},
    00207     {tGEQ,              &ripper_id_op},
    00208     {tGVAR,             &ripper_id_gvar},
    00209     {tIDENTIFIER,       &ripper_id_ident},
    00210     {tINTEGER,          &ripper_id_int},
    00211     {tIVAR,             &ripper_id_ivar},
    00212     {tLBRACE,           &ripper_id_lbrace},
    00213     {tLBRACE_ARG,       &ripper_id_lbrace},
    00214     {'{',               &ripper_id_lbrace},
    00215     {'}',               &ripper_id_rbrace},
    00216     {tLBRACK,           &ripper_id_lbracket},
    00217     {'[',               &ripper_id_lbracket},
    00218     {']',               &ripper_id_rbracket},
    00219     {tLEQ,              &ripper_id_op},
    00220     {tLPAREN,           &ripper_id_lparen},
    00221     {tLPAREN_ARG,       &ripper_id_lparen},
    00222     {'(',               &ripper_id_lparen},
    00223     {')',               &ripper_id_rparen},
    00224     {tLSHFT,            &ripper_id_op},
    00225     {tMATCH,            &ripper_id_op},
    00226     {tNEQ,              &ripper_id_op},
    00227     {tNMATCH,           &ripper_id_op},
    00228     {tNTH_REF,          &ripper_id_backref},
    00229     {tOP_ASGN,          &ripper_id_op},
    00230     {tOROP,             &ripper_id_op},
    00231     {tPOW,              &ripper_id_op},
    00232     {tQWORDS_BEG,       &ripper_id_qwords_beg},
    00233     {tREGEXP_BEG,       &ripper_id_regexp_beg},
    00234     {tREGEXP_END,       &ripper_id_regexp_end},
    00235     {tRPAREN,           &ripper_id_rparen},
    00236     {tRSHFT,            &ripper_id_op},
    00237     {tSTAR,             &ripper_id_op},
    00238     {tSTRING_BEG,       &ripper_id_tstring_beg},
    00239     {tSTRING_CONTENT,   &ripper_id_tstring_content},
    00240     {tSTRING_DBEG,      &ripper_id_embexpr_beg},
    00241     {tSTRING_DVAR,      &ripper_id_embvar},
    00242     {tSTRING_END,       &ripper_id_tstring_end},
    00243     {tSYMBEG,           &ripper_id_symbeg},
    00244     {tUMINUS,           &ripper_id_op},
    00245     {tUMINUS_NUM,       &ripper_id_op},
    00246     {tUPLUS,            &ripper_id_op},
    00247     {tWORDS_BEG,        &ripper_id_words_beg},
    00248     {tXSTRING_BEG,      &ripper_id_backtick},
    00249     {tLABEL,            &ripper_id_label},
    00250     {tLAMBDA,           &ripper_id_tlambda},
    00251     {tLAMBEG,           &ripper_id_tlambeg},
    00252
    00253     /* ripper specific tokens */
    00254     {tIGNORED_NL,       &ripper_id_ignored_nl},
    00255     {tCOMMENT,          &ripper_id_comment},
    00256     {tEMBDOC_BEG,       &ripper_id_embdoc_beg},
    00257     {tEMBDOC,           &ripper_id_embdoc},
    00258     {tEMBDOC_END,       &ripper_id_embdoc_end},
    00259     {tSP,               &ripper_id_sp},
    00260     {tHEREDOC_BEG,      &ripper_id_heredoc_beg},
    00261     {tHEREDOC_END,      &ripper_id_heredoc_end},
    00262     {k__END__,          &ripper_id___end__},
    00263     {0, NULL}
    00264 };
    00265
    00266 static ID
    00267 ripper_token2eventid(int tok)
    00268 {
    00269     const struct token_assoc *a;
    00270
    00271     for (a = token_to_eventid; a->id != NULL; a++) {
    00272         if (a->token == tok)
    00273             return *a->id;
    00274     }
    00275     if (tok < 256) {
    00276         return ripper_id_CHAR;
    00277     }
    00278     rb_raise(rb_eRuntimeError, "[Ripper FATAL] unknown token %d", tok);
    00279 }
    00280