|
|
| version 1.298, 2024/09/28 14:37:53 | version 1.301, 2024/12/03 04:07:02 |
|---|---|
| Line 2 | Line 2 |
| /** @file | /** @file |
| Parser: compiler(lexical parser and grammar). | Parser: compiler(lexical parser and grammar). |
| Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) |
| Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| Line 653 name_expr_value: | Line 653 name_expr_value: |
| | 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_square_code_value /* [codes] */ |
| | name_round_expr_value /* (expr) */ | |
| ; | ; |
| name_expr_subvar_value: '$' subvar_ref_name_rdive { | name_expr_subvar_value: '$' subvar_ref_name_rdive { |
| $$=$2; | $$=$2; |
| Line 683 name_square_code_value: '[' { | Line 684 name_square_code_value: '[' { |
| /* context=pop; stack: context.value() */ | /* context=pop; stack: context.value() */ |
| } | } |
| }; | }; |
| name_round_expr_value: '(' expr_value ')' { | |
| $$ = N(); | |
| P(*$$, *$2); | |
| }; | |
| subvar_ref_name_rdive: STRING { | subvar_ref_name_rdive: STRING { |
| $$=N(); | $$=N(); |
| O(*$$, OP::OP_WITH_READ); | O(*$$, OP::OP_WITH_READ); |
| Line 1367 default: | Line 1372 default: |
| goto break2; | goto break2; |
| case '[': | case '[': |
| // $name.<[>code] | // $name.<[>code] |
| if(pc.pos.col>1/*not first column*/ && ( | if( end[-1]=='$' /* was start of get */ || |
| end[-1]=='$'/*was start of get*/ || | end[-1]==':' /* was class name delim */ || |
| end[-1]==':'/*was class name delim */ || | end[-1]=='.' /* was name delim */ |
| end[-1]=='.'/*was name delim */ | ) { |
| )) { | |
| push_LS(pc, LS_NAME_SQUARE_PART); | push_LS(pc, LS_NAME_SQUARE_PART); |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| Line 1380 default: | Line 1384 default: |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '{': | case '{': |
| if(begin==end) { // ${name}, no need of EON, switching LS | if(end[-1]=='$') { // ${name}, no need of EON, switching LS, not begin==end as $[a]{$b} will fit |
| pc.ls=LS_VAR_NAME_CURLY; | pc.ls=LS_VAR_NAME_CURLY; |
| } else { | } else { |
| pc.ls=LS_VAR_CURLY; | pc.ls=LS_VAR_CURLY; |
| Line 1389 default: | Line 1393 default: |
| RC; | RC; |
| case '(': | case '(': |
| // $name.<(>expr) | |
| if( // end[-1]=='$' /* $() excluded */ || | |
| end[-1]==':' /* was class name delim */ || | |
| end[-1]=='.' /* was name delim */ | |
| ) { | |
| push_LS(pc, LS_VAR_ROUND); | |
| lexical_brackets_nestage=1; | |
| RC; | |
| } | |
| pc.ls=LS_VAR_ROUND; | pc.ls=LS_VAR_ROUND; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| Line 1412 default: | Line 1425 default: |
| push_LS(pc, LS_NAME_SQUARE_PART); | push_LS(pc, LS_NAME_SQUARE_PART); |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '(': | |
| // ${name.<(>expr)} | |
| push_LS(pc, LS_VAR_ROUND); | |
| lexical_brackets_nestage=1; | |
| RC; | |
| case '}': // ${name} finished, restoring LS | case '}': // ${name} finished, restoring LS |
| pop_LS(pc); | pop_LS(pc); |
| RC; | RC; |
| Line 1468 default: | Line 1486 default: |
| case LS_METHOD_NAME: | case LS_METHOD_NAME: |
| switch(c) { | switch(c) { |
| case '[': | case '[': |
| // ^name.<[>code].xxx | // ^name.<[>code] |
| if(pc.pos.col>1/*not first column*/ && ( | if( // end[-1]=='^' /* never, ^[ is literal */ || |
| end[-1]=='^'/*was start of call*/ || // never, ^[ is literal... | end[-1]==':' /* was class name delim */ || |
| end[-1]==':'/*was class name delim */ || | end[-1]=='.' /* was name delim */ |
| end[-1]=='.'/*was name delim */ | ) { |
| )) { | |
| push_LS(pc, LS_NAME_SQUARE_PART); | push_LS(pc, LS_NAME_SQUARE_PART); |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| Line 1486 default: | Line 1503 default: |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '(': | case '(': |
| // ^name.<(>expr) | |
| if( // end[-1]=='^' /* never, ^( is literal */ || | |
| end[-1]==':' /* was class name delim */ || | |
| end[-1]=='.' /* was name delim */ | |
| ) { | |
| push_LS(pc, LS_VAR_ROUND); | |
| lexical_brackets_nestage=1; | |
| RC; | |
| } | |
| pc.ls=LS_METHOD_ROUND; | pc.ls=LS_METHOD_ROUND; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |