Skip to content

Commit

Permalink
Разделители _ в числовых константах
Browse files Browse the repository at this point in the history
  • Loading branch information
miks1965 committed Sep 13, 2023
1 parent 131c55e commit b33efb5
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Configuration/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "9";
public const string Build = "0";
public const string Revision = "3349";
public const string Revision = "3351";

public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Version.defs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%MINOR%=9
%REVISION%=3349
%REVISION%=3351
%COREVERSION%=0
%MAJOR%=3
Binary file modified Localization/DefaultLang.resources
Binary file not shown.
18 changes: 11 additions & 7 deletions Parsers/PascalABCParserNewSaushkin/ABCPascal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-G8V08V4
// DateTime: 23.06.2023 13:17:35
// DateTime: 13.09.2023 10:23:20
// UserName: ?????????
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>
Expand Down Expand Up @@ -1221,15 +1221,18 @@ static sbyte Map(int code)
-1, -1, -1, -1, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-1, 28, 28, 28, 28, 28, 28}),
/* NxS[ 29] */ new Table(0, 0, -1, null),
/* NxS[ 30] */ new Table(16, 34, -1, new sbyte[] {75, -1, -1, -1, -1, -1,
/* NxS[ 30] */ new Table(16, 34, -1, new sbyte[] {75, -1, -1, -1, -1, 30,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 76, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 30, 77, -1, -1, 76}),
/* NxS[ 31] */ new Table(50, 2, 74, new sbyte[] {32, -1}),
/* NxS[ 32] */ new Table(50, 1, -1, new sbyte[] {74}),
/* NxS[ 33] */ new Table(0, 0, -1, null),
/* NxS[ 34] */ new Table(45, 1, -1, new sbyte[] {34}),
/* NxS[ 35] */ new Table(31, 19, -1, new sbyte[] {76, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 35, -1, -1, -1, 76}),
/* NxS[ 34] */ new Table(21, 25, -1, new sbyte[] {34, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 34}),
/* NxS[ 35] */ new Table(21, 29, -1, new sbyte[] {35, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 76, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 35, -1, -1, -1, 76}),
/* NxS[ 36] */ new Table(0, 0, -1, null),
/* NxS[ 37] */ new Table(0, 0, -1, null),
/* NxS[ 38] */ new Table(0, 0, -1, null),
Expand All @@ -1256,8 +1259,9 @@ static sbyte Map(int code)
/* NxS[ 55] */ new Table(0, 0, -1, null),
/* NxS[ 56] */ new Table(0, 0, -1, null),
/* NxS[ 57] */ new Table(0, 0, -1, null),
/* NxS[ 58] */ new Table(31, 19, -1, new sbyte[] {58, -1, -1, -1, -1, -1,
-1, -1, -1, 58, -1, -1, -1, -1, 58, 58, -1, 58, 58}),
/* NxS[ 58] */ new Table(21, 29, -1, new sbyte[] {58, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 58, -1, -1, -1, -1, -1, -1, -1, -1, 58, -1, -1,
-1, -1, 58, 58, -1, 58, 58}),
/* NxS[ 59] */ new Table(50, 1, -1, new sbyte[] {108}),
/* NxS[ 60] */ new Table(0, 0, -1, null),
/* NxS[ 61] */ new Table(0, 7, 61, new sbyte[] {-1, 61, 61, 61, 61, 61,
Expand Down
6 changes: 4 additions & 2 deletions Parsers/PascalABCParserNewSaushkin/ABCPascal.lex
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@

Letter [[:IsLetter:]_]
Digit [0-9]
Digit_ [0-9_]
LetterDigit {Letter}|{Digit}
ID {Letter}{LetterDigit}*
HexDigit {Digit}|[abcdefABCDEF]
HexDigit_ {Digit}|[abcdefABCDEF_]
DotChr [^\r\n]
OneLineCmnt \/\/{DotChr}*

Expand All @@ -31,13 +33,13 @@ DotChr1 [^\r\n}]
NOTASCII [^\x00-x7F]

CHARACTERNUM '[^'\n]'
INTNUM {Digit}+
INTNUM {Digit}{Digit_}*
BIGINTNUM {INTNUM}[bB][iI]
FLOATNUM {INTNUM}\.{INTNUM}
EXPNUM ({INTNUM}\.)?{INTNUM}[eE][+\-]?{INTNUM}
STRINGNUM \'([^\'\n]|\'\')*\'
FORMATSTRINGNUM \$\'([^\'\n]|\'\')*\'
HEXNUM ${HexDigit}+
HEXNUM ${HexDigit}{HexDigit_}*
SHARPCHARNUM #{Digit}+
OLDDIRECTIVE #{ID}
IFDEF \{\$ifdef\ {DotChr1}*\}
Expand Down
21 changes: 19 additions & 2 deletions Parsers/PascalABCParserNewSaushkin/ABCPascalParserTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ public const_node create_double_const(string text, SourceContext sc)
{
System.Globalization.NumberFormatInfo sgnfi = new System.Globalization.NumberFormatInfo();
sgnfi.NumberDecimalSeparator = ".";

text = RemoveThousandsDelimiter(text, sc);

double val = double.Parse(text, sgnfi);
cn = new double_const(val);
cn.source_context = sc;
Expand All @@ -357,11 +360,13 @@ public const_node create_int_const(string text, SourceContext sc)

public const_node create_bigint_const(string text, SourceContext sc)
{
text = RemoveThousandsDelimiter(text, sc);

var txt = text.Substring(0, text.Length - 2);
const_node cn = new bigint_const();
var cn = new bigint_const();
try
{
(cn as bigint_const).val = System.UInt64.Parse(txt);
cn.val = System.UInt64.Parse(txt);
}
catch (Exception)
{
Expand All @@ -371,12 +376,24 @@ public const_node create_bigint_const(string text, SourceContext sc)
return cn;
}

public string RemoveThousandsDelimiter(string s, SourceContext sc)
{
if (s.EndsWith("_") || s.Contains("__"))
{
var errstr = ParserErrorsStringResources.Get("BAD_FORMED_NUM_CONST");
errors.Add(new SyntaxError(errstr, CurrentFileName, sc, null));
}

return s.Replace("_", "");
}

public const_node create_int_const(string text, SourceContext sc, System.Globalization.NumberStyles NumberStyles)
{
//таблица целых констант на уровне синтаксиса
// не может быть - 0 +
// 32--------16----8----|----8----16--------32----------------64(bits)
// [ int64 )[ int32 ]( int64 ]( uint64 ]
text = RemoveThousandsDelimiter(text, sc);
if (NumberStyles == System.Globalization.NumberStyles.HexNumber)
text = text.Substring(1);
const_node cn = new int32_const();
Expand Down
2 changes: 1 addition & 1 deletion Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// GPPG version 1.3.6
// Machine: DESKTOP-G8V08V4
// DateTime: 23.06.2023 13:17:36
// DateTime: 13.09.2023 10:23:21
// UserName: ?????????
// Input file <ABCPascal.y>

Expand Down
2 changes: 2 additions & 0 deletions Parsers/PascalABCParserNewSaushkin/PABC.ymc
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ script=








Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
Expand Down
2 changes: 1 addition & 1 deletion Release/pabcversion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.0.3349
3.9.0.3351
2 changes: 1 addition & 1 deletion ReleaseGenerators/PascalABCNET_version.nsh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!define VERSION '3.9.0.3349'
!define VERSION '3.9.0.3351'
10 changes: 10 additions & 0 deletions SemanticTree/SemanticTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,16 @@ int constant_value
}
}

//Интерфейс для представления BigInteger констант.
public interface IBigIntConstantNode : IConstantNode
{
//Значение константы.
System.Numerics.BigInteger constant_value
{
get;
}
}

//Интерфейс для представления unsigned int констант.
public interface IUIntConstantNode : IConstantNode
{
Expand Down
1 change: 1 addition & 0 deletions SemanticTree/SemanticTree.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
Expand Down
1 change: 0 additions & 1 deletion TestSuite/CompilationSamples/PABCSystem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10158,7 +10158,6 @@ function Product(Self: sequence of BigInteger): BigInteger; extensionmethod;
Result *= a
end;


/// Возвращает отсортированную по возрастанию последовательность
function Sorted<T>(Self: sequence of T): sequence of T; extensionmethod;
begin
Expand Down
2 changes: 1 addition & 1 deletion TreeConverter/TreeConversion/syntax_tree_visitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17778,7 +17778,7 @@ public override void visit(SyntaxTree.int32_const int32)
motivation_keeper.reset();
switch (mot)
{
case motivation.address_receiving: throw new CompilerInternalError("Addres receiving from constant");
case motivation.address_receiving: throw new CompilerInternalError("Address receiving from constant");
case motivation.expression_evaluation: return_value(en); break;
case motivation.semantic_node_reciving: return_semantic_value(en); break;
}
Expand Down
1 change: 0 additions & 1 deletion bin/Lib/PABCSystem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10158,7 +10158,6 @@ function Product(Self: sequence of BigInteger): BigInteger; extensionmethod;
Result *= a
end;


/// Возвращает отсортированную по возрастанию последовательность
function Sorted<T>(Self: sequence of T): sequence of T; extensionmethod;
begin
Expand Down
1 change: 1 addition & 0 deletions bin/Lng/Rus/ParserErrors.dat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

BAD_FLOAT=Слишком большое вещественное
BAD_INT=Слишком большое целое
BAD_FORMED_NUM_CONST=Неверное использование разделителя в числовой константе
BAD_HEX=Неправильная запись hex числа
UNEXPECTED_SYMBOL{0}=Неожиданный символ '{0}'
BAD_EXPR=Неверное выражение
Expand Down

0 comments on commit b33efb5

Please sign in to comment.