^ для индексера

This commit is contained in:
Александр Погорелов 2020-04-03 11:48:15 +03:00
parent 9cf75580a5
commit 7f4a8cec42
4 changed files with 2091 additions and 2055 deletions

View file

@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-P4NLNB1
// DateTime: 3/9/2020 1:37:31 PM
// DateTime: 4/3/2020 11:47:29 AM
// UserName: fatco
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>

View file

@ -85,7 +85,7 @@
%type <ex> const_simple_expr term term1 simple_term typed_const typed_const_plus typed_var_init_expression expr expr_with_func_decl_lambda const_expr elem range_expr const_elem array_const factor relop_expr expr_dq expr_l1 expr_l1_func_decl_lambda expr_l1_for_lambda simple_expr range_term range_factor
%type <ex> external_directive_ident init_const_expr case_label variable var_reference /*optional_write_expr*/ optional_read_expr /*simple_expr_or_nothing*/ var_question_point expr_l1_for_question_expr expr_l1_for_new_question_expr
%type <ob> for_cycle_type
%type <ex> format_expr format_const_expr const_expr_or_nothing simple_expr_with_deref_or_nothing simple_expr_with_deref
%type <ex> format_expr format_const_expr const_expr_or_nothing simple_expr_with_deref_or_nothing simple_expr_with_deref /*expr_l1_for_indexer*/
%type <stn> foreach_stmt
%type <stn> for_stmt loop_stmt yield_stmt yield_sequence_stmt
%type <stn> fp_list fp_sect_list
@ -3119,9 +3119,20 @@ expr_with_func_decl_lambda
expr
: expr_l1
{ $$ = $1; }
| tkDeref expr_l1
{ $$ = new simple_expr_with_deref($2, true); }
| format_expr
{ $$ = $1; }
;
/*
expr_l1_for_indexer
: tkDeref expr_l1
{ $$ = new simple_expr_with_deref($2, true); }
| expr_l1
{ $$ = $1; }
| format_expr
{ $$ = $1; }
;*/
expr_l1
: expr_dq
@ -4061,7 +4072,7 @@ variable
}
$$ = new slice_expr($1 as addressed_value,fe.expr,fe.format1,fe.format2,fe.index_inversion_from,fe.index_inversion_to,@$);
}
else $$ = new indexer($1 as addressed_value,el, @$);
else $$ = new indexer($1 as addressed_value, el, @$);
}
| variable tkQuestionSquareOpen format_expr tkSquareClose
{

File diff suppressed because it is too large Load diff

View file

@ -51,6 +51,24 @@ namespace SyntaxVisitors.SugarVisitors
_assign.to.visit(this);
}
public override void visit(indexer indexer)
{
for (int i = 0; i < indexer.indexes.expressions.Count; ++i)
{
var ind = indexer.indexes.expressions[i];
if (ind is simple_expr_with_deref indWithDeref)
{
var countCall = new dot_node(
indexer.dereferencing_value,
new ident("Count", ind.source_context),
ind.source_context);
var inversedIndex = new bin_expr(countCall, indWithDeref.simple_expr, Operators.Minus, ind.source_context);
ReplaceUsingParent(ind, inversedIndex);
}
}
}
public override void visit(slice_expr sl)
{
var el = construct_expression_list_for_slice_expr(sl);