Working commit
This commit is contained in:
parent
23d451898a
commit
2983529171
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "1";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "1198";
|
||||
public const string Revision = "1200";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=1
|
||||
%REVISION%=1198
|
||||
%REVISION%=1200
|
||||
%COREVERSION%=0
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: SSM
|
||||
// DateTime: 10.03.2016 0:57:37
|
||||
// DateTime: 12.03.2016 23:50:46
|
||||
// UserName: ?????????
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
%type <stn> enumeration_id expr_l1_list
|
||||
%type <stn> enumeration_id_list
|
||||
%type <ex> const_simple_expr term typed_const typed_const_or_new expr const_expr elem range_expr const_elem array_const factor relop_expr expr_l1 simple_expr range_term range_factor
|
||||
%type <ex> external_directive_ident init_const_expr case_label variable var_reference // var_question_colon
|
||||
%type <ex> external_directive_ident init_const_expr case_label variable var_reference simple_expr_or_nothing // var_question_colon
|
||||
%type <ob> for_cycle_type
|
||||
%type <ex> format_expr
|
||||
%type <stn> foreach_stmt
|
||||
|
|
@ -2775,15 +2775,34 @@ relop_expr
|
|||
}
|
||||
;
|
||||
|
||||
simple_expr_or_nothing
|
||||
: simple_expr
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
|
|
||||
{
|
||||
$$ = null;
|
||||
}
|
||||
;
|
||||
|
||||
format_expr
|
||||
: simple_expr tkColon simple_expr
|
||||
: simple_expr tkColon simple_expr_or_nothing
|
||||
{
|
||||
$$ = new format_expr($1, $3, null, @$);
|
||||
}
|
||||
| simple_expr tkColon simple_expr tkColon simple_expr
|
||||
| tkColon simple_expr
|
||||
{
|
||||
$$ = new format_expr(null, $2, null, @$);
|
||||
}
|
||||
| simple_expr tkColon simple_expr_or_nothing tkColon simple_expr
|
||||
{
|
||||
$$ = new format_expr($1, $3, $5, @$);
|
||||
}
|
||||
| tkColon simple_expr_or_nothing tkColon simple_expr
|
||||
{
|
||||
$$ = new format_expr(null, $2, $4, @$);
|
||||
}
|
||||
;
|
||||
|
||||
relop
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -25,7 +25,6 @@
|
|||
<name value="question_expr" />
|
||||
<name value="new_expr" />
|
||||
<name value="relop_expr" />
|
||||
<name value="format_expr" />
|
||||
<name value="simple_expr" />
|
||||
<name value="as_is_expr" />
|
||||
<name value="term" />
|
||||
|
|
|
|||
|
|
@ -122,5 +122,6 @@ script=
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.1.0.1198'
|
||||
!define VERSION '3.1.0.1200'
|
||||
|
|
|
|||
|
|
@ -1097,7 +1097,8 @@ function Power(x, y: real): real;
|
|||
function Power(x, y: integer): real;
|
||||
/// Возвращает x в степени y
|
||||
function Power(x: BigInteger; y: integer): BigInteger;
|
||||
/// Возвращает x, округленное до ближайшего целого
|
||||
/// Возвращает x, округленное до ближайшего целого. Если вещественное находится посередине между двумя целыми,
|
||||
///то округление осуществляется к ближайшему четному (банковское округление): Round(2.5)=2, Round(3.5)=4
|
||||
function Round(x: real): integer;
|
||||
/// Возвращает x, округленное до ближайшего длинного целого
|
||||
function RoundBigInteger(x: real): BigInteger;
|
||||
|
|
@ -3428,6 +3429,11 @@ begin
|
|||
Result := a*n;
|
||||
end;
|
||||
|
||||
///--
|
||||
function operator in<T>(x: T; Self: sequence of T): boolean; extensionmethod;
|
||||
begin
|
||||
Result := Self.Contains(x);
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
// Функции для последовательностей и динамических массивов
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -3635,7 +3641,7 @@ type
|
|||
end;
|
||||
procedure Dispose(); override;
|
||||
begin
|
||||
cur := first;
|
||||
cur := first-1;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -8520,13 +8526,13 @@ end;
|
|||
/// Ищет в указанной строке все вхождения регулярного выражения и возвращает их в виде последовательности элементов типа Match
|
||||
function Matches(Self: string; reg: string; options: RegexOptions := RegexOptions.None): sequence of Match; extensionmethod;
|
||||
begin
|
||||
Result := (new Regex (reg, options)).Matches(Self).Cast&<Match>();
|
||||
Result := (new Regex(reg, options)).Matches(Self).Cast&<Match>();
|
||||
end;
|
||||
|
||||
/// Ищет в указанной строке первое вхождение регулярного выражения и возвращает его в виде строки
|
||||
function MatchValue(Self: string; reg: string; options: RegexOptions := RegexOptions.None): string; extensionmethod;
|
||||
begin
|
||||
Result := (new Regex (reg, options)).Match(Self).Value;
|
||||
Result := (new Regex(reg, options)).Match(Self).Value;
|
||||
end;
|
||||
|
||||
/// Ищет в указанной строке все вхождения регулярного выражения и возвращает их в виде последовательности строк
|
||||
|
|
|
|||
|
|
@ -2369,6 +2369,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public override void visit(SyntaxTree.format_expr _format_expr)
|
||||
{
|
||||
if (_format_expr.expr == null || _format_expr.format1 == null)
|
||||
AddError(get_location(_format_expr), "BAD_CONSTRUCTED_FORMAT_EXPRESSION");
|
||||
//TODO: Добавить проверки.
|
||||
if (!SemanticRules.AllowUseFormatExprAnywhere && !is_format_allowed)
|
||||
AddError(get_location(_format_expr.expr), "FORMAT_EXPRESSION_CAN_USE_ONLY_IN_THESE_PROCEDURES");
|
||||
|
|
@ -18878,6 +18880,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public override void visit(SyntaxTree.slice_expr sl)
|
||||
{
|
||||
// Преобразуется в вызов a.Slice
|
||||
// from, step сохраняются, count вычисляется как count = (to-from+step-sign(step)) div step
|
||||
// Для a: нужно to присвоить очень большое целое
|
||||
// Для :b нужно from присвоить -1
|
||||
// Для a::step нужно использовать a.Slice(from,step)
|
||||
// Для :b:step нужно закодировать from - from := -MaxInt div 2 и в методе Slice это проверить и поправить from в зависимости от знака step
|
||||
|
||||
var semvar = convert_strong(sl.v);
|
||||
var semvartype = semvar.type;
|
||||
|
||||
|
|
@ -18920,9 +18929,23 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (!IsOrImplementsIEnumerableT)
|
||||
AddError(get_location(sl.v), "BAD_SLICE_OBJECT");
|
||||
|
||||
var semfrom = convert_strong(sl.from);
|
||||
convertion_data_and_alghoritms.check_convert_type(semfrom, SystemLibrary.SystemLibrary.integer_type, get_location(sl.from));
|
||||
var synfrom = new SyntaxTree.semantic_addr_value(semfrom);
|
||||
// Ситуация from::step - вызвать Slice с двумя параметрами - пропустить вычисление и добавление count
|
||||
bool SituationFromSpaceStep = (sl.from != null) && (sl.to == null) && (sl.step != null);
|
||||
// Ситуация :to:step - закодировать from = -MaxInt div 2 и в Slice сделато коррекцию если step<0 !!!
|
||||
bool SituationSpaceToStep = (sl.from == null) && (sl.to != null) && (sl.step != null);
|
||||
|
||||
|
||||
SyntaxTree.expression synfrom;
|
||||
if (sl.from != null)
|
||||
{
|
||||
var semfrom = convert_strong(sl.from);
|
||||
convertion_data_and_alghoritms.check_convert_type(semfrom, SystemLibrary.SystemLibrary.integer_type, get_location(sl.from));
|
||||
synfrom = new SyntaxTree.semantic_addr_value(semfrom);
|
||||
}
|
||||
else
|
||||
{
|
||||
synfrom = new int32_const(-1);
|
||||
}
|
||||
|
||||
var int1 = new int32_const(1);
|
||||
var el = new SyntaxTree.expression_list();
|
||||
|
|
@ -18944,21 +18967,30 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
el.Add(synstep);
|
||||
|
||||
var semto = convert_strong(sl.to);
|
||||
convertion_data_and_alghoritms.check_convert_type(semto, SystemLibrary.SystemLibrary.integer_type, get_location(sl.to));
|
||||
var synto = new SyntaxTree.semantic_addr_value(semto);
|
||||
SyntaxTree.expression synto;
|
||||
if (sl.to != null)
|
||||
{
|
||||
var semto = convert_strong(sl.to);
|
||||
convertion_data_and_alghoritms.check_convert_type(semto, SystemLibrary.SystemLibrary.integer_type, get_location(sl.to));
|
||||
synto = new SyntaxTree.semantic_addr_value(semto);
|
||||
}
|
||||
else
|
||||
{
|
||||
synto = new int32_const(Int32.MaxValue/2);
|
||||
}
|
||||
|
||||
// count = (abs(to-from)-1) div abs(step) + 1 - нет
|
||||
// count = (to-from+step-sign(step)) div step
|
||||
SyntaxTree.expression ex = new bin_expr(synto, synfrom, Operators.Minus);
|
||||
//ex = new method_call(new ident("abs"), new expression_list(ex));
|
||||
//ex = new bin_expr(ex, absstep, Operators.IntegerDivision);
|
||||
SyntaxTree.expression signstep = new method_call(new ident("sign"), new expression_list(synstep));
|
||||
ex = new bin_expr(ex, synstep, Operators.Plus);
|
||||
ex = new bin_expr(ex, signstep, Operators.Minus);
|
||||
ex = new bin_expr(ex, synstep, Operators.IntegerDivision);
|
||||
if (!SituationFromSpaceStep) // если не from::step то вычислить count и вызвать Slice с тремя параметрами
|
||||
{
|
||||
// count = (to-from+step-sign(step)) div step
|
||||
SyntaxTree.expression ex = new bin_expr(synto, synfrom, Operators.Minus);
|
||||
SyntaxTree.expression signstep = new method_call(new ident("sign"), new expression_list(synstep));
|
||||
ex = new bin_expr(ex, synstep, Operators.Plus);
|
||||
ex = new bin_expr(ex, signstep, Operators.Minus);
|
||||
ex = new bin_expr(ex, synstep, Operators.IntegerDivision);
|
||||
|
||||
el.Add(ex); // Параметр count
|
||||
}
|
||||
|
||||
el.Add(ex);
|
||||
var mc = new method_call(new dot_node(sl.v, new ident("Slice", sl.v.source_context), sl.v.source_context), el, sl.source_context);
|
||||
visit(mc);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -19,6 +19,7 @@ DESTRUCTOR_CANNOT_HAVE_PARAMETERS=Destructor cannot have parameters
|
|||
USING_MODIFIERS{0}_{1}_TOGETHER_NOT_ALLOWED=Modifier '{0}' has conflicts with modifier '{1}'
|
||||
CONST_PARAMETERS_CANNOT_HAVE_DEFAULT_VALUE=const-parameters cannot have default value
|
||||
FORMAT_EXPRESSION_CAN_USE_ONLY_IN_THESE_PROCEDURES=Format expression can be used only in calls of write, writeln и str
|
||||
BAD_CONSTRUCTED_FORMAT_EXPRESSION=Badly constructed format expression
|
||||
NIL_IN_SET_CONSTRUCTOR_NOT_ALLOWED=nil cannot be used in a set constructor
|
||||
POINTERS_IN_SETS_NOT_ALLOWED=Set cannot contain pointers
|
||||
VOID_NOT_VALID=Type 'System.Void' cannot be used in this context
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ DESTRUCTOR_CANNOT_HAVE_PARAMETERS=Деструктор не может имет
|
|||
USING_MODIFIERS{0}_{1}_TOGETHER_NOT_ALLOWED=Совместное использование модификаторов {0} и {1} недопустимо
|
||||
CONST_PARAMETERS_CANNOT_HAVE_DEFAULT_VALUE=const-параметры не могут иметь значение по умолчанию
|
||||
FORMAT_EXPRESSION_CAN_USE_ONLY_IN_THESE_PROCEDURES=Форматное выражение может использоваться только внутри write, writeln и str
|
||||
BAD_CONSTRUCTED_FORMAT_EXPRESSION=Неверно сконструированное форматное выражение
|
||||
NIL_IN_SET_CONSTRUCTOR_NOT_ALLOWED=Нельзя использовать nil в конструкторе множества
|
||||
POINTERS_IN_SETS_NOT_ALLOWED=Множество не может содержать указатели
|
||||
VOID_NOT_VALID=Использование типа System.Void в данном контексте недопустимо
|
||||
|
|
|
|||
Loading…
Reference in a new issue