Add typeclass param list
This commit is contained in:
parent
2f8965fbe4
commit
dc26158d0a
|
|
@ -18,7 +18,7 @@ end;
|
|||
begin
|
||||
var v1, v2, v3, res: integer;
|
||||
|
||||
res := Sum3&<integer>(v1, v2, v3);
|
||||
res := Sum3&[integer](v1, v2, v3);
|
||||
|
||||
Write(res);
|
||||
end.
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: OBERON
|
||||
// DateTime: 4/10/2018 5:44:39 PM
|
||||
// DateTime: 4/18/2018 6:59:00 PM
|
||||
// UserName: voganesyan
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -154,7 +154,8 @@
|
|||
%type <ti> class_or_interface_keyword optional_tk_do keyword reserved_keyword
|
||||
%type <ex> typeof_expr
|
||||
%type <stn> simple_fp_sect
|
||||
%type <stn> template_param_list template_type_params
|
||||
%type <stn> template_param_list template_type_params
|
||||
%type <stn> template_type_or_typeclass_params typeclass_params
|
||||
%type <td> template_type
|
||||
%type <stn> try_stmt
|
||||
%type <stn> uses_clause used_units_list
|
||||
|
|
@ -859,7 +860,7 @@ const_variable
|
|||
{
|
||||
$$ = NewConstVariable($1, $2, @$);
|
||||
}
|
||||
| const_variable tkAmpersend template_type_params
|
||||
| const_variable tkAmpersend template_type_or_typeclass_params
|
||||
{
|
||||
$$ = new ident_with_templateparams($1 as addressed_value, $3 as template_param_list, @$);
|
||||
}
|
||||
|
|
@ -1084,12 +1085,29 @@ simple_type_decl
|
|||
;
|
||||
|
||||
typeclass_restriction
|
||||
: simple_type_identifier tkSquareOpen template_param_list tkSquareClose
|
||||
: simple_type_identifier typeclass_params
|
||||
{
|
||||
$$ = new typeclass_restriction(($1 as named_type_reference).ToString(), $3 as template_param_list, @$);
|
||||
$$ = new typeclass_restriction(($1 as named_type_reference).ToString(), $2 as template_param_list, @$);
|
||||
}
|
||||
;
|
||||
|
||||
typeclass_params
|
||||
: tkSquareOpen template_param_list tkSquareClose
|
||||
{
|
||||
$$ = new typeclass_param_list($2 as template_param_list);
|
||||
}
|
||||
;
|
||||
|
||||
template_type_or_typeclass_params
|
||||
: template_type_params
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
| typeclass_params
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
type_decl_identifier
|
||||
: identifier
|
||||
{ $$ = $1; }
|
||||
|
|
@ -2863,7 +2881,7 @@ simple_or_template_type_reference
|
|||
{
|
||||
$$ = new template_type_reference((named_type_reference)$1, (template_param_list)$2, @$);
|
||||
}
|
||||
| simple_type_identifier tkAmpersend template_type_params
|
||||
| simple_type_identifier tkAmpersend template_type_or_typeclass_params
|
||||
{
|
||||
$$ = new template_type_reference((named_type_reference)$1, (template_param_list)$3, @$);
|
||||
}
|
||||
|
|
@ -3294,7 +3312,7 @@ variable
|
|||
{
|
||||
$$ = new roof_dereference($1 as addressed_value,@$);
|
||||
}
|
||||
| variable tkAmpersend template_type_params
|
||||
| variable tkAmpersend template_type_or_typeclass_params
|
||||
{
|
||||
$$ = new ident_with_templateparams($1 as addressed_value, $3 as template_param_list, @$);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1137,6 +1137,11 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
DefaultVisit(_where_typeclass_constraint);
|
||||
}
|
||||
|
||||
public virtual void visit(typeclass_param_list _typeclass_param_list)
|
||||
{
|
||||
DefaultVisit(_typeclass_param_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1813,6 +1813,14 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
}
|
||||
|
||||
public virtual void pre_do_visit(typeclass_param_list _typeclass_param_list)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void post_do_visit(typeclass_param_list _typeclass_param_list)
|
||||
{
|
||||
}
|
||||
|
||||
public override void visit(expression _expression)
|
||||
{
|
||||
DefaultVisit(_expression);
|
||||
|
|
@ -3748,6 +3756,13 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
visit(where_typeclass_constraint.restriction);
|
||||
post_do_visit(_where_typeclass_constraint);
|
||||
}
|
||||
|
||||
public override void visit(typeclass_param_list _typeclass_param_list)
|
||||
{
|
||||
DefaultVisit(_typeclass_param_list);
|
||||
pre_do_visit(_typeclass_param_list);
|
||||
post_do_visit(_typeclass_param_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -472,6 +472,8 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
return new typeclass_definition();
|
||||
case 225:
|
||||
return new where_typeclass_constraint();
|
||||
case 226:
|
||||
return new typeclass_param_list();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -3977,6 +3979,17 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
_where_typeclass_constraint.restriction = _read_node() as typeclass_restriction;
|
||||
}
|
||||
|
||||
|
||||
public void visit(typeclass_param_list _typeclass_param_list)
|
||||
{
|
||||
read_typeclass_param_list(_typeclass_param_list);
|
||||
}
|
||||
|
||||
public void read_typeclass_param_list(typeclass_param_list _typeclass_param_list)
|
||||
{
|
||||
read_template_param_list(_typeclass_param_list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6232,6 +6232,18 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void visit(typeclass_param_list _typeclass_param_list)
|
||||
{
|
||||
bw.Write((Int16)226);
|
||||
write_typeclass_param_list(_typeclass_param_list);
|
||||
}
|
||||
|
||||
public void write_typeclass_param_list(typeclass_param_list _typeclass_param_list)
|
||||
{
|
||||
write_template_param_list(_typeclass_param_list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48188,6 +48188,191 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
///Список параметров тайпкласса
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public partial class typeclass_param_list : template_param_list
|
||||
{
|
||||
|
||||
///<summary>
|
||||
///Конструктор без параметров.
|
||||
///</summary>
|
||||
public typeclass_param_list()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public typeclass_param_list(addressed_value _dereferencing_value,List<type_definition> _params_list)
|
||||
{
|
||||
this._dereferencing_value=_dereferencing_value;
|
||||
this._params_list=_params_list;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public typeclass_param_list(addressed_value _dereferencing_value,List<type_definition> _params_list,SourceContext sc)
|
||||
{
|
||||
this._dereferencing_value=_dereferencing_value;
|
||||
this._params_list=_params_list;
|
||||
source_context = sc;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
public typeclass_param_list(template_param_list _template_param_list): this(_template_param_list.dereferencing_value, _template_param_list.params_list, _template_param_list.source_context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Создает копию узла </summary>
|
||||
public override syntax_tree_node Clone()
|
||||
{
|
||||
typeclass_param_list copy = new typeclass_param_list();
|
||||
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 (dereferencing_value != null)
|
||||
{
|
||||
copy.dereferencing_value = (addressed_value)dereferencing_value.Clone();
|
||||
copy.dereferencing_value.Parent = copy;
|
||||
}
|
||||
if (params_list != null)
|
||||
{
|
||||
foreach (type_definition elem in params_list)
|
||||
{
|
||||
if (elem != null)
|
||||
{
|
||||
copy.Add((type_definition)elem.Clone());
|
||||
copy.Last().Parent = copy;
|
||||
}
|
||||
else
|
||||
copy.Add(null);
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/// <summary> Получает копию данного узла корректного типа </summary>
|
||||
public new typeclass_param_list TypedClone()
|
||||
{
|
||||
return Clone() as typeclass_param_list;
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
|
||||
public override void FillParentsInDirectChilds()
|
||||
{
|
||||
if (attributes != null)
|
||||
attributes.Parent = this;
|
||||
if (dereferencing_value != null)
|
||||
dereferencing_value.Parent = this;
|
||||
if (params_list != null)
|
||||
{
|
||||
foreach (var child in params_list)
|
||||
if (child != null)
|
||||
child.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
///<summary> Заполняет поля Parent во всем поддереве </summary>
|
||||
public override void FillParentsInAllChilds()
|
||||
{
|
||||
FillParentsInDirectChilds();
|
||||
attributes?.FillParentsInAllChilds();
|
||||
dereferencing_value?.FillParentsInAllChilds();
|
||||
if (params_list != null)
|
||||
{
|
||||
foreach (var child in params_list)
|
||||
child?.FillParentsInAllChilds();
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Свойство для получения количества всех подузлов без элементов поля типа List
|
||||
///</summary>
|
||||
public override Int32 subnodes_without_list_elements_count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
|
||||
///</summary>
|
||||
public override Int32 subnodes_count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1 + (params_list == null ? 0 : params_list.Count);
|
||||
}
|
||||
}
|
||||
///<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 dereferencing_value;
|
||||
}
|
||||
Int32 index_counter=ind - 1;
|
||||
if(params_list != null)
|
||||
{
|
||||
if(index_counter < params_list.Count)
|
||||
{
|
||||
return params_list[index_counter];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
|
||||
throw new IndexOutOfRangeException();
|
||||
switch(ind)
|
||||
{
|
||||
case 0:
|
||||
dereferencing_value = (addressed_value)value;
|
||||
break;
|
||||
}
|
||||
Int32 index_counter=ind - 1;
|
||||
if(params_list != null)
|
||||
{
|
||||
if(index_counter < params_list.Count)
|
||||
{
|
||||
params_list[index_counter]= (type_definition)value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///<summary>
|
||||
///Метод для обхода дерева посетителем
|
||||
///</summary>
|
||||
///<param name="visitor">Объект-посетитель.</param>
|
||||
///<returns>Return value is void</returns>
|
||||
public override void visit(IVisitor visitor)
|
||||
{
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1360,6 +1360,12 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
///<param name="_where_typeclass_constraint">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(where_typeclass_constraint _where_typeclass_constraint);
|
||||
///<summary>
|
||||
///Method to visit typeclass_param_list.
|
||||
///</summary>
|
||||
///<param name="_typeclass_param_list">Node to visit</param>
|
||||
///<returns> Return value is void </returns>
|
||||
void visit(typeclass_param_list _typeclass_param_list);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@
|
|||
<Tags>
|
||||
<CategoryIndices>
|
||||
<CategoryIndex>0</CategoryIndex>
|
||||
<CategoryIndex>0</CategoryIndex>
|
||||
</CategoryIndices>
|
||||
<TagIndices>
|
||||
<TagIndex>1</TagIndex>
|
||||
<TagIndex>9</TagIndex>
|
||||
</TagIndices>
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
|
|
@ -2920,6 +2922,24 @@
|
|||
</TagIndices>
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
<SyntaxNode Name="typeclass_param_list" BaseName="template_param_list">
|
||||
<Fields />
|
||||
<Methods>
|
||||
<Method>
|
||||
<Text>public typeclass_param_list(template_param_list _template_param_list): this(_template_param_list.dereferencing_value, _template_param_list.params_list, _template_param_list.source_context)
|
||||
{
|
||||
}</Text>
|
||||
</Method>
|
||||
</Methods>
|
||||
<Tags>
|
||||
<CategoryIndices>
|
||||
<CategoryIndex>0</CategoryIndex>
|
||||
</CategoryIndices>
|
||||
<TagIndices>
|
||||
<TagIndex>9</TagIndex>
|
||||
</TagIndices>
|
||||
</Tags>
|
||||
</SyntaxNode>
|
||||
</SyntaxNodes>
|
||||
<Settings>
|
||||
<FileName>Tree.cs</FileName>
|
||||
|
|
@ -2945,7 +2965,7 @@
|
|||
<Tag Name="Важнейшие" ReferenceCount="207" />
|
||||
<Tag Name="Method_Procedure_Call" ReferenceCount="2" />
|
||||
<Tag Name="Yield" ReferenceCount="8" />
|
||||
<Tag Name="Typeclasses" ReferenceCount="4" />
|
||||
<Tag Name="Typeclasses" ReferenceCount="6" />
|
||||
</Tags>
|
||||
</FilterCategory>
|
||||
</TagCategories>
|
||||
|
|
@ -4139,6 +4159,9 @@
|
|||
<HelpData Key="typeclass_definition" Value="Определение класса типов" />
|
||||
<HelpData Key="typeclass_definition.additional_restrictions" Value="" />
|
||||
<HelpData Key="typeclass_definition.body" Value="" />
|
||||
<HelpData Key="typeclass_param_list" Value="Список параметров тайпкласса" />
|
||||
<HelpData Key="typeclass_param_list.public typeclass_param_list(template_param_list _template_param_list): this(_template_param_list._dereferencing_value, _template_param_list._params_list, _template_param_list.source_context)" Value="" />
|
||||
<HelpData Key="typeclass_param_list.public typeclass_param_list(template_param_list _template_param_list): this(_template_param_list.dereferencing_value, _template_param_list.params_list, _template_param_list.source_context)" Value="" />
|
||||
<HelpData Key="typeclass_restriction" Value="Представляет конструкцию вида Typeclass[T], где Typleclass это ограничение, которое накладывается на тип T" />
|
||||
<HelpData Key="typeclass_restriction.restriction_args" Value="" />
|
||||
<HelpData Key="typed_const_definition" Value="" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue