Правки для slice_expr_question
This commit is contained in:
parent
b74473a57d
commit
3abae412a2
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-P4NLNB1
|
||||
// DateTime: 2/24/2020 4:29:36 PM
|
||||
// DateTime: 3/5/2020 11:52:52 AM
|
||||
// UserName: fatco
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -939,7 +939,7 @@ const_variable
|
|||
if (fe.format1 == null)
|
||||
fe.format1 = new int32_const(int.MaxValue,@3);
|
||||
}
|
||||
$$ = new slice_expr($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$);
|
||||
$$ = new slice_expr($1 as addressed_value,fe.expr,fe.format1,fe.format2,fe.index_inversion_from,fe.index_inversion_to,@$);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -2719,7 +2719,7 @@ assignment
|
|||
if (fe.format1 == null)
|
||||
fe.format1 = new int32_const(int.MaxValue,@3);
|
||||
}
|
||||
$$ = new slice_expr_question($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$);
|
||||
$$ = new slice_expr_question($1 as addressed_value,fe.expr,fe.format1,fe.format2,fe.index_inversion_from,fe.index_inversion_to,@$);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -4081,7 +4081,7 @@ variable
|
|||
if (fe.format1 == null)
|
||||
fe.format1 = new int32_const(int.MaxValue,@3);
|
||||
}
|
||||
$$ = new slice_expr_question($1 as addressed_value,fe.expr,fe.format1,fe.format2,@$);
|
||||
$$ = new slice_expr_question($1 as addressed_value,fe.expr,fe.format1,fe.format2,fe.index_inversion_from,fe.index_inversion_to,@$);
|
||||
}
|
||||
| variable tkRoundOpen optional_expr_list tkRoundClose
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// GPPG version 1.3.6
|
||||
// Machine: DESKTOP-P4NLNB1
|
||||
// DateTime: 2/24/2020 4:29:36 PM
|
||||
// DateTime: 3/5/2020 11:52:52 AM
|
||||
// UserName: fatco
|
||||
// Input file <ABCPascal.y>
|
||||
|
||||
|
|
@ -3438,7 +3438,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
if (fe.format1 == null)
|
||||
fe.format1 = new int32_const(int.MaxValue,LocationStack[LocationStack.Depth-2]);
|
||||
}
|
||||
CurrentSemanticValue.ex = new slice_expr(ValueStack[ValueStack.Depth-4].ex as addressed_value,fe.expr,fe.format1,fe.format2,CurrentLocationSpan);
|
||||
CurrentSemanticValue.ex = new slice_expr(ValueStack[ValueStack.Depth-4].ex as addressed_value,fe.expr,fe.format1,fe.format2,fe.index_inversion_from,fe.index_inversion_to,CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 164: // const_variable_2 -> tkPoint, identifier_or_keyword
|
||||
|
|
@ -5132,7 +5132,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
if (fe.format1 == null)
|
||||
fe.format1 = new int32_const(int.MaxValue,LocationStack[LocationStack.Depth-4]);
|
||||
}
|
||||
CurrentSemanticValue.stn = new slice_expr_question(ValueStack[ValueStack.Depth-6].ex as addressed_value,fe.expr,fe.format1,fe.format2,CurrentLocationSpan);
|
||||
CurrentSemanticValue.stn = new slice_expr_question(ValueStack[ValueStack.Depth-6].ex as addressed_value,fe.expr,fe.format1,fe.format2,fe.index_inversion_from,fe.index_inversion_to,CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 507: // variable_list -> variable
|
||||
|
|
@ -6445,7 +6445,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
if (fe.format1 == null)
|
||||
fe.format1 = new int32_const(int.MaxValue,LocationStack[LocationStack.Depth-2]);
|
||||
}
|
||||
CurrentSemanticValue.ex = new slice_expr_question(ValueStack[ValueStack.Depth-4].ex as addressed_value,fe.expr,fe.format1,fe.format2,CurrentLocationSpan);
|
||||
CurrentSemanticValue.ex = new slice_expr_question(ValueStack[ValueStack.Depth-4].ex as addressed_value,fe.expr,fe.format1,fe.format2,fe.index_inversion_from,fe.index_inversion_to,CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 763: // variable -> variable, tkRoundOpen, optional_expr_list, tkRoundClose
|
||||
|
|
|
|||
|
|
@ -1761,6 +1761,10 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{ }
|
||||
public slice_expr_question(addressed_value v, expression from, expression to, expression step, SourceContext sc) : base(v, from, to, step, sc)
|
||||
{ }
|
||||
public slice_expr_question(addressed_value v, expression from, expression to, expression step, bool ifrom, bool ito) : base(v, from, to, step, ifrom, ito)
|
||||
{ }
|
||||
public slice_expr_question(addressed_value v, expression from, expression to, expression step, bool ifrom, bool ito, SourceContext sc) : base(v, from, to, step, ifrom, ito, sc)
|
||||
{ }
|
||||
}
|
||||
|
||||
public partial class sugared_addressed_value
|
||||
|
|
|
|||
|
|
@ -78,9 +78,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
{
|
||||
var el = construct_expression_list_for_slice_expr(sl);
|
||||
var mc = method_call.NewP(dot_node.NewP(sl.v, new ident("SystemSliceQuestion", sl.v.source_context), sl.v.source_context), el, sl.source_context);
|
||||
|
||||
var sug = sugared_addressed_value.NewP(sl, mc, sl.source_context);
|
||||
|
||||
ReplaceUsingParent(sl, sug);
|
||||
visit(mc); // обойти заменённое на предмет наличия такого же синтаксического сахара
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
///--
|
||||
unit PABCExtensions;
|
||||
|
||||
uses PABCSystem,
|
||||
System;
|
||||
uses PABCSystem;
|
||||
|
||||
function GetCurrentLocale: string;
|
||||
begin
|
||||
|
|
@ -15,12 +14,6 @@ begin
|
|||
Result := 'ru';
|
||||
end;
|
||||
|
||||
procedure p();
|
||||
begin
|
||||
var s := 'sdfh';
|
||||
s[1] := 'd';
|
||||
end;
|
||||
|
||||
function GetTranslation(message: string): string;
|
||||
begin
|
||||
var cur_locale := GetCurrentLocale();
|
||||
|
|
@ -69,15 +62,15 @@ begin
|
|||
// situation = 2 - to отсутствует
|
||||
// situation = 3 - from и to отсутствуют
|
||||
if step = 0 then
|
||||
raise new ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_NOT_EQUAL_0));
|
||||
raise new System.ArgumentException(GetTranslation(PARAMETER_STEP_MUST_BE_NOT_EQUAL_0));
|
||||
|
||||
if (situation = 0) or (situation = 2) then
|
||||
if (from < 0) or (from > Len - 1) then
|
||||
raise new ArgumentException(GetTranslation(PARAMETER_FROM_OUT_OF_RANGE));
|
||||
raise new System.ArgumentException(GetTranslation(PARAMETER_FROM_OUT_OF_RANGE));
|
||||
|
||||
if (situation = 0) or (situation = 1) then
|
||||
if (&to < -1) or (&to > Len) then
|
||||
raise new ArgumentException(GetTranslation(PARAMETER_TO_OUT_OF_RANGE));
|
||||
raise new System.ArgumentException(GetTranslation(PARAMETER_TO_OUT_OF_RANGE));
|
||||
|
||||
CorrectFromTo(situation, Len, from, &to, step);
|
||||
|
||||
|
|
|
|||
|
|
@ -10269,14 +10269,22 @@ begin
|
|||
end;
|
||||
|
||||
///--
|
||||
function SystemSliceQuestion<T>(Self: List<T>; situation: integer; from, &to: integer): List<T>; extensionmethod;
|
||||
function SystemSliceQuestion<T>(Self: List<T>; situation: integer; from, &to: integer; inverseFrom, inverseTo: boolean): List<T>; extensionmethod;
|
||||
begin
|
||||
if inverseFrom then
|
||||
from := Self.Count - from;
|
||||
if inverseTo then
|
||||
&to := Self.Count - &to;
|
||||
Result := SystemSliceListImplQuestion(Self, situation, from, &to, 1);
|
||||
end;
|
||||
|
||||
///--
|
||||
function SystemSliceQuestion<T>(Self: List<T>; situation: integer; from, &to, step: integer): List<T>; extensionmethod;
|
||||
function SystemSliceQuestion<T>(Self: List<T>; situation: integer; from, &to, step: integer; inverseFrom, inverseTo: boolean): List<T>; extensionmethod;
|
||||
begin
|
||||
if inverseFrom then
|
||||
from := Self.Count - from;
|
||||
if inverseTo then
|
||||
&to := Self.Count - &to;
|
||||
Result := SystemSliceListImplQuestion(Self, situation, from, &to, step);
|
||||
end;
|
||||
|
||||
|
|
@ -11110,14 +11118,22 @@ begin
|
|||
end;
|
||||
|
||||
///--
|
||||
function SystemSliceQuestion<T>(Self: array of T; situation: integer; from, &to: integer): array of T; extensionmethod;
|
||||
function SystemSliceQuestion<T>(Self: array of T; situation: integer; from, &to: integer; inverseFrom, inverseTo: boolean): array of T; extensionmethod;
|
||||
begin
|
||||
if inverseFrom then
|
||||
from := Self.Count - from;
|
||||
if inverseTo then
|
||||
&to := Self.Count - &to;
|
||||
Result := SystemSliceArrayImplQuestion(Self, situation, from, &to, 1);
|
||||
end;
|
||||
|
||||
///--
|
||||
function SystemSliceQuestion<T>(Self: array of T; situation: integer; from, &to, step: integer): array of T; extensionmethod;
|
||||
function SystemSliceQuestion<T>(Self: array of T; situation: integer; from, &to, step: integer; inverseFrom, inverseTo: boolean): array of T; extensionmethod;
|
||||
begin
|
||||
if inverseFrom then
|
||||
from := Self.Count - from;
|
||||
if inverseTo then
|
||||
&to := Self.Count - &to;
|
||||
Result := SystemSliceArrayImplQuestion(Self, situation, from, &to, step);
|
||||
end;
|
||||
|
||||
|
|
@ -11709,14 +11725,22 @@ begin
|
|||
end;
|
||||
|
||||
///--
|
||||
function SystemSliceQuestion(Self: string; situation: integer; from, &to: integer): string; extensionmethod;
|
||||
function SystemSliceQuestion(Self: string; situation: integer; from, &to: integer; inverseFrom, inverseTo: boolean): string; extensionmethod;
|
||||
begin
|
||||
if inverseFrom then
|
||||
from := Self.Count - from;
|
||||
if inverseTo then
|
||||
&to := Self.Count - &to;
|
||||
Result := SystemSliceStringImplQuestion(Self, situation, from, &to, 1);
|
||||
end;
|
||||
|
||||
///--
|
||||
function SystemSliceQuestion(Self: string; situation: integer; from, &to, step: integer): string; extensionmethod;
|
||||
function SystemSliceQuestion(Self: string; situation: integer; from, &to, step: integer; inverseFrom, inverseTo: boolean): string; extensionmethod;
|
||||
begin
|
||||
if inverseFrom then
|
||||
from := Self.Count - from;
|
||||
if inverseTo then
|
||||
&to := Self.Count - &to;
|
||||
Result := SystemSliceStringImplQuestion(Self, situation, from, &to, step);
|
||||
end;
|
||||
//--------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue