Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

parse.c File Reference

#include "ruby.h"
#include "env.h"
#include "intern.h"
#include "node.h"
#include "st.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include "regex.h"
#include "util.h"
#include "lex.c"

Go to the source code of this file.

Data Structures

struct  local_vars
union  yyalloc
union  yystype

Defines

#define YYBISON   1
#define kCLASS   257
#define kMODULE   258
#define kDEF   259
#define kUNDEF   260
#define kBEGIN   261
#define kRESCUE   262
#define kENSURE   263
#define kEND   264
#define kIF   265
#define kUNLESS   266
#define kTHEN   267
#define kELSIF   268
#define kELSE   269
#define kCASE   270
#define kWHEN   271
#define kWHILE   272
#define kUNTIL   273
#define kFOR   274
#define kBREAK   275
#define kNEXT   276
#define kREDO   277
#define kRETRY   278
#define kIN   279
#define kDO   280
#define kDO_COND   281
#define kDO_BLOCK   282
#define kRETURN   283
#define kYIELD   284
#define kSUPER   285
#define kSELF   286
#define kNIL   287
#define kTRUE   288
#define kFALSE   289
#define kAND   290
#define kOR   291
#define kNOT   292
#define kIF_MOD   293
#define kUNLESS_MOD   294
#define kWHILE_MOD   295
#define kUNTIL_MOD   296
#define kRESCUE_MOD   297
#define kALIAS   298
#define kDEFINED   299
#define klBEGIN   300
#define klEND   301
#define k__LINE__   302
#define k__FILE__   303
#define tIDENTIFIER   304
#define tFID   305
#define tGVAR   306
#define tIVAR   307
#define tCONSTANT   308
#define tCVAR   309
#define tINTEGER   310
#define tFLOAT   311
#define tSTRING_CONTENT   312
#define tNTH_REF   313
#define tBACK_REF   314
#define tREGEXP_END   315
#define tUPLUS   316
#define tUMINUS   317
#define tPOW   318
#define tCMP   319
#define tEQ   320
#define tEQQ   321
#define tNEQ   322
#define tGEQ   323
#define tLEQ   324
#define tANDOP   325
#define tOROP   326
#define tMATCH   327
#define tNMATCH   328
#define tDOT2   329
#define tDOT3   330
#define tAREF   331
#define tASET   332
#define tLSHFT   333
#define tRSHFT   334
#define tCOLON2   335
#define tCOLON3   336
#define tOP_ASGN   337
#define tASSOC   338
#define tLPAREN   339
#define tLPAREN_ARG   340
#define tRPAREN   341
#define tLBRACK   342
#define tLBRACE   343
#define tLBRACE_ARG   344
#define tSTAR   345
#define tAMPER   346
#define tSYMBEG   347
#define tSTRING_BEG   348
#define tXSTRING_BEG   349
#define tREGEXP_BEG   350
#define tWORDS_BEG   351
#define tQWORDS_BEG   352
#define tSTRING_DBEG   353
#define tSTRING_DVAR   354
#define tSTRING_END   355
#define tLOWEST   356
#define tUMINUS_NUM   357
#define tLAST_TOKEN   358
#define YYDEBUG   1
#define YYERROR_VERBOSE   1
#define YYSTACK_USE_ALLOCA   0
#define YYMALLOC   rb_parser_malloc
#define YYREALLOC   rb_parser_realloc
#define YYCALLOC   rb_parser_calloc
#define YYFREE   rb_parser_free
#define malloc   YYMALLOC
#define realloc   YYREALLOC
#define calloc   YYCALLOC
#define free   YYFREE
#define yyparse   ruby_yyparse
#define yylex   ruby_yylex
#define yyerror   ruby_yyerror
#define yylval   ruby_yylval
#define yychar   ruby_yychar
#define yydebug   ruby_yydebug
#define ID_SCOPE_SHIFT   3
#define ID_SCOPE_MASK   0x07
#define ID_LOCAL   0x01
#define ID_INSTANCE   0x02
#define ID_GLOBAL   0x03
#define ID_ATTRSET   0x04
#define ID_CONST   0x05
#define ID_CLASS   0x06
#define ID_JUNK   0x07
#define ID_INTERNAL   ID_JUNK
#define is_notop_id(id)   ((id)>tLAST_TOKEN)
#define is_local_id(id)   (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
#define is_global_id(id)   (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL)
#define is_instance_id(id)   (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE)
#define is_attrset_id(id)   (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET)
#define is_const_id(id)   (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CONST)
#define is_class_id(id)   (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CLASS)
#define is_junk_id(id)   (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_JUNK)
#define is_asgn_or_id(id)
#define BITSTACK_PUSH(stack, n)   (stack = (stack<<1)|((n)&1))
#define BITSTACK_POP(stack)   (stack >>= 1)
#define BITSTACK_LEXPOP(stack)   (stack = (stack >> 1) | (stack & 1))
#define BITSTACK_SET_P(stack)   (stack&1)
#define COND_PUSH(n)   BITSTACK_PUSH(cond_stack, n)
#define COND_POP()   BITSTACK_POP(cond_stack)
#define COND_LEXPOP()   BITSTACK_LEXPOP(cond_stack)
#define COND_P()   BITSTACK_SET_P(cond_stack)
#define CMDARG_PUSH(n)   BITSTACK_PUSH(cmdarg_stack, n)
#define CMDARG_POP()   BITSTACK_POP(cmdarg_stack)
#define CMDARG_LEXPOP()   BITSTACK_LEXPOP(cmdarg_stack)
#define CMDARG_P()   BITSTACK_SET_P(cmdarg_stack)
#define value_expr(node)   value_expr0((node) = remove_begin(node))
#define void_expr(node)   void_expr0((node) = remove_begin(node))
#define RE_OPTION_ONCE   0x80
#define NODE_STRTERM   NODE_ZARRAY
#define NODE_HEREDOC   NODE_ARRAY
#define SIGN_EXTEND(x, n)   (((1<<(n)-1)^((x)&~(~0<<(n))))-(1<<(n)-1))
#define nd_func   u1.id
#define nd_term(node)   ((signed short)(node)->u2.id)
#define nd_paren(node)   (char)((node)->u2.id >> CHAR_BIT*2)
#define nd_nest   u3.id
#define YYSTYPE   yystype
#define YYSTYPE_IS_TRIVIAL   1
#define YYFINAL   895
#define YYFLAG   -32768
#define YYNTBASE   132
#define YYTRANSLATE(x)   ((unsigned)(x) <= 358 ? yytranslate[x] : 274)
#define YYLAST   9585
#define YYSTACK_ALLOC   malloc
#define YYSTACK_FREE   free
#define YYSTACK_GAP_MAX   (sizeof (union yyalloc) - 1)
#define YYSTACK_BYTES(N)
#define YYCOPY(To, From, Count)
#define YYSTACK_RELOCATE(Stack)
#define YYSIZE_T   unsigned int
#define yyerrok   (yyerrstatus = 0)
#define yyclearin   (yychar = YYEMPTY)
#define YYEMPTY   -2
#define YYEOF   0
#define YYACCEPT   goto yyacceptlab
#define YYABORT   goto yyabortlab
#define YYERROR   goto yyerrlab1
#define YYFAIL   goto yyerrlab
#define YYRECOVERING()   (!!yyerrstatus)
#define YYBACKUP(Token, Value)
#define YYTERROR   1
#define YYERRCODE   256
#define YYLLOC_DEFAULT(Current, Rhs, N)
#define YYLEX   yylex ()
#define YYFPRINTF   fprintf
#define YYDPRINTF(Args)
#define YYINITDEPTH   200
#define YYMAXDEPTH   10000
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL
#define YY_DECL_NON_LSP_VARIABLES
#define YY_DECL_VARIABLES   YY_DECL_NON_LSP_VARIABLES
#define YYPOPSTACK   (yyvsp--, yyssp--)
#define SIGN_EXTEND_CHAR(c)   ((((unsigned char)(c)) ^ 128) - 128)
#define is_identchar(c)   (SIGN_EXTEND_CHAR(c)!=-1&&(ISALNUM(c) || (c) == '_' || ismbchar(c)))
#define LEAVE_BS   1
#define was_bol()   (lex_p == lex_pbeg + 1)
#define peek(c)   (lex_p != lex_pend && (c) == *lex_p)
#define tokfix()   (tokenbuf[tokidx]='\0')
#define tok()   tokenbuf
#define toklen()   tokidx
#define toklast()   (tokidx>0?tokenbuf[tokidx-1]:0)
#define STR_FUNC_ESCAPE   0x01
#define STR_FUNC_EXPAND   0x02
#define STR_FUNC_REGEXP   0x04
#define STR_FUNC_QWORDS   0x08
#define STR_FUNC_SYMBOL   0x10
#define STR_FUNC_INDENT   0x20
#define NEW_STRTERM(func, term, paren)   rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
#define IS_ARG()   (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
#define HEAPCNT(n, size)   ((n) * (size) / sizeof(YYSTYPE))
#define NEWHEAP()   rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser_heap, 0)
#define ADD2HEAP(n, c, p)

Typedefs

typedef unsigned LONG_LONG stack_type

Enumerations

enum  lex_state {
  EXPR_BEG, EXPR_END, EXPR_ARG, EXPR_CMDARG,
  EXPR_ENDARG, EXPR_MID, EXPR_FNAME, EXPR_DOT,
  EXPR_CLASS
}
enum  string_type {
  str_squote = (0), str_dquote = (STR_FUNC_EXPAND), str_xquote = (STR_FUNC_EXPAND), str_regexp = (STR_FUNC_REGEXP|STR_FUNC_ESCAPE|STR_FUNC_EXPAND),
  str_sword = (STR_FUNC_QWORDS), str_dword = (STR_FUNC_QWORDS|STR_FUNC_EXPAND), str_ssym = (STR_FUNC_SYMBOL), str_dsym = (STR_FUNC_SYMBOL|STR_FUNC_EXPAND)
}

Functions

void * rb_parser_malloc (size_t)
void * rb_parser_realloc (void *, size_t)
void * rb_parser_calloc (size_t, size_t)
void rb_parser_free (void *)
int yylex ()
int yyerror ()
NODEcond ()
NODElogop ()
int cond_negative ()
NODEnewline_node ()
void fixpos ()
int value_expr0 ()
void void_expr0 ()
void void_stmts ()
NODEremove_begin ()
NODEblock_append ()
NODElist_append ()
NODElist_concat ()
NODEarg_concat ()
NODEarg_prepend ()
NODEliteral_concat ()
NODEnew_evstr ()
NODEevstr2dstr ()
NODEcall_op ()
NODEnegate_lit ()
NODEret_args ()
NODEarg_blk_pass ()
NODEnew_call ()
NODEnew_fcall ()
NODEnew_super ()
NODEnew_yield ()
NODEgettable ()
NODEassignable ()
NODEaryset ()
NODEattrset ()
void rb_backref_error ()
NODEnode_assign ()
NODEmatch_gen ()
void local_push ()
void local_pop ()
int local_append ()
int local_cnt ()
int local_id ()
IDlocal_tbl ()
ID internal_id ()
RVarmapdyna_push ()
void dyna_pop ()
int dyna_in_block ()
NODEdyna_init ()
void top_local_init ()
void top_local_setup ()
YYSIZE_T yystrlen (char *yystr) const
char * yystpcpy (char *yydest, const char *yysrc)
YY_DECL_VARIABLES int yyparse (YYPARSE_PARAM_ARG)
int yyerror (char *msg) const
NODEyycompile (char *f, int line)
VALUE lex_get_str (VALUE s)
VALUE lex_getline ()
NODErb_compile_string (char *f, VALUE s, int line) const
NODErb_compile_cstr (char *f, char *s, int len, int line) const
NODErb_compile_file (char *f, VALUE file, int start) const
int nextc ()
void pushback (int c)
char * newtok ()
void tokadd (char c)
int read_escape ()
int tokadd_escape (int term)
int regx_options ()
void dispose_string (VALUE str)
int tokadd_string (int func, int term, int paren, int *nest)
int parse_string (NODE *quote)
int heredoc_identifier ()
void heredoc_restore (NODE *here)
int whole_match_p (char *eos, int len, int indent)
int here_document (NODE *here)
void arg_ambiguous ()
NODErb_node_newnode (enum node_type type, VALUE a0, VALUE a1, VALUE a2)
enum node_type nodetype (NODE *node)
int nodeline (NODE *node)
NODEnewline_node (NODE *node)
void fixpos (NODE *node, NODE *orig)
void parser_warning (NODE *node, const char *mesg)
void parser_warn (NODE *node, const char *mesg)
NODEblock_append (NODE *head, NODE *tail)
NODElist_append (NODE *list, NODE *item)
NODElist_concat (NODE *head, NODE *tail)
NODEliteral_concat (NODE *head, NODE *tail)
NODEevstr2dstr (NODE *node)
NODEnew_evstr (NODE *node)
NODEcall_op (NODE *recv, ID id, int narg, NODE *arg1)
NODEmatch_gen (NODE *node1, NODE *node2)
NODEgettable (ID id)
NODEassignable (ID id, NODE *val)
NODEaryset (NODE *recv, NODE *idx)
ID rb_id_attrset (ID id)
NODEattrset (NODE *recv, ID id)
void rb_backref_error (NODE *node)
NODEarg_concat (NODE *node1, NODE *node2)
NODEarg_add (NODE *node1, NODE *node2)
NODEnode_assign (NODE *lhs, NODE *rhs)
int value_expr0 (NODE *node)
void void_expr0 (NODE *node)
void void_stmts (NODE *node)
NODEremove_begin (NODE *node)
int assign_in_cond (NODE *node)
int e_option_supplied ()
void warn_unless_e_option (NODE *node, const char *str)
void warning_unless_e_option (NODE *node, const char *str)
NODEcond0 ()
NODErange_op (NODE *node)
int literal_node (NODE *node)
NODEcond0 (NODE *node)
NODEcond (NODE *node)
NODElogop (enum node_type type, NODE *left, NODE *right)
int cond_negative (NODE **nodep)
void no_blockarg (NODE *node)
NODEret_args (NODE *node)
NODEnew_yield (NODE *node)
NODEnegate_lit (NODE *node)
NODEarg_blk_pass (NODE *node1, NODE *node2)
NODEarg_prepend (NODE *node1, NODE *node2)
NODEnew_call (NODE *r, ID m, NODE *a)
NODEnew_fcall (ID m, NODE *a)
NODEnew_super (NODE *a)
void local_push (int top)
int local_append (ID id)
int local_cnt (ID id)
int local_id (ID id)
void dyna_pop (struct RVarmap *vars)
NODEdyna_init (NODE *node, struct RVarmap *pre)
int ruby_parser_stack_on_heap ()
void rb_gc_mark_parser ()
void rb_parser_append_print ()
void rb_parser_while_loop (int chop, int split)
void Init_sym ()
int is_special_global_name (char *m) const
int rb_symname_p (char *name) const
ID rb_intern (char *name) const
char * rb_id2name (ID id)
int symbols_i (char *key, ID value, VALUE ary)
VALUE rb_sym_all_symbols ()
int rb_is_const_id (ID id)
int rb_is_class_id (ID id)
int rb_is_instance_id (ID id)
int rb_is_local_id (ID id)
int rb_is_junk_id (ID id)
void special_local_set (char c, VALUE val)
VALUE rb_backref_get ()
void rb_backref_set (VALUE val)
VALUE rb_lastline_get ()
void rb_lastline_set (VALUE val)

Variables

NODEruby_eval_tree_begin = 0
NODEruby_eval_tree = 0
char * ruby_sourcefile
int ruby_sourceline
enum lex_state lex_state
NODElex_strterm
stack_type cond_stack = 0
stack_type cmdarg_stack = 0
int class_nest = 0
int in_single = 0
int in_def = 0
int compile_for_eval = 0
ID cur_mid = 0
int in_defined = 0
const short yytranslate []
const short yyprhs []
const short yyrhs []
const short yyrline []
const char *const  yytname []
const short yyr1 []
const short yyr2 []
const short yydefact []
const short yydefgoto []
const short yypact []
const short yypgoto []
const short yytable []
const short yycheck []
int yydebug
char * tokenbuf = NULL
int tokidx
int toksiz = 0
VALUE(* lex_gets )()
VALUE lex_input
VALUE lex_lastline
char * lex_pbeg
char * lex_p
char * lex_pend
int heredoc_end
int command_start = Qtrue
int ruby_in_compile = 0
int ruby__end__seen
VALUE ruby_debug_lines
NODEparser_heap
int lex_gets_ptr
local_varslvtbl
struct {
   ID   token
   char *   name
op_tbl []
st_tablesym_tbl
st_tablesym_rev_tbl
ID last_id = tLAST_TOKEN


Define Documentation

#define ADD2HEAP n,
c,
 ) 
 

Value:

((parser_heap = (n))->u1.node = (p), \
                           (n)->u3.cnt = (c), (p))

Definition at line 10240 of file parse.c.

Referenced by rb_parser_calloc(), rb_parser_malloc(), and rb_parser_realloc().

#define BITSTACK_LEXPOP stack   )     (stack = (stack >> 1) | (stack & 1))
 

Definition at line 202 of file parse.c.

#define BITSTACK_POP stack   )     (stack >>= 1)
 

Definition at line 201 of file parse.c.

#define BITSTACK_PUSH stack,
 )     (stack = (stack<<1)|((n)&1))
 

Definition at line 200 of file parse.c.

#define BITSTACK_SET_P stack   )     (stack&1)
 

Definition at line 203 of file parse.c.

#define calloc   YYCALLOC
 

Definition at line 133 of file parse.c.

 
#define CMDARG_LEXPOP  )     BITSTACK_LEXPOP(cmdarg_stack)
 

Definition at line 214 of file parse.c.

Referenced by yyparse().

 
#define CMDARG_P  )     BITSTACK_SET_P(cmdarg_stack)
 

Definition at line 215 of file parse.c.

 
#define CMDARG_POP  )     BITSTACK_POP(cmdarg_stack)
 

Definition at line 213 of file parse.c.

#define CMDARG_PUSH  )     BITSTACK_PUSH(cmdarg_stack, n)
 

Definition at line 212 of file parse.c.

Referenced by yyparse().

 
#define COND_LEXPOP  )     BITSTACK_LEXPOP(cond_stack)
 

Definition at line 208 of file parse.c.

Referenced by yyparse().

 
#define COND_P  )     BITSTACK_SET_P(cond_stack)
 

Definition at line 209 of file parse.c.

 
#define COND_POP  )     BITSTACK_POP(cond_stack)
 

Definition at line 207 of file parse.c.

Referenced by yyparse().

#define COND_PUSH  )     BITSTACK_PUSH(cond_stack, n)
 

Definition at line 206 of file parse.c.

Referenced by yyparse().

#define free   YYFREE
 

Definition at line 134 of file parse.c.

Referenced by blk_free(), dir_initialize(), dir_s_chdir(), dir_s_getwd(), file_expand_path(), frame_free(), free_dir(), free_unused_heaps(), gc_sweep(), glob_helper(), io_reopen(), method_clone(), method_unbind(), mnew(), obj_free(), opt_i_set(), path_check_0(), proc_options(), rand_init(), rb_alias_variable(), rb_ary_replace(), rb_exec_end_proc(), rb_file_s_readlink(), rb_gc_call_finalizer_at_exit(), rb_gc_unregister_address(), rb_io_fptr_finalize(), rb_io_reopen(), rb_load(), rb_reg_initialize(), rb_require_safe(), rb_stat_init(), rb_stat_init_copy(), rb_str_replace(), rb_str_shared_replace(), rb_strftime(), rb_thread_die(), rehash(), remove_trace(), require_libraries(), ruby_getcwd(), ruby_setenv(), ruby_xfree(), st_copy(), st_delete(), st_foreach(), st_free_table(), stat_new_0(), str_gsub(), sweep_source_filename(), thgroup_s_alloc(), thread_free(), time_free(), time_strftime(), and umethod_bind().

#define HEAPCNT n,
size   )     ((n) * (size) / sizeof(YYSTYPE))
 

Definition at line 10238 of file parse.c.

Referenced by rb_parser_calloc(), rb_parser_malloc(), and rb_parser_realloc().

#define ID_ATTRSET   0x04
 

Definition at line 152 of file parse.c.

Referenced by rb_id_attrset(), and rb_intern().

#define ID_CLASS   0x06
 

Definition at line 154 of file parse.c.

Referenced by rb_intern().

#define ID_CONST   0x05
 

Definition at line 153 of file parse.c.

Referenced by rb_id2name(), and rb_intern().

#define ID_GLOBAL   0x03
 

Definition at line 151 of file parse.c.

Referenced by rb_intern().

#define ID_INSTANCE   0x02
 

Definition at line 150 of file parse.c.

Referenced by rb_intern().

#define ID_INTERNAL   ID_JUNK
 

Definition at line 156 of file parse.c.

Referenced by internal_id().

#define ID_JUNK   0x07
 

Definition at line 155 of file parse.c.

Referenced by rb_intern().

#define ID_LOCAL   0x01
 

Definition at line 149 of file parse.c.

Referenced by rb_id2name(), and rb_intern().

#define ID_SCOPE_MASK   0x07
 

Definition at line 148 of file parse.c.

Referenced by rb_id2name(), and rb_id_attrset().

#define ID_SCOPE_SHIFT   3
 

Definition at line 147 of file parse.c.

Referenced by internal_id(), and rb_intern().

 
#define IS_ARG  )     (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
 

Definition at line 7344 of file parse.c.

#define is_asgn_or_id id   ) 
 

Value:

((is_notop_id(id)) && \
        (((id)&ID_SCOPE_MASK) == ID_GLOBAL || \
         ((id)&ID_SCOPE_MASK) == ID_INSTANCE || \
         ((id)&ID_SCOPE_MASK) == ID_CLASS))

Definition at line 167 of file parse.c.

Referenced by yyparse().

#define is_attrset_id id   )     (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET)
 

Definition at line 162 of file parse.c.

Referenced by rb_id2name(), and rb_intern().

#define is_class_id id   )     (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CLASS)
 

Definition at line 164 of file parse.c.

Referenced by assignable(), gettable(), and rb_is_class_id().

#define is_const_id id   )     (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CONST)
 

Definition at line 163 of file parse.c.

Referenced by assignable(), gettable(), and rb_is_const_id().