Skip to content

Commit

Permalink
Merge branch 'pascalabcnet:master' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
spectatorBH authored Jan 7, 2024
2 parents 0436612 + 564ece3 commit aad4d4f
Show file tree
Hide file tree
Showing 18 changed files with 2,605 additions and 2,585 deletions.
3 changes: 2 additions & 1 deletion CodeCompletion/CodeCompletionPCUReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private static bool ReadPCUHead(PCUFile pcu_file, BinaryReader br)
if (Header[i] != PCUFile.Header[i])
return false;
pcu_file.Version = br.ReadInt16();
pcu_file.Revision = br.ReadInt32();
pcu_file.CRC = br.ReadInt64();
pcu_file.IncludeDebugInfo = br.ReadBoolean();
return true;
Expand All @@ -96,7 +97,7 @@ private void InvalidUnitDetected()
{
//(ssyy) DarkStar - Ïî÷åìó áû â ýòîì ñëó÷àå ïðîñòî íå ïåðåêîìïèëèðîâàòü ìîäóëü?
CloseUnit();
throw new InvalidPCUFule(unit_name);
throw new InvalidPCUFile(unit_name);
}

private void ReadPCUHeader()
Expand Down
11 changes: 10 additions & 1 deletion CodeCompletion/CodeFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3504,8 +3504,17 @@ public override void visit(foreach_stmt_formatting fe)
if (need_off)
DecOffset();
}
public override void visit(let_var_expr lvex)
{
sb.Append("(var ");

visit_node(lvex.id);
add_space_after = true;
add_space_before = true;
visit_node(lvex.ex);
}
#endregion
}


}
6 changes: 6 additions & 0 deletions CodeCompletion/DomSyntaxTreeVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5980,6 +5980,12 @@ public override void visit(bigint_const bi)
var ne = new new_expr(ntr, new expression_list(new uint64_const(bi.val)), bi.source_context);
ne.visit(this);
}

public override void visit(let_var_expr _let_var_expr)
{
var_def_statement vds = new var_def_statement(_let_var_expr.id, _let_var_expr.ex, _let_var_expr.source_context);
vds.visit(this);
}
}
}

13 changes: 13 additions & 0 deletions CodeCompletion/FindReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,19 @@ public override void visit(var_def_statement _var_def_statement)
_var_def_statement.inital_value.visit(this);
}

public override void visit(let_var_expr _let_var_expr)
{
if (for_refactoring)
{
IBaseScope ss = entry_scope.FindScopeByLocation(_let_var_expr.id.source_context.begin_position.line_num, _let_var_expr.id.source_context.begin_position.column_num);
if (ss != null && ss.IsEqual(founded_scope))
pos_list.Add(get_position(_let_var_expr.id));
}

if (_let_var_expr.ex != null)
_let_var_expr.ex.visit(this);
}

public override void visit(declaration _declaration)
{
throw new NotImplementedException();
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4181,7 +4181,7 @@ private bool UnitHasPCU(unit_node_list unitsFromUsesSection, Dictionary<unit_nod
return true;
}
}
catch (InvalidPCUFule)
catch (InvalidPCUFile)
{
//Перекомпилируем....
}
Expand Down
2 changes: 1 addition & 1 deletion Compiler/PCU/PCUFileFormatVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace PascalABCCompiler.PCU
{
public static class PCUFileFormatVersion
{
public static System.Int16 Version = 119;
public static System.Int16 Version = 120;
}
}
11 changes: 6 additions & 5 deletions Compiler/PCU/PCUReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public enum PCUReaderWriterState
BeginReadTree, EndReadTree, BeginSaveTree, EndSaveTree, ErrorSaveTree
}

public class InvalidPCUFule: PascalABCCompiler.Errors.LocatedError
public class InvalidPCUFile: PascalABCCompiler.Errors.LocatedError
{
internal string UnitName;
public InvalidPCUFule(string UnitName)
public InvalidPCUFile(string UnitName)
{
this.UnitName = UnitName;
}
Expand Down Expand Up @@ -263,6 +263,7 @@ public CompilationUnit GetCompilationUnit(string FileName, bool readDebugInfo)
ms = new MemoryStream(File.ReadAllBytes(FileName));
br = new BinaryReader(ms);
ReadPCUHeader();

units[FileName] = this;
unit = new CompilationUnit();
unit.UnitFileName = FileName;
Expand Down Expand Up @@ -543,9 +544,8 @@ private void AddNames(NameRef[] names, SymbolTable.Scope Scope)

private void InvalidUnitDetected()
{
//(ssyy) DarkStar - Почему бы в этом случае просто не перекомпилировать модуль?
CloseUnit();
throw new InvalidPCUFule(unit_name);
throw new InvalidPCUFile(unit_name);
}

private static bool ReadPCUHead(PCUFile pcu_file, BinaryReader br)
Expand All @@ -555,6 +555,7 @@ private static bool ReadPCUHead(PCUFile pcu_file, BinaryReader br)
if (Header[i] != PCUFile.Header[i])
return false;
pcu_file.Version = br.ReadInt16();
pcu_file.Revision = br.ReadInt32();
pcu_file.CRC = br.ReadInt64();
pcu_file.UseRtlDll = br.ReadBoolean();
pcu_file.IncludeDebugInfo = br.ReadBoolean();
Expand All @@ -564,7 +565,7 @@ private static bool ReadPCUHead(PCUFile pcu_file, BinaryReader br)
//чтение заголовка PCU
private void ReadPCUHeader()
{
if (!ReadPCUHead(pcu_file, br) || PCUFile.SupportedVersion != pcu_file.Version)
if (!ReadPCUHead(pcu_file, br) || PCUFile.SupportedVersion != pcu_file.Version || PCUFile.SupportedRevision != pcu_file.Revision)
InvalidUnitDetected();

if(pcu_file.IncludeDebugInfo)
Expand Down
5 changes: 3 additions & 2 deletions Compiler/PCU/PCUWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ public class PCUFile {
public static char[] Header = new char[3] { 'P', 'C', 'U'};

public static Int16 SupportedVersion = PCUFileFormatVersion.Version;

public static int SupportedRevision = Convert.ToInt32(RevisionClass.Revision);
public Int16 Version;

public int Revision;
public static int CRCOffset = 3 + 2;

public Int64 CRC;
Expand Down Expand Up @@ -428,6 +428,7 @@ private void WritePCUHeader(BinaryWriter fbw)
pcu_file.imp_entitles[i] = imp_entitles[i];
fbw.Write(PCUFile.Header);
fbw.Write(PCUFile.SupportedVersion);
fbw.Write(Convert.ToInt32(RevisionClass.Revision));
fbw.Write((Int64)0);//CRC32
fbw.Write(pcu_file.UseRtlDll);
fbw.Write(pcu_file.IncludeDebugInfo);
Expand Down
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 = "3412";
public const string Revision = "3417";

public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
Expand Down
4 changes: 2 additions & 2 deletions Configuration/Version.defs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=3412
%MINOR%=9
%REVISION%=3417
%COREVERSION%=0
%MAJOR%=3
2 changes: 1 addition & 1 deletion 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: 03.01.2024 10:26:46
// DateTime: 06.01.2024 9:49:55
// UserName: ?????????
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>
Expand Down
71 changes: 32 additions & 39 deletions Parsers/PascalABCParserNewSaushkin/ABCPascal.y
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@
%type <stn> stmt_or_expression unlabelled_stmt stmt case_item
%type <td> set_type
%type <ex> as_is_expr as_is_constexpr is_type_expr as_expr power_expr power_constexpr
%type <td> unsized_array_type simple_type_or_ simple_type simple_type_question/*array_name_for_new_expr*/ foreach_stmt_ident_dype_opt fptype type_ref fptype_noproctype array_type
%type <td> template_param template_empty_param structured_type empty_template_type_reference simple_or_template_type_reference simple_or_template_or_question_type_reference type_ref_or_secific for_stmt_decl_or_assign type_decl_type
%type <td> unsized_array_type simple_type_or_ simple_type simple_type_question/*array_name_for_new_expr*/ optional_type_specification fptype type_ref fptype_noproctype array_type
%type <td> template_param template_empty_param structured_type empty_template_type_reference simple_or_template_type_reference simple_or_template_or_question_type_reference type_ref_or_secific type_decl_type
%type <stn> type_ref_and_secific_list
%type <stn> type_decl_sect
%type <stn> try_handler
Expand Down Expand Up @@ -3087,20 +3087,39 @@ index_or_nothing
{ $$ = null; }
;

optional_type_specification
: tkColon type_ref
{ $$ = $2; }
|
{ $$ = null; }
;

optional_var
: tkVar
{ $$ = true; }
|
{ $$ = false; }
;

for_cycle_type
: tkTo
{ $$ = for_cycle_type.to; }
| tkDownto
{ $$ = for_cycle_type.downto; }
;

foreach_stmt
: tkForeach identifier foreach_stmt_ident_dype_opt tkIn expr_l1 index_or_nothing tkDo unlabelled_stmt
: tkForeach identifier optional_type_specification tkIn expr_l1 index_or_nothing tkDo unlabelled_stmt
{
$$ = new foreach_stmt($2, $3, $5, $8 as statement, $6, @$);
if ($3 == null)
parsertools.AddWarningFromResource("USING_UNLOCAL_FOREACH_VARIABLE", $2.source_context);
}
| tkForeach tkVar identifier tkColon type_ref tkIn expr_l1 index_or_nothing tkDo unlabelled_stmt
| tkForeach tkVar identifier optional_type_specification tkIn expr_l1 index_or_nothing tkDo unlabelled_stmt
{
$$ = new foreach_stmt($3, $5, $7, $10 as statement, $8, @$);
}
| tkForeach tkVar identifier tkIn expr_l1 index_or_nothing tkDo unlabelled_stmt
{
$$ = new foreach_stmt($3, new no_type_foreach(), $5, (statement)$8, $6, @$);
if ($4 == null)
$$ = new foreach_stmt($3, new no_type_foreach(), $6, $9 as statement, $7, @$);
else $$ = new foreach_stmt($3, $4, $6, $9 as statement, $7, @$);
}
| tkForeach tkVar tkRoundOpen ident_list tkRoundClose tkIn expr_l1 index_or_nothing tkDo unlabelled_stmt // сахарное правило
{
Expand All @@ -3126,43 +3145,17 @@ foreach_stmt
}
;

foreach_stmt_ident_dype_opt
: tkColon type_ref
{ $$ = $2; }
|
;

for_stmt
: tkFor optional_var identifier for_stmt_decl_or_assign expr_l1 for_cycle_type expr_l1 optional_tk_do unlabelled_stmt
: tkFor optional_var identifier optional_type_specification tkAssign expr_l1 for_cycle_type expr_l1 optional_tk_do unlabelled_stmt
{
$$ = NewForStmt((bool)$2, $3, $4, $5, (for_cycle_type)$6, $7, $8, $9 as statement, null, @$);
$$ = NewForStmt((bool)$2, $3, $4, $6, (for_cycle_type)$7, $8, $9, $10 as statement, null, @$);
}
| tkFor optional_var identifier for_stmt_decl_or_assign expr_l1 for_cycle_type expr_l1 tkStep expr_l1 tkDo unlabelled_stmt
| tkFor optional_var identifier optional_type_specification tkAssign expr_l1 for_cycle_type expr_l1 tkStep expr_l1 tkDo unlabelled_stmt
{
$$ = NewForStmt((bool)$2, $3, $4, $5, (for_cycle_type)$6, $7, $8, $11 as statement, $9, @$);
$$ = NewForStmt((bool)$2, $3, $4, $6, (for_cycle_type)$7, $8, $9, $12 as statement, $10, @$);
}
;

optional_var
: tkVar
{ $$ = true; }
|
{ $$ = false; }
;

for_stmt_decl_or_assign
: tkAssign
| tkColon simple_type_identifier tkAssign
{ $$ = $2; }
;

for_cycle_type
: tkTo
{ $$ = for_cycle_type.to; }
| tkDownto
{ $$ = for_cycle_type.downto; }
;

with_stmt
: tkWith expr_list tkDo unlabelled_stmt
{
Expand Down
Loading

0 comments on commit aad4d4f

Please sign in to comment.