--- parser3/src/main/compile.y 2001/05/10 12:42:34 1.131 +++ parser3/src/main/compile.y 2001/05/23 06:54:47 1.137 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.y,v 1.131 2001/05/10 12:42:34 paf Exp $ + $Id: compile.y,v 1.137 2001/05/23 06:54:47 parser Exp $ */ /** @@ -28,15 +28,13 @@ #define yyerror(msg) real_yyerror((parse_control *)pc, msg) #define YYPRINT(file, type, value) yyprint(file, type, value) -#include "pa_config_includes.h" - #include "compile_tools.h" #include "pa_value.h" #include "pa_request.h" #include "pa_vobject.h" #include "pa_vdouble.h" #include "pa_globals.h" -#include "pa_vunknown.h" +#include "pa_vnothing.h" #define SELF_ELEMENT_NAME "self" #define USE_CONTROL_METHOD_NAME "USE" @@ -125,7 +123,7 @@ one_big_piece: maybe_codes; method: control_method | code_method; control_method: '@' STRING '\n' - control_strings { + maybe_control_strings { const String& command=*LA2S($2); YYSTYPE strings_code=$4; if(command==END_CONTROL_METHOD_NAME && strings_code->size()==0) @@ -160,7 +158,7 @@ control_method: '@' STRING '\n' PC.request->use_file( PC.request->absolute(*LA2S(strings_code, i))); } else if(command==BASE_NAME) { - if(PC.cclass->base()) { // already changed from default? + if(PC.cclass->base()!=&PC.request->OP) { // already changed from default? strcpy(PC.error, "class already have a base '"); strncat(PC.error, PC.cclass->base()->name().cstr(), 100); strcat(PC.error, "'"); @@ -193,6 +191,7 @@ control_method: '@' STRING '\n' YYERROR; } }; +maybe_control_strings: empty | control_strings; control_strings: control_string | control_strings control_string { $$=$1; P($$, $2) }; control_string: maybe_string '\n'; maybe_string: empty | STRING; @@ -345,9 +344,9 @@ call_value: '^' call_name store_params E O($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */ YYSTYPE params_code=$3; - if(params_code->size()==3) // probably [] case. [OP_VALUE + Unknown + STORE_PARAM] + if(params_code->size()==3) // probably [] case. [OP_VALUE + Nothing + STORE_PARAM] if(Value *value=LA2V(params_code)) // it is OP_VALUE + value? - if(!value->is_defined()) // value is VUnknown? + if(!value->is_defined()) // value is VNothing? params_code=0; // ^zzz[] case. don't append lone empty param. if(params_code) P($$, params_code); // filling method_frame.store_params @@ -528,7 +527,7 @@ write_string: STRING { change_string_literal_to_write_string_literal($$=$1) }; -unknown_value: /* empty */ { $$=VL(NEW VUnknown(POOL)) }; +unknown_value: /* empty */ { $$=VL(NEW VNothing(POOL)) }; empty: /* empty */ { $$=N(POOL) }; %% @@ -1060,8 +1059,10 @@ break2: if((c=='@' || c==0) && end[-1]=='\n') { // we are before LS_DEF_NAME or EOF? // strip last \n end--; + if(end!=begin && end[-1]=='\n') // allow one empty line before LS_DEF_NAME + end--; } - if(end!=begin) { // last piece still alive? + if(end!=begin && PC.ls!=LS_COMMENT) { // last piece still alive and not comment? // append it PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line/*, start_col*/); }