function f(n: integer): integer;
begin if n = 0 then Result := 1 else Result := n*f(n-1); end; begin var a := (var b := f(5)) + b; Print(a,b); end.
This commit is contained in:
parent
19a52d19e4
commit
30668e650a
|
|
@ -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 = "3404";
|
||||
public const string Revision = "3407";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=0
|
||||
%REVISION%=3404
|
||||
%MINOR%=9
|
||||
%REVISION%=3407
|
||||
%COREVERSION%=0
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-G8V08V4
|
||||
// DateTime: 08.12.2023 22:21:31
|
||||
// DateTime: 31.12.2023 18:49:08
|
||||
// UserName: ?????????
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -4213,6 +4213,8 @@ factor
|
|||
{ $$ = $1; }
|
||||
| tuple
|
||||
{ $$ = $1; }
|
||||
| tkRoundOpen tkVar identifier tkAssign expr_dq tkRoundClose
|
||||
{ $$ = new let_var_expr($3,$5,@$); }
|
||||
;
|
||||
|
||||
literal_or_number
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -370,5 +370,6 @@ script=
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.9.0.3404
|
||||
3.9.0.3407
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.9.0.3404'
|
||||
!define VERSION '3.9.0.3407'
|
||||
|
|
|
|||
|
|
@ -1312,6 +1312,11 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
DefaultVisit(_ref_var_def_statement);
|
||||
}
|
||||
|
||||
public virtual void visit(let_var_expr _let_var_expr)
|
||||
{
|
||||
DefaultVisit(_let_var_expr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2093,6 +2093,14 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
}
|
||||
|
||||
public virtual void pre_do_visit(let_var_expr _let_var_expr)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void post_do_visit(let_var_expr _let_var_expr)
|
||||
{
|
||||
}
|
||||
|
||||
public override void visit(expression _expression)
|
||||
{
|
||||
DefaultVisit(_expression);
|
||||
|
|
@ -4325,6 +4333,15 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
visit(ref_var_def_statement.initial_value);
|
||||
post_do_visit(_ref_var_def_statement);
|
||||
}
|
||||
|
||||
public override void visit(let_var_expr _let_var_expr)
|
||||
{
|
||||
DefaultVisit(_let_var_expr);
|
||||
pre_do_visit(_let_var_expr);
|
||||
visit(let_var_expr.id);
|
||||
visit(let_var_expr.ex);
|
||||
post_do_visit(_let_var_expr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -542,6 +542,8 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
return new lambda_any_type_node_syntax();
|
||||
case 260:
|
||||
return new ref_var_def_statement();
|
||||
case 261:
|
||||
return new let_var_expr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -4547,6 +4549,19 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
_ref_var_def_statement.initial_value = _read_node() as addressed_value;
|
||||
}
|
||||
|
||||
|
||||
public void visit(let_var_expr _let_var_expr)
|
||||
{
|
||||
read_let_var_expr(_let_var_expr);
|
||||
}
|
||||
|
||||
public void read_let_var_expr(let_var_expr _let_var_expr)
|
||||
{
|
||||
read_expression(_let_var_expr);
|
||||
_let_var_expr.id = _read_node() as ident;
|
||||
_let_var_expr.ex = _read_node() as expression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7143,6 +7143,36 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void visit(let_var_expr _let_var_expr)
|
||||
{
|
||||
bw.Write((Int16)261);
|
||||
write_let_var_expr(_let_var_expr);
|
||||
}
|
||||
|
||||
public void write_let_var_expr(let_var_expr _let_var_expr)
|
||||
{
|
||||
write_expression(_let_var_expr);
|
||||
if (_let_var_expr.id == null)
|
||||
{
|
||||
bw.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
_let_var_expr.id.visit(this);
|
||||
}
|
||||
if (_let_var_expr.ex == null)
|
||||
{
|
||||
bw.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
_let_var_expr.ex.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55707,6 +55707,196 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public partial class let_var_expr : expression
|
||||
{
|
||||
|
||||
///<summary>
|
||||
///Конструктор без параметров.
|
||||
///</summary>
|
||||
public let_var_expr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public let_var_expr(ident _id,expression _ex)
|
||||
{
|
||||
this._id=_id;
|
||||
this._ex=_ex;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public let_var_expr(ident _id,expression _ex,SourceContext sc)
|
||||
{
|
||||
this._id=_id;
|
||||
this._ex=_ex;
|
||||
source_context = sc;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
protected ident _id;
|
||||
protected expression _ex;
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
public ident id
|
||||
{
|
||||
get
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
set
|
||||
{
|
||||
_id=value;
|
||||
if (_id != null)
|
||||
_id.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
public expression ex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ex;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ex=value;
|
||||
if (_ex != null)
|
||||
_ex.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Создает копию узла </summary>
|
||||
public override syntax_tree_node Clone()
|
||||
{
|
||||
let_var_expr copy = new let_var_expr();
|
||||
copy.Parent = this.Parent;
|
||||
if (source_context != null)
|
||||
copy.source_context = new SourceContext(source_context);
|
||||
if (attributes != null)
|
||||
{
|
||||
copy.attributes = (attribute_list)attributes.Clone();
|
||||
copy.attributes.Parent = copy;
|
||||
}
|
||||
if (id != null)
|
||||
{
|
||||
copy.id = (ident)id.Clone();
|
||||
copy.id.Parent = copy;
|
||||
}
|
||||
if (ex != null)
|
||||
{
|
||||
copy.ex = (expression)ex.Clone();
|
||||
copy.ex.Parent = copy;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/// <summary> Получает копию данного узла корректного типа </summary>
|
||||
public new let_var_expr TypedClone()
|
||||
{
|
||||
return Clone() as let_var_expr;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
|
||||
public override void FillParentsInDirectChilds()
|
||||
{
|
||||
if (attributes != null)
|
||||
attributes.Parent = this;
|
||||
if (id != null)
|
||||
id.Parent = this;
|
||||
if (ex != null)
|
||||
ex.Parent = this;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent во всем поддереве </summary>
|
||||
public override void FillParentsInAllChilds()
|
||||
{
|
||||
FillParentsInDirectChilds();
|
||||
attributes?.FillParentsInAllChilds();
|
||||
id?.FillParentsInAllChilds();
|
||||
ex?.FillParentsInAllChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Свойство для получения количества всех подузлов без элементов поля типа List
|
||||
///</summary>
|
||||
public override Int32 subnodes_without_list_elements_count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
|
||||
///</summary>
|
||||
public override Int32 subnodes_count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Индексатор для получения всех подузлов
|
||||
///</summary>
|
||||
public override syntax_tree_node this[Int32 ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||
throw new IndexOutOfRangeException();
|
||||
switch(ind)
|
||||
{
|
||||
case 0:
|
||||
return id;
|
||||
case 1:
|
||||
return ex;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||
throw new IndexOutOfRangeException();
|
||||
switch(ind)
|
||||
{
|
||||
case 0:
|
||||
id = (ident)value;
|
||||
break;
|
||||
case 1:
|
||||
ex = (expression)value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Метод для обхода дерева посетителем
|
||||
///</summary>
|
||||
///<param name="visitor">Объект-посетитель.</param>
|
||||
///<returns>Return value is void</returns>
|
||||
public override void visit(IVisitor visitor)
|
||||
{
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1570,6 +1570,12 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
///<param name="_ref_var_def_statement">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(ref_var_def_statement _ref_var_def_statement);
|
||||
///<summary>
|
||||
///Method to visit let_var_expr.
|
||||
///</summary>
|
||||
///<param name="_let_var_expr">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(let_var_expr _let_var_expr);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3357,6 +3357,17 @@
|
|||
<TagIndices />
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
<SyntaxNode Name="let_var_expr" BaseName="expression">
|
||||
<Fields>
|
||||
<SyntaxField Name="id" SyntaxType="ident" />
|
||||
<SyntaxField Name="ex" SyntaxType="expression" />
|
||||
</Fields>
|
||||
<Methods />
|
||||
<Tags>
|
||||
<CategoryIndices />
|
||||
<TagIndices />
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
</SyntaxNodes>
|
||||
<Settings>
|
||||
<FileName>Tree.cs</FileName>
|
||||
|
|
@ -3424,6 +3435,7 @@
|
|||
<HelpData Key=".handlers" Value="" />
|
||||
<HelpData Key=".has_deref" Value="" />
|
||||
<HelpData Key=".i" Value="" />
|
||||
<HelpData Key=".id" Value="" />
|
||||
<HelpData Key=".if_false" Value="" />
|
||||
<HelpData Key=".if_true" Value="" />
|
||||
<HelpData Key=".il" Value="" />
|
||||
|
|
@ -4115,6 +4127,9 @@
|
|||
<HelpData Key="lambda_inferred_type._realType" Value="" />
|
||||
<HelpData Key="lambda_inferred_type.realType" Value="" />
|
||||
<HelpData Key="lambda_inferred_type.real_type" Value="" />
|
||||
<HelpData Key="let_var_expr" Value="" />
|
||||
<HelpData Key="let_var_expr.ex" Value="" />
|
||||
<HelpData Key="let_var_expr.id" Value="" />
|
||||
<HelpData Key="literal" Value="#12 либо 'abc'" />
|
||||
<HelpData Key="literal_const_line" Value="Представляет в синтаксическом дереве строку вида #123'abc'#124#125." />
|
||||
<HelpData Key="literal_const_line.literal_const_line Add(literal _literal)" Value="" />
|
||||
|
|
|
|||
|
|
@ -19800,6 +19800,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
ret.reset(); // SSM 19.01.17 не возвращать семантическое значение т.к. ничего не нужно добавлять в текущий список операторов!!
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.let_var_expr node)
|
||||
{
|
||||
var vs = new SyntaxTree.var_statement(node.id, node.ex);
|
||||
visit(vs);
|
||||
return_value((statement_node)convert_strong(node.ex));
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.expression_as_statement node)
|
||||
{
|
||||
return_value((statement_node)convert_strong(node.expr));
|
||||
|
|
|
|||
Loading…
Reference in a new issue