From 884efe7c5ecfe5bf0621008b7a535729b4c07b97 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 19 Feb 2003 09:27:49 +0000 Subject: * node.h (nd_cpath): nested class/module declaration. [EXPREIMENTAL] * eval.c (rb_eval): ditto. * gc.c (rb_gc_mark_children): ditto. * parse.y (cpath): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 0c04a40bea..2d0682f929 100644 --- a/parse.y +++ b/parse.y @@ -240,7 +240,7 @@ static void top_local_setup(); %type singleton strings string string1 xstring regexp %type string_contents xstring_contents string_content %type words qwords word_list qword_list word -%type literal numeric dsym +%type literal numeric dsym cbase cpath %type bodystmt compstmt stmts stmt expr arg primary command command_call method_call %type expr_value arg_value primary_value %type if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure @@ -837,6 +837,27 @@ cname : tIDENTIFIER | tCONSTANT ; +cbase : tCOLON3 cname + { + $$ = NEW_COLON3($2); + } + | cname + { + $$ = NEW_CONST($1); + } + | cbase tCOLON2 cname + { + $$ = NEW_COLON2($1, $3); + } + ; + +cpath : cbase + { + if (nd_type($$ = $1) == NODE_CONST) + $$ = NEW_COLON2(0, $$->nd_vid); + } + ; + fname : tIDENTIFIER | tCONSTANT | tFID @@ -1525,7 +1546,7 @@ primary : literal $$ = NEW_FOR($2, $5, $8); fixpos($$, $2); } - | kCLASS cname superclass + | kCLASS cpath superclass { if (in_def || in_single) yyerror("class definition in method body"); @@ -1563,7 +1584,7 @@ primary : literal in_def = $4; in_single = $6; } - | kMODULE cname + | kMODULE cpath { if (in_def || in_single) yyerror("module definition in method body"); -- cgit v1.2.3