|
|
| version 1.152, 2001/07/25 11:16:57 | version 1.162, 2001/08/10 13:03:05 |
|---|---|
| Line 151 control_method: '@' STRING '\n' | Line 151 control_method: '@' STRING '\n' |
| } | } |
| } else if(command==USE_CONTROL_METHOD_NAME) { | } else if(command==USE_CONTROL_METHOD_NAME) { |
| for(int i=0; i<strings_code->size(); i+=2) | for(int i=0; i<strings_code->size(); i+=2) |
| PC.request->use_file( | PC.request->use_file(*LA2S(strings_code, i)); |
| PC.request->absolute(*LA2S(strings_code, i))); | |
| } else if(command==BASE_NAME) { | } else if(command==BASE_NAME) { |
| if(PC.cclass->base()) { // already changed from default? | if(PC.cclass->base()) { // already changed from default? |
| strcpy(PC.error, "class already have a base '"); | strcpy(PC.error, "class already have a base '"); |
| Line 247 get_name_value: name_without_curly_rdive | Line 246 get_name_value: name_without_curly_rdive |
| name_in_curly_rdive: '{' name_without_curly_rdive '}' { $$=$2 }; | name_in_curly_rdive: '{' name_without_curly_rdive '}' { $$=$2 }; |
| name_without_curly_rdive: | name_without_curly_rdive: |
| name_without_curly_rdive_read | name_without_curly_rdive_read |
| | name_without_curly_rdive_root | |
| | name_without_curly_rdive_class; | | name_without_curly_rdive_class; |
| name_without_curly_rdive_read: name_without_curly_rdive_code { | name_without_curly_rdive_read: name_without_curly_rdive_code { |
| $$=N(POOL); | $$=N(POOL); |
| Line 264 name_without_curly_rdive_read: name_with | Line 262 name_without_curly_rdive_read: name_with |
| } | } |
| /* diving code; stack: current context */ | /* diving code; stack: current context */ |
| }; | }; |
| name_without_curly_rdive_root: ':' name_without_curly_rdive_code { | |
| $$=N(POOL); | |
| O($$, OP_WITH_ROOT); /* stack: starting context */ | |
| P($$, $2); /* diving code; stack: current context */ | |
| }; | |
| name_without_curly_rdive_class: class_prefix name_without_curly_rdive_code { $$=$1; P($$, $2) }; | name_without_curly_rdive_class: class_prefix name_without_curly_rdive_code { $$=$1; P($$, $2) }; |
| name_without_curly_rdive_code: name_advance2 | name_path name_advance2 { $$=$1; P($$, $2) }; | name_without_curly_rdive_code: name_advance2 | name_path name_advance2 { $$=$1; P($$, $2) }; |
| Line 279 put: '$' name_expr_wdive construct { | Line 272 put: '$' name_expr_wdive construct { |
| P($$, $3); /* stack: context,name,constructor_value */ | P($$, $3); /* stack: context,name,constructor_value */ |
| }; | }; |
| name_expr_wdive: | name_expr_wdive: |
| name_expr_wdive_write | name_expr_wdive_root |
| | name_expr_wdive_root | | name_expr_wdive_write |
| | name_expr_wdive_class; | | name_expr_wdive_class; |
| name_expr_wdive_write: name_expr_dive_code { | name_expr_wdive_root: name_expr_dive_code { |
| $$=N(POOL); | $$=N(POOL); |
| Array *diving_code=$1; | Array *diving_code=$1; |
| const String *first_name=LA2S(diving_code); | const String *first_name=LA2S(diving_code); |
| Line 292 name_expr_wdive_write: name_expr_dive_co | Line 285 name_expr_wdive_write: name_expr_dive_co |
| /* skip over... */ | /* skip over... */ |
| diving_code->size()>2?3/*OP_+string+get_element*/:2/*OP_+string*/); | diving_code->size()>2?3/*OP_+string+get_element*/:2/*OP_+string*/); |
| } else { | } else { |
| O($$, OP_WITH_WRITE); /* stack: starting context */ | O($$, OP_WITH_ROOT); /* stack: starting context */ |
| P($$, diving_code); | P($$, diving_code); |
| } | } |
| /* diving code; stack: current context */ | /* diving code; stack: current context */ |
| }; | }; |
| name_expr_wdive_root: ':' name_expr_dive_code { | name_expr_wdive_write: '.' name_expr_dive_code { |
| $$=N(POOL); | $$=N(POOL); |
| O($$, OP_WITH_ROOT); /* stack: starting context */ | O($$, OP_WITH_WRITE); /* stack: starting context */ |
| P($$, $2); /* diving code; stack: context,name */ | P($$, $2); /* diving code; stack: context,name */ |
| }; | }; |
| name_expr_wdive_class: class_prefix name_expr_dive_code { $$=$1; P($$, $2) }; | name_expr_wdive_class: class_prefix name_expr_dive_code { $$=$1; P($$, $2) }; |
| Line 328 construct_curly: '{' maybe_codes '}' { | Line 321 construct_curly: '{' maybe_codes '}' { |
| }; | }; |
| any_constructor_code_value: | any_constructor_code_value: |
| empty_string_value /* optimized $var[] case */ | void_value /* optimized $var[] case */ |
| | STRING /* optimized $var[STRING] case */ | | STRING /* optimized $var[STRING] case */ |
| | constructor_code_value /* $var[something complex] */ | | constructor_code_value /* $var[something complex] */ |
| ; | ; |
| Line 347 call: call_value { | Line 340 call: call_value { |
| $$=$1; /* stack: value */ | $$=$1; /* stack: value */ |
| O($$, OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ | O($$, OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ |
| }; | }; |
| call_value: '^' call_name store_params EON { /* ^field.$method{vasya} */ | call_value: '^' { PC.object_constructor_allowed=true } |
| $$=$2; /* with_xxx,diving code; stack: context,method_junction */ | call_name { PC.object_constructor_allowed=false } |
| store_params EON { /* ^field.$method{vasya} */ | |
| $$=$3; /* with_xxx,diving code; stack: context,method_junction */ | |
| O($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */ | O($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */ |
| YYSTYPE params_code=$3; | YYSTYPE params_code=$5; |
| if(params_code->size()==3) // probably [] case. [OP_VALUE + Void + STORE_PARAM] | if(params_code->size()==3) // probably [] case. [OP_VALUE + Void + STORE_PARAM] |
| if(Value *value=LA2V(params_code)) // it is OP_VALUE + value? | if(Value *value=LA2V(params_code)) // it is OP_VALUE + value? |
| if(!value->is_defined()) // value is VVoid? | if(!value->is_defined()) // value is VVoid? |
| Line 397 store_curly_param_part: maybe_codes { | Line 392 store_curly_param_part: maybe_codes { |
| PCA($$, $1); | PCA($$, $1); |
| }; | }; |
| code_param_value: | code_param_value: |
| empty_void_value /* optimized [;...] case */ | void_value /* optimized [;...] case */ |
| | STRING /* optimized [STRING] case */ | | STRING /* optimized [STRING] case */ |
| | constructor_code_value /* [something complex] */ | | constructor_code_value /* [something complex] */ |
| ; | ; |
| Line 427 name_advance2: name_expr_value { | Line 422 name_advance2: name_expr_value { |
| name_expr_value: | name_expr_value: |
| STRING /* subname_is_const */ | STRING /* subname_is_const */ |
| | name_expr_subvar_value /* $subname_is_var_value */ | | name_expr_subvar_value /* $subname_is_var_value */ |
| | name_expr_with_subvar_value /* xxx$part_of_subname_is_var_value[$...] */ | | name_expr_with_subvar_value /* xxx$part_of_subname_is_var_value */ |
| | name_curly_code_value /* (codes) */ | |
| ; | ; |
| name_expr_subvar_value: '$' subvar_ref_name_rdive { | name_expr_subvar_value: '$' subvar_ref_name_rdive { |
| $$=$2; | $$=$2; |
| Line 441 name_expr_with_subvar_value: STRING subv | Line 437 name_expr_with_subvar_value: STRING subv |
| P($$, $2); | P($$, $2); |
| O($$, OP_REDUCE_EWPOOL); | O($$, OP_REDUCE_EWPOOL); |
| }; | }; |
| subvar_ref_name_rdive: subvar_ref_name_rdive_read | subvar_ref_name_rdive_root; | name_curly_code_value: '[' codes ']' { |
| subvar_ref_name_rdive_read: STRING { | |
| $$=N(POOL); | $$=N(POOL); |
| O($$, OP_WITH_READ); | O($$, OP_CREATE_EWPOOL); |
| P($$, $1); | P($$, $2); |
| O($$, OP_REDUCE_EWPOOL); | |
| }; | }; |
| subvar_ref_name_rdive_root: ':' STRING { | subvar_ref_name_rdive: STRING { |
| $$=N(POOL); | $$=N(POOL); |
| O($$, OP_WITH_ROOT); | O($$, OP_WITH_READ); |
| P($$, $2); | P($$, $1); |
| }; | }; |
| subvar_get_writes: subvar__get_write | subvar_get_writes subvar__get_write { $$=$1; P($$, $2) }; | subvar_get_writes: subvar__get_write | subvar_get_writes subvar__get_write { $$=$1; P($$, $2) }; |
| subvar__get_write: '$' subvar_ref_name_rdive { | subvar__get_write: '$' subvar_ref_name_rdive { |
| Line 458 subvar__get_write: '$' subvar_ref_name_r | Line 454 subvar__get_write: '$' subvar_ref_name_r |
| O($$, OP_GET_ELEMENT__WRITE); | O($$, OP_GET_ELEMENT__WRITE); |
| }; | }; |
| class_prefix: STRING ':' { | class_prefix: |
| class_static_prefix | |
| | class_constructor_prefix | |
| ; | |
| class_static_prefix: STRING ':' { | |
| $$=$1; // stack: class name string | $$=$1; // stack: class name string |
| O($$, OP_GET_CLASS); | O($$, OP_GET_CLASS); |
| }; | }; |
| class_constructor_prefix: class_static_prefix ':' { | |
| $$=$1; | |
| if(!PC.object_constructor_allowed) { | |
| strcpy(PC.error, ":: not allowed here"); | |
| YYERROR; | |
| } | |
| O($$, OP_PREPARE_TO_CONSTRUCT_OBJECT); | |
| }; | |
| /* expr */ | /* expr */ |
| Line 526 write_string: STRING { | Line 534 write_string: STRING { |
| change_string_literal_to_write_string_literal($$=$1) | change_string_literal_to_write_string_literal($$=$1) |
| }; | }; |
| empty_void_value: /* empty */ { $$=VL(NEW VVoid(POOL)) }; | void_value: /* empty */ { $$=VL(NEW VVoid(POOL)) }; |
| empty_string_value: /* empty */ { $$=VL(NEW VString(POOL)) }; | |
| empty: /* empty */ { $$=N(POOL) }; | empty: /* empty */ { $$=N(POOL) }; |
| %% | %% |
| Line 636 static int yylex(YYSTYPE *lvalp, void *p | Line 643 static int yylex(YYSTYPE *lvalp, void *p |
| // USER'S = NOT OURS | // USER'S = NOT OURS |
| case LS_USER: | case LS_USER: |
| if(PC.skipping_bof_empty_lines) | if(PC.trim_bof) |
| if(c=='\n') { | switch(c) { |
| case '\n': case ' ': case '\t': | |
| begin=PC.source; | begin=PC.source; |
| begin_line=PC.line; | begin_line=PC.line; |
| continue; // skip it | continue; // skip it |
| default: | |
| PC.trim_bof=false; | |
| } | } |
| PC.skipping_bof_empty_lines=false; | |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE); | push_LS(PC, LS_VAR_NAME_SIMPLE); |
| Line 656 static int yylex(YYSTYPE *lvalp, void *p | Line 665 static int yylex(YYSTYPE *lvalp, void *p |
| RC; | RC; |
| } | } |
| break; | break; |
| case ']': // $name.(code<)> | |
| if(--lexical_brackets_nestage==0) { | |
| pop_LS(PC); | |
| RC; | |
| } | |
| break; | |
| case '[': | |
| lexical_brackets_nestage++; | |
| break; | |
| } | } |
| break; | break; |
| Line 911 static int yylex(YYSTYPE *lvalp, void *p | Line 929 static int yylex(YYSTYPE *lvalp, void *p |
| case '&': case '|': | case '&': case '|': |
| case '=': case '!': | case '=': case '!': |
| // common delimiters | // common delimiters |
| case ',': | case ',': case '?': |
| // before call | // before call |
| case '^': | case '^': |
| pop_LS(PC); | pop_LS(PC); |
| Line 919 static int yylex(YYSTYPE *lvalp, void *p | Line 937 static int yylex(YYSTYPE *lvalp, void *p |
| result=EON; | result=EON; |
| goto break2; | goto break2; |
| case '[': | case '[': |
| // $name.<[>code] | |
| if(PC.col>1/*not first column*/ && ( | |
| end[-1]=='.'/*was dot */ || | |
| end[-1]=='$'/*was start of get*/ | |
| )) { | |
| push_LS(PC, LS_USER); | |
| lexical_brackets_nestage=1; | |
| RC; | |
| } | |
| PC.ls=LS_VAR_SQUARE; | PC.ls=LS_VAR_SQUARE; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| Line 937 static int yylex(YYSTYPE *lvalp, void *p | Line 964 static int yylex(YYSTYPE *lvalp, void *p |
| RC; | RC; |
| case '.': // name part delim | case '.': // name part delim |
| case '$': // name part subvar | case '$': // name part subvar |
| case ':': // ':name' or 'class:name' | case ':': // class<:>name |
| PC.ls=LS_VAR_NAME_NO_COLON; // stop before next ':' | PC.ls=LS_VAR_NAME_NO_COLON; // stop before next ':' |
| RC; | RC; |
| } | } |
| Line 945 static int yylex(YYSTYPE *lvalp, void *p | Line 972 static int yylex(YYSTYPE *lvalp, void *p |
| case LS_VAR_NAME_CURLY: | case LS_VAR_NAME_CURLY: |
| switch(c) { | switch(c) { |
| case '[': | |
| // ${name.<[>code)} | |
| push_LS(PC, LS_USER); | |
| lexical_brackets_nestage=1; | |
| RC; | |
| case '}': // ${name} finished, restoring LS | case '}': // ${name} finished, restoring LS |
| pop_LS(PC); | pop_LS(PC); |
| RC; | RC; |
| Line 1001 static int yylex(YYSTYPE *lvalp, void *p | Line 1033 static int yylex(YYSTYPE *lvalp, void *p |
| case LS_METHOD_NAME: | case LS_METHOD_NAME: |
| switch(c) { | switch(c) { |
| case '[': | case '[': |
| // $name.<[>code) | |
| if(PC.col>1/*not first column*/ && ( | |
| end[-1]=='.'/*was dot */ || | |
| end[-1]=='^'/*was start of call*/ | |
| )) { | |
| push_LS(PC, LS_USER); | |
| lexical_brackets_nestage=1; | |
| RC; | |
| } | |
| PC.ls=LS_METHOD_SQUARE; | PC.ls=LS_METHOD_SQUARE; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |