Новsй узел expression_with_let_semantic, expression_with_let_semantic
для конструкции вида procedure p(b: integer := (var x := b*b; x*x+x-1));
This commit is contained in:
parent
e4a0a33d3e
commit
1438b620ab
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "8";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "2901";
|
||||
public const string Revision = "2903";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=8
|
||||
%REVISION%=2901
|
||||
%REVISION%=2903
|
||||
%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: 28.05.2021 19:30:50
|
||||
// DateTime: 29.06.2021 9:47:21
|
||||
// UserName: ?????????
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@
|
|||
%type <ti> tkAssignOrEqual
|
||||
%type <stn> const_pattern_expression pattern deconstruction_or_const_pattern pattern_optional_var collection_pattern tuple_pattern collection_pattern_list_item tuple_pattern_item collection_pattern_var_item match_with pattern_case pattern_cases pattern_out_param pattern_out_param_optional_var
|
||||
%type <ob> pattern_out_param_list pattern_out_param_list_optional_var collection_pattern_expr_list tuple_pattern_item_list const_pattern_expr_list
|
||||
%type <stn> var_with_init_for_expr_with_let var_with_init_for_expr_with_let_list
|
||||
|
||||
%%
|
||||
|
||||
|
|
@ -3238,13 +3239,6 @@ expr
|
|||
| format_expr
|
||||
{ $$ = $1; }
|
||||
;
|
||||
/*
|
||||
expr_l1_for_indexer
|
||||
: expr_l1
|
||||
{ $$ = $1; }
|
||||
| format_expr
|
||||
{ $$ = $1; }
|
||||
;*/
|
||||
|
||||
expr_l1
|
||||
: expr_dq
|
||||
|
|
@ -4168,6 +4162,25 @@ variable_or_literal_or_number
|
|||
{ $$ = $1; }
|
||||
;
|
||||
|
||||
var_with_init_for_expr_with_let
|
||||
: tkVar identifier tkAssign expr tkSemiColon
|
||||
{
|
||||
$$ = new assign($2 as addressed_value, $4, Operators.Assignment, @$);
|
||||
}
|
||||
;
|
||||
|
||||
var_with_init_for_expr_with_let_list
|
||||
: var_with_init_for_expr_with_let
|
||||
{
|
||||
$$ = new statement_list($1 as statement, @$);
|
||||
}
|
||||
| var_with_init_for_expr_with_let_list var_with_init_for_expr_with_let
|
||||
{
|
||||
$1 = new statement_list($2 as statement, @$);
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
variable
|
||||
: identifier
|
||||
{ $$ = $1; }
|
||||
|
|
@ -4177,7 +4190,6 @@ variable
|
|||
{
|
||||
$$ = new inherited_ident($2.name, @$);
|
||||
}
|
||||
|
||||
| tkRoundOpen expr tkRoundClose
|
||||
{
|
||||
if (!parsertools.build_tree_for_formatter)
|
||||
|
|
@ -4187,6 +4199,15 @@ variable
|
|||
}
|
||||
else $$ = new bracket_expr($2, @$);
|
||||
}
|
||||
| tkRoundOpen var_with_init_for_expr_with_let_list expr tkRoundClose
|
||||
{
|
||||
if (!parsertools.build_tree_for_formatter)
|
||||
{
|
||||
$3.source_context = @$;
|
||||
$$ = $3;
|
||||
}
|
||||
else $$ = new expression_with_let($2 as statement_list, $2 as expression, @$);
|
||||
}
|
||||
| sizeof_expr
|
||||
{ $$ = $1; }
|
||||
| typeof_expr
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -330,6 +330,11 @@ script=
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.8.0.2901
|
||||
3.8.0.2903
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.8.0.2901'
|
||||
!define VERSION '3.8.0.2903'
|
||||
|
|
|
|||
|
|
@ -1297,6 +1297,11 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
DefaultVisit(_property_ident);
|
||||
}
|
||||
|
||||
public virtual void visit(expression_with_let _expression_with_let)
|
||||
{
|
||||
DefaultVisit(_expression_with_let);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2069,6 +2069,14 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
}
|
||||
|
||||
public virtual void pre_do_visit(expression_with_let _expression_with_let)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void post_do_visit(expression_with_let _expression_with_let)
|
||||
{
|
||||
}
|
||||
|
||||
public override void visit(expression _expression)
|
||||
{
|
||||
DefaultVisit(_expression);
|
||||
|
|
@ -4273,6 +4281,15 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
visit(property_ident.ln[i]);
|
||||
post_do_visit(_property_ident);
|
||||
}
|
||||
|
||||
public override void visit(expression_with_let _expression_with_let)
|
||||
{
|
||||
DefaultVisit(_expression_with_let);
|
||||
pre_do_visit(_expression_with_let);
|
||||
visit(expression_with_let.stat);
|
||||
visit(expression_with_let.expr);
|
||||
post_do_visit(_expression_with_let);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -536,6 +536,8 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
return new foreach_stmt_formatting();
|
||||
case 257:
|
||||
return new property_ident();
|
||||
case 258:
|
||||
return new expression_with_let();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -4501,6 +4503,19 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void visit(expression_with_let _expression_with_let)
|
||||
{
|
||||
read_expression_with_let(_expression_with_let);
|
||||
}
|
||||
|
||||
public void read_expression_with_let(expression_with_let _expression_with_let)
|
||||
{
|
||||
read_addressed_value(_expression_with_let);
|
||||
_expression_with_let.stat = _read_node() as statement_list;
|
||||
_expression_with_let.expr = _read_node() as expression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7044,6 +7044,36 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void visit(expression_with_let _expression_with_let)
|
||||
{
|
||||
bw.Write((Int16)258);
|
||||
write_expression_with_let(_expression_with_let);
|
||||
}
|
||||
|
||||
public void write_expression_with_let(expression_with_let _expression_with_let)
|
||||
{
|
||||
write_addressed_value(_expression_with_let);
|
||||
if (_expression_with_let.stat == null)
|
||||
{
|
||||
bw.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
_expression_with_let.stat.visit(this);
|
||||
}
|
||||
if (_expression_with_let.expr == null)
|
||||
{
|
||||
bw.Write((byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
_expression_with_let.expr.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55093,6 +55093,196 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public partial class expression_with_let : addressed_value
|
||||
{
|
||||
|
||||
///<summary>
|
||||
///Конструктор без параметров.
|
||||
///</summary>
|
||||
public expression_with_let()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public expression_with_let(statement_list _stat,expression _expr)
|
||||
{
|
||||
this._stat=_stat;
|
||||
this._expr=_expr;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public expression_with_let(statement_list _stat,expression _expr,SourceContext sc)
|
||||
{
|
||||
this._stat=_stat;
|
||||
this._expr=_expr;
|
||||
source_context = sc;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
protected statement_list _stat;
|
||||
protected expression _expr;
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
public statement_list stat
|
||||
{
|
||||
get
|
||||
{
|
||||
return _stat;
|
||||
}
|
||||
set
|
||||
{
|
||||
_stat=value;
|
||||
if (_stat != null)
|
||||
_stat.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
public expression expr
|
||||
{
|
||||
get
|
||||
{
|
||||
return _expr;
|
||||
}
|
||||
set
|
||||
{
|
||||
_expr=value;
|
||||
if (_expr != null)
|
||||
_expr.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Создает копию узла </summary>
|
||||
public override syntax_tree_node Clone()
|
||||
{
|
||||
expression_with_let copy = new expression_with_let();
|
||||
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 (stat != null)
|
||||
{
|
||||
copy.stat = (statement_list)stat.Clone();
|
||||
copy.stat.Parent = copy;
|
||||
}
|
||||
if (expr != null)
|
||||
{
|
||||
copy.expr = (expression)expr.Clone();
|
||||
copy.expr.Parent = copy;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/// <summary> Получает копию данного узла корректного типа </summary>
|
||||
public new expression_with_let TypedClone()
|
||||
{
|
||||
return Clone() as expression_with_let;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
|
||||
public override void FillParentsInDirectChilds()
|
||||
{
|
||||
if (attributes != null)
|
||||
attributes.Parent = this;
|
||||
if (stat != null)
|
||||
stat.Parent = this;
|
||||
if (expr != null)
|
||||
expr.Parent = this;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent во всем поддереве </summary>
|
||||
public override void FillParentsInAllChilds()
|
||||
{
|
||||
FillParentsInDirectChilds();
|
||||
attributes?.FillParentsInAllChilds();
|
||||
stat?.FillParentsInAllChilds();
|
||||
expr?.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 stat;
|
||||
case 1:
|
||||
return expr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||
throw new IndexOutOfRangeException();
|
||||
switch(ind)
|
||||
{
|
||||
case 0:
|
||||
stat = (statement_list)value;
|
||||
break;
|
||||
case 1:
|
||||
expr = (expression)value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Метод для обхода дерева посетителем
|
||||
///</summary>
|
||||
///<param name="visitor">Объект-посетитель.</param>
|
||||
///<returns>Return value is void</returns>
|
||||
public override void visit(IVisitor visitor)
|
||||
{
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1552,6 +1552,12 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
///<param name="_property_ident">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(property_ident _property_ident);
|
||||
///<summary>
|
||||
///Method to visit expression_with_let.
|
||||
///</summary>
|
||||
///<param name="_expression_with_let">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(expression_with_let _expression_with_let);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3323,6 +3323,17 @@
|
|||
<TagIndices />
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
<SyntaxNode Name="expression_with_let" BaseName="addressed_value">
|
||||
<Fields>
|
||||
<SyntaxField Name="stat" SyntaxType="statement_list" />
|
||||
<SyntaxField Name="expr" SyntaxType="expression" />
|
||||
</Fields>
|
||||
<Methods />
|
||||
<Tags>
|
||||
<CategoryIndices />
|
||||
<TagIndices />
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
</SyntaxNodes>
|
||||
<Settings>
|
||||
<FileName>Tree.cs</FileName>
|
||||
|
|
@ -3422,6 +3433,7 @@
|
|||
<HelpData Key=".sharp_consts" Value="Список символьных констант в строке вида #123#124#125" />
|
||||
<HelpData Key=".simple_expr" Value="" />
|
||||
<HelpData Key=".specificator" Value="" />
|
||||
<HelpData Key=".st" Value="" />
|
||||
<HelpData Key=".stat" Value="" />
|
||||
<HelpData Key=".statements" Value="" />
|
||||
<HelpData Key=".step" Value="" />
|
||||
|
|
@ -3827,6 +3839,7 @@
|
|||
<HelpData Key="exit_directive" Value="" />
|
||||
<HelpData Key="expr_collection_pattern_item" Value="" />
|
||||
<HelpData Key="expr_collection_pattern_item.item_expression" Value="" />
|
||||
<HelpData Key="expr_with_let" Value="" />
|
||||
<HelpData Key="expression" Value="Выражение" />
|
||||
<HelpData Key="expression." Value="" />
|
||||
<HelpData Key="expression_as_statement" Value="" />
|
||||
|
|
@ -3844,6 +3857,9 @@
|
|||
<HelpData Key="expression_list.override string ToString()" Value="" />
|
||||
<HelpData Key="expression_list.void Add(expression ex)" Value="" />
|
||||
<HelpData Key="expression_list.void Add(expression ex, SourceContext sc)" Value="" />
|
||||
<HelpData Key="expression_with_let" Value="" />
|
||||
<HelpData Key="expression_with_let.expr" Value="" />
|
||||
<HelpData Key="expression_with_let.stat" Value="" />
|
||||
<HelpData Key="external_directive" Value="expression может быть literal или ident" />
|
||||
<HelpData Key="external_directive.modulename" Value="" />
|
||||
<HelpData Key="external_directive.name" Value="" />
|
||||
|
|
|
|||
|
|
@ -21406,5 +21406,11 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
visit(mc);*/
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.expression_with_let _ex_with_let)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -577,4 +577,23 @@ namespace PascalABCCompiler.TreeRealization
|
|||
visitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class expression_with_let_semantic : expression_node
|
||||
{
|
||||
public expression_with_let_semantic(type_node type, location loc)
|
||||
: base(type, loc)
|
||||
{
|
||||
}
|
||||
|
||||
public override semantic_node_type semantic_node_type
|
||||
{
|
||||
get
|
||||
{
|
||||
return semantic_node_type.typed_expression;
|
||||
}
|
||||
}
|
||||
public override string ToString() => type.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue