|
|
| version 1.155, 2001/07/26 12:25:37 | version 1.166, 2001/09/18 16:05:42 |
|---|---|
| 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 242 get: get_value { | Line 241 get: get_value { |
| $$=$1; /* stack: resulting value */ | $$=$1; /* stack: resulting value */ |
| O($$, OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ | O($$, OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ |
| }; | }; |
| get_value: '$' get_name_value { $$=$2 } | get_value: '$' get_name_value { $$=$2 }; |
| get_name_value: name_without_curly_rdive EON | name_in_curly_rdive; | get_name_value: name_without_curly_rdive EON | name_in_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: |
| Line 273 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_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 285 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_write: '.' name_expr_dive_code { | |
| $$=N(POOL); | |
| O($$, OP_WITH_WRITE); /* stack: starting context */ | |
| 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) }; |
| construct: | construct: |
| construct_square | | construct_square |
| construct_round | | | construct_round |
| construct_curly | | construct_curly |
| ; | ; |
| construct_square: '[' any_constructor_code_value ']' { | construct_square: '[' any_constructor_code_value ']' { |
| // stack: context, name | // stack: context, name |
| Line 306 construct_square: '[' any_constructor_co | Line 311 construct_square: '[' any_constructor_co |
| construct_round: '(' expr_value ')' { | construct_round: '(' expr_value ')' { |
| // stack: context, name | // stack: context, name |
| $$=$2; // stack: context, name, value | $$=$2; // stack: context, name, value |
| O($$, OP_CONSTRUCT_EXPR); /* value=pop; name=pop; context=pop; construct(context,name,value) */ | O($$, OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */ |
| } | } |
| ; | ; |
| construct_curly: '{' maybe_codes '}' { | construct_curly: '{' maybe_codes '}' { |
| Line 316 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 387 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 417 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_square_code_value /* [codes] */ | |
| ; | ; |
| name_expr_subvar_value: '$' subvar_ref_name_rdive { | name_expr_subvar_value: '$' subvar_ref_name_rdive { |
| $$=$2; | $$=$2; |
| Line 431 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); |
| }; | }; |
| name_square_code_value: '[' codes ']' { | |
| $$=N(POOL); | |
| O($$, OP_CREATE_EWPOOL); | |
| P($$, $2); | |
| O($$, OP_REDUCE_EWPOOL); | |
| }; | |
| subvar_ref_name_rdive: STRING { | subvar_ref_name_rdive: STRING { |
| $$=N(POOL); | $$=N(POOL); |
| O($$, OP_WITH_READ); | O($$, OP_WITH_READ); |
| Line 475 expr: | Line 487 expr: |
| | '(' expr ')' { $$ = $2; } | | '(' expr ')' { $$ = $2; } |
| /* stack: operand // stack: @operand */ | /* stack: operand // stack: @operand */ |
| | '-' expr %prec NEG { $$=$2; O($$, OP_NEG) } | | '-' expr %prec NEG { $$=$2; O($$, OP_NEG) } |
| | '+' expr %prec NEG { $$=$2 } | |
| | '~' expr { $$=$2; O($$, OP_INV) } | | '~' expr { $$=$2; O($$, OP_INV) } |
| | '!' expr { $$=$2; O($$, OP_NOT) } | | '!' expr { $$=$2; O($$, OP_NOT) } |
| | "def" expr { $$=$2; O($$, OP_DEF) } | | "def" expr { $$=$2; O($$, OP_DEF) } |
| Line 522 write_string: STRING { | Line 535 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 564 static int yylex(YYSTYPE *lvalp, void *p | Line 576 static int yylex(YYSTYPE *lvalp, void *p |
| int skip_analized=0; | int skip_analized=0; |
| while(true) { | while(true) { |
| c=*(end=(PC.source++)); | c=*(end=(PC.source++)); |
| // fprintf(stderr, "\nchar: %c %02X; nestage: %d, sp=%d", c, c, lexical_brackets_nestage, PC.sp); | |
| if(c=='\n') { | if(c=='\n') { |
| PC.line++; | PC.line++; |
| Line 573 static int yylex(YYSTYPE *lvalp, void *p | Line 586 static int yylex(YYSTYPE *lvalp, void *p |
| if(c=='^' && PC.ls!=LS_COMMENT && PC.ls!=LS_DEF_COMMENT) | if(c=='^' && PC.ls!=LS_COMMENT && PC.ls!=LS_DEF_COMMENT) |
| switch(*PC.source) { | switch(*PC.source) { |
| // escaping: ^^ & co | // ^escaping some punctuators |
| case '^': case '$': case ';': | case '^': case '$': case ';': |
| case '(': case ')': | case '(': case ')': |
| case '[': case ']': | case '[': case ']': |
| Line 584 static int yylex(YYSTYPE *lvalp, void *p | Line 597 static int yylex(YYSTYPE *lvalp, void *p |
| PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); | PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); |
| } | } |
| // reset piece 'begin' position & line | // reset piece 'begin' position & line |
| begin=PC.source; // ^ | end=begin=PC.source; // ^ |
| begin_line=PC.line; | begin_line=PC.line; |
| // skip over ^ and _ | if(PC.ls==LS_METHOD_AFTER) { |
| PC.source++; PC.col++; | pop_LS(PC); |
| // skip analysis = forced literal | result=EON; |
| continue; | skip_analized=-1; // return to ^ afterwards to assure it's literality |
| goto break2; | |
| } else { | |
| // skip over _ after ^ | |
| PC.source++; PC.col++; | |
| // skip analysis = forced literal | |
| continue; | |
| } | |
| // converting ^#HH into char(hex(HH)) | // converting ^#HH into char(hex(HH)) |
| case '#': | case '#': |
| Line 632 static int yylex(YYSTYPE *lvalp, void *p | Line 652 static int yylex(YYSTYPE *lvalp, void *p |
| // USER'S = NOT OURS | // USER'S = NOT OURS |
| case LS_USER: | case LS_USER: |
| case LS_NAME_SQUARE_PART: // name.[here].xxx | |
| if(PC.trim_bof) | if(PC.trim_bof) |
| switch(c) { | switch(c) { |
| case '\n': case ' ': case '\t': | case '\n': case ' ': case '\t': |
| Line 643 static int yylex(YYSTYPE *lvalp, void *p | Line 664 static int yylex(YYSTYPE *lvalp, void *p |
| } | } |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE); | push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(PC, LS_METHOD_NAME); |
| Line 654 static int yylex(YYSTYPE *lvalp, void *p | Line 675 static int yylex(YYSTYPE *lvalp, void *p |
| RC; | RC; |
| } | } |
| break; | break; |
| case ']': | |
| if(PC.ls==LS_NAME_SQUARE_PART) | |
| if(--lexical_brackets_nestage==0) {// $name.[co<]?>de<]?> | |
| pop_LS(PC); // $name.[co<]>de<]!> | |
| RC; | |
| } | |
| break; | |
| case '[': // $name.[co<[>de] | |
| if(PC.ls==LS_NAME_SQUARE_PART) | |
| lexical_brackets_nestage++; | |
| break; | |
| } | } |
| break; | break; |
| Line 683 static int yylex(YYSTYPE *lvalp, void *p | Line 715 static int yylex(YYSTYPE *lvalp, void *p |
| } | } |
| break; | break; |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE); | push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(PC, LS_METHOD_NAME); |
| Line 765 static int yylex(YYSTYPE *lvalp, void *p | Line 797 static int yylex(YYSTYPE *lvalp, void *p |
| pop_LS(PC); // return to normal life | pop_LS(PC); // return to normal life |
| RC; | RC; |
| case '$': | case '$': |
| push_LS(PC, LS_EXPRESSION_VAR_NAME); | push_LS(PC, LS_EXPRESSION_VAR_NAME_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(PC, LS_METHOD_NAME); |
| Line 875 static int yylex(YYSTYPE *lvalp, void *p | Line 907 static int yylex(YYSTYPE *lvalp, void *p |
| break; | break; |
| // VARIABLE GET/PUT/WITH | // VARIABLE GET/PUT/WITH |
| case LS_VAR_NAME_SIMPLE: | case LS_VAR_NAME_SIMPLE_WITH_COLON: |
| case LS_EXPRESSION_VAR_NAME: | case LS_VAR_NAME_SIMPLE_WITHOUT_COLON: |
| case LS_VAR_NAME_NO_COLON: | case LS_EXPRESSION_VAR_NAME_WITH_COLON: |
| if(PC.ls==LS_EXPRESSION_VAR_NAME) { | case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON: |
| if( | |
| PC.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON || | |
| PC.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) { | |
| // name in expr ends also before binary operators | // name in expr ends also before binary operators |
| switch(c) { | switch(c) { |
| case '-': | case '-': |
| Line 888 static int yylex(YYSTYPE *lvalp, void *p | Line 923 static int yylex(YYSTYPE *lvalp, void *p |
| goto break2; | goto break2; |
| } | } |
| } | } |
| if(PC.ls==LS_VAR_NAME_NO_COLON) { | if( |
| PC.ls==LS_VAR_NAME_SIMPLE_WITHOUT_COLON || | |
| PC.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) { | |
| // name already has ':', stop before next | // name already has ':', stop before next |
| switch(c) { | switch(c) { |
| case ':': | case ':': |
| Line 909 static int yylex(YYSTYPE *lvalp, void *p | Line 946 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 917 static int yylex(YYSTYPE *lvalp, void *p | Line 954 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 start of get*/ || | |
| end[-1]==':'/*was class name delim */ || | |
| end[-1]=='.'/*was name delim */ | |
| )) { | |
| push_LS(PC, LS_NAME_SQUARE_PART); | |
| 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 935 static int yylex(YYSTYPE *lvalp, void *p | Line 982 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 ':' | // go to _WITHOUT_COLON state variant... |
| if(PC.ls==LS_VAR_NAME_SIMPLE_WITH_COLON) | |
| PC.ls=LS_VAR_NAME_SIMPLE_WITHOUT_COLON; | |
| else if(PC.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON) | |
| PC.ls=LS_EXPRESSION_VAR_NAME_WITHOUT_COLON; | |
| // ...stop before next ':' | |
| RC; | RC; |
| } | } |
| break; | break; |
| case LS_VAR_NAME_CURLY: | case LS_VAR_NAME_CURLY: |
| switch(c) { | switch(c) { |
| case '[': | |
| // ${name.<[>code]} | |
| push_LS(PC, LS_NAME_SQUARE_PART); | |
| lexical_brackets_nestage=1; | |
| RC; | |
| case '}': // ${name} finished, restoring LS | case '}': // ${name} finished, restoring LS |
| pop_LS(PC); | pop_LS(PC); |
| RC; | RC; |
| Line 956 static int yylex(YYSTYPE *lvalp, void *p | Line 1013 static int yylex(YYSTYPE *lvalp, void *p |
| case LS_VAR_SQUARE: | case LS_VAR_SQUARE: |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE); | push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(PC, LS_METHOD_NAME); |
| Line 978 static int yylex(YYSTYPE *lvalp, void *p | Line 1035 static int yylex(YYSTYPE *lvalp, void *p |
| case LS_VAR_CURLY: | case LS_VAR_CURLY: |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE); | push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(PC, LS_METHOD_NAME); |
| Line 999 static int yylex(YYSTYPE *lvalp, void *p | Line 1056 static int yylex(YYSTYPE *lvalp, void *p |
| case LS_METHOD_NAME: | case LS_METHOD_NAME: |
| switch(c) { | switch(c) { |
| case '[': | case '[': |
| // ^name.<[>code].xxx | |
| if(PC.col>1/*not first column*/ && ( | |
| end[-1]=='^'/*was start of call*/ || // never, ^[ is literal... | |
| end[-1]==':'/*was class name delim */ || | |
| end[-1]=='.'/*was name delim */ | |
| )) { | |
| push_LS(PC, LS_NAME_SQUARE_PART); | |
| 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; |
| Line 1020 static int yylex(YYSTYPE *lvalp, void *p | Line 1087 static int yylex(YYSTYPE *lvalp, void *p |
| case LS_METHOD_SQUARE: | case LS_METHOD_SQUARE: |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE); | push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(PC, LS_METHOD_NAME); |
| Line 1042 static int yylex(YYSTYPE *lvalp, void *p | Line 1109 static int yylex(YYSTYPE *lvalp, void *p |
| case LS_METHOD_CURLY: | case LS_METHOD_CURLY: |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE); | push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(PC, LS_METHOD_NAME); |