Add where_type_class_constraint

This commit is contained in:
Bogdan Voloshin 2018-04-10 18:07:31 +03:00
parent 95cf30dba5
commit fdfae3b9fd
10 changed files with 280 additions and 5 deletions

View file

@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: OBERON
// DateTime: 4/5/2018 7:25:13 PM
// DateTime: 4/10/2018 5:44:39 PM
// UserName: voganesyan
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>

View file

@ -1568,7 +1568,7 @@ where_part
}
| tkWhere typeclass_restriction tkSemiColon
{
$$ = $1;
$$ = new where_typeclass_constraint($2 as typeclass_restriction);
}
;

View file

@ -2,7 +2,7 @@
// GPPG version 1.3.6
// Machine: OBERON
// DateTime: 4/5/2018 7:25:14 PM
// DateTime: 4/10/2018 5:44:39 PM
// UserName: voganesyan
// Input file <ABCPascal.y>
@ -3746,7 +3746,7 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
break;
case 312: // where_part -> tkWhere, typeclass_restriction, tkSemiColon
{
CurrentSemanticValue.stn = ValueStack[ValueStack.Depth-3].ti;
CurrentSemanticValue.stn = new where_typeclass_constraint(ValueStack[ValueStack.Depth-2].id as typeclass_restriction);
}
break;
case 313: // type_ref_and_secific_list -> type_ref_or_secific

View file

@ -1132,6 +1132,11 @@ namespace PascalABCCompiler.SyntaxTree
{
DefaultVisit(_typeclass_definition);
}
public virtual void visit(where_typeclass_constraint _where_typeclass_constraint)
{
DefaultVisit(_where_typeclass_constraint);
}
}

View file

@ -1805,6 +1805,14 @@ namespace PascalABCCompiler.SyntaxTree
{
}
public virtual void pre_do_visit(where_typeclass_constraint _where_typeclass_constraint)
{
}
public virtual void post_do_visit(where_typeclass_constraint _where_typeclass_constraint)
{
}
public override void visit(expression _expression)
{
DefaultVisit(_expression);
@ -3732,6 +3740,14 @@ namespace PascalABCCompiler.SyntaxTree
visit(typeclass_definition.body);
post_do_visit(_typeclass_definition);
}
public override void visit(where_typeclass_constraint _where_typeclass_constraint)
{
DefaultVisit(_where_typeclass_constraint);
pre_do_visit(_where_typeclass_constraint);
visit(where_typeclass_constraint.restriction);
post_do_visit(_where_typeclass_constraint);
}
}

View file

@ -470,6 +470,8 @@ namespace PascalABCCompiler.SyntaxTree
return new instance_definition();
case 224:
return new typeclass_definition();
case 225:
return new where_typeclass_constraint();
}
return null;
}
@ -3963,6 +3965,18 @@ namespace PascalABCCompiler.SyntaxTree
_typeclass_definition.body = _read_node() as class_body_list;
}
public void visit(where_typeclass_constraint _where_typeclass_constraint)
{
read_where_typeclass_constraint(_where_typeclass_constraint);
}
public void read_where_typeclass_constraint(where_typeclass_constraint _where_typeclass_constraint)
{
read_where_definition(_where_typeclass_constraint);
_where_typeclass_constraint.restriction = _read_node() as typeclass_restriction;
}
}

View file

@ -6211,6 +6211,27 @@ namespace PascalABCCompiler.SyntaxTree
}
}
public void visit(where_typeclass_constraint _where_typeclass_constraint)
{
bw.Write((Int16)225);
write_where_typeclass_constraint(_where_typeclass_constraint);
}
public void write_where_typeclass_constraint(where_typeclass_constraint _where_typeclass_constraint)
{
write_where_definition(_where_typeclass_constraint);
if (_where_typeclass_constraint.restriction == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_where_typeclass_constraint.restriction.visit(this);
}
}
}

View file

@ -47992,6 +47992,202 @@ namespace PascalABCCompiler.SyntaxTree
}
///<summary>
///
///</summary>
[Serializable]
public partial class where_typeclass_constraint : where_definition
{
///<summary>
///Конструктор без параметров.
///</summary>
public where_typeclass_constraint()
{
}
///<summary>
///Конструктор с параметрами.
///</summary>
public where_typeclass_constraint(typeclass_restriction _restriction)
{
this._restriction=_restriction;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public where_typeclass_constraint(typeclass_restriction _restriction,SourceContext sc)
{
this._restriction=_restriction;
source_context = sc;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public where_typeclass_constraint(ident_list _names,where_type_specificator_list _types,typeclass_restriction _restriction)
{
this._names=_names;
this._types=_types;
this._restriction=_restriction;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public where_typeclass_constraint(ident_list _names,where_type_specificator_list _types,typeclass_restriction _restriction,SourceContext sc)
{
this._names=_names;
this._types=_types;
this._restriction=_restriction;
source_context = sc;
FillParentsInDirectChilds();
}
protected typeclass_restriction _restriction;
///<summary>
///
///</summary>
public typeclass_restriction restriction
{
get
{
return _restriction;
}
set
{
_restriction=value;
}
}
/// <summary> Создает копию узла </summary>
public override syntax_tree_node Clone()
{
where_typeclass_constraint copy = new where_typeclass_constraint();
copy.Parent = this.Parent;
if (source_context != null)
copy.source_context = new SourceContext(source_context);
if (names != null)
{
copy.names = (ident_list)names.Clone();
copy.names.Parent = copy;
}
if (types != null)
{
copy.types = (where_type_specificator_list)types.Clone();
copy.types.Parent = copy;
}
if (restriction != null)
{
copy.restriction = (typeclass_restriction)restriction.Clone();
copy.restriction.Parent = copy;
}
return copy;
}
/// <summary> Получает копию данного узла корректного типа </summary>
public new where_typeclass_constraint TypedClone()
{
return Clone() as where_typeclass_constraint;
}
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
public override void FillParentsInDirectChilds()
{
if (names != null)
names.Parent = this;
if (types != null)
types.Parent = this;
if (restriction != null)
restriction.Parent = this;
}
///<summary> Заполняет поля Parent во всем поддереве </summary>
public override void FillParentsInAllChilds()
{
FillParentsInDirectChilds();
names?.FillParentsInAllChilds();
types?.FillParentsInAllChilds();
restriction?.FillParentsInAllChilds();
}
///<summary>
///Свойство для получения количества всех подузлов без элементов поля типа List
///</summary>
public override Int32 subnodes_without_list_elements_count
{
get
{
return 3;
}
}
///<summary>
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
///</summary>
public override Int32 subnodes_count
{
get
{
return 3;
}
}
///<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 names;
case 1:
return types;
case 2:
return restriction;
}
return null;
}
set
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
switch(ind)
{
case 0:
names = (ident_list)value;
break;
case 1:
types = (where_type_specificator_list)value;
break;
case 2:
restriction = (typeclass_restriction)value;
break;
}
}
}
///<summary>
///Метод для обхода дерева посетителем
///</summary>
///<param name="visitor">Объект-посетитель.</param>
///<returns>Return value is void</returns>
public override void visit(IVisitor visitor)
{
visitor.visit(this);
}
}
}

View file

@ -1354,6 +1354,12 @@ namespace PascalABCCompiler.SyntaxTree
///<param name="_typeclass_definition">Node to visit</param>
///<returns> Return value is void </returns>
void visit(typeclass_definition _typeclass_definition);
///<summary>
///Method to visit where_typeclass_constraint.
///</summary>
///<param name="_where_typeclass_constraint">Node to visit</param>
///<returns> Return value is void </returns>
void visit(where_typeclass_constraint _where_typeclass_constraint);
}

View file

@ -2906,6 +2906,20 @@
</TagIndices>
</Tags>
</SyntaxNode>
<SyntaxNode Name="where_typeclass_constraint" BaseName="where_definition">
<Fields>
<SyntaxField Name="restriction" SyntaxType="typeclass_restriction" />
</Fields>
<Methods />
<Tags>
<CategoryIndices>
<CategoryIndex>0</CategoryIndex>
</CategoryIndices>
<TagIndices>
<TagIndex>9</TagIndex>
</TagIndices>
</Tags>
</SyntaxNode>
</SyntaxNodes>
<Settings>
<FileName>Tree.cs</FileName>
@ -2931,7 +2945,7 @@
<Tag Name="Важнейшие" ReferenceCount="207" />
<Tag Name="Method_Procedure_Call" ReferenceCount="2" />
<Tag Name="Yield" ReferenceCount="8" />
<Tag Name="Typeclasses" ReferenceCount="3" />
<Tag Name="Typeclasses" ReferenceCount="4" />
</Tags>
</FilterCategory>
</TagCategories>
@ -2981,6 +2995,7 @@
<HelpData Key=".params" Value="" />
<HelpData Key=".procdef" Value="" />
<HelpData Key=".res" Value="" />
<HelpData Key=".restriction" Value="" />
<HelpData Key=".restriction_args" Value="" />
<HelpData Key=".right" Value="" />
<HelpData Key=".sharp_consts" Value="Список символьных констант в строке вида #123#124#125" />
@ -4312,6 +4327,8 @@
<HelpData Key="where_definition_list.where_definition_list(where_definition _where_definition, SourceContext sc)" Value="" />
<HelpData Key="where_type_specificator_list" Value="" />
<HelpData Key="where_type_specificator_list.defs" Value="" />
<HelpData Key="where_typeclass_constraint" Value="" />
<HelpData Key="where_typeclass_constraint.restriction" Value="" />
<HelpData Key="while_node" Value="Цикл ПОКА" />
<HelpData Key="while_node." Value="" />
<HelpData Key="while_node.CycleType" Value="Тип цикла ПОКА" />