Add grammar rules and syntax nodes

This commit is contained in:
Bogdan Voloshin 2018-04-05 20:02:37 +03:00
parent b708d655ff
commit 4444cf2689
17 changed files with 3812 additions and 2895 deletions

View file

@ -1,9 +1,9 @@
//
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: IVAN-PC
// DateTime: 25.03.2018 18:30:28
// UserName: Ivan
// Machine: OBERON
// DateTime: 4/5/2018 7:25:13 PM
// UserName: voganesyan
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>
//
@ -1952,6 +1952,8 @@ string cur_yytext = yytext;
case (int)Tokens.tkExternal:
case (int)Tokens.tkYield:
case (int)Tokens.tkSequence:
case (int)Tokens.tkTypeclass:
case (int)Tokens.tkInstance:
yylval = new Union();
yylval.ti = new token_info(cur_yytext,currentLexLocation);
break;

View file

@ -360,6 +360,8 @@ UNICODEARROW \x890
case (int)Tokens.tkExternal:
case (int)Tokens.tkYield:
case (int)Tokens.tkSequence:
case (int)Tokens.tkTypeclass:
case (int)Tokens.tkInstance:
yylval = new Union();
yylval.ti = new token_info(cur_yytext,currentLexLocation);
break;

View file

@ -33,7 +33,7 @@
%token <ti> tkDirectiveName tkAmpersend tkColon tkDotDot tkPoint tkRoundOpen tkRoundClose tkSemiColon tkSquareOpen tkSquareClose tkQuestion tkQuestionPoint tkDoubleQuestion tkQuestionSquareOpen
%token <ti> tkSizeOf tkTypeOf tkWhere tkArray tkCase tkClass tkAuto tkConst tkConstructor tkDestructor tkElse tkExcept tkFile tkFor tkForeach tkFunction
%token <ti> tkIf tkImplementation tkInherited tkInterface tkProcedure tkOperator tkProperty tkRaise tkRecord tkSet tkType tkThen tkUses tkVar tkWhile tkWith tkNil
%token <ti> tkIf tkImplementation tkInherited tkInterface tkTypeclass tkInstance tkProcedure tkOperator tkProperty tkRaise tkRecord tkSet tkType tkThen tkUses tkVar tkWhile tkWith tkNil
%token <ti> tkGoto tkOf tkLabel tkLock tkProgram tkEvent tkDefault tkTemplate tkPacked tkExports tkResourceString tkThreadvar tkSealed tkPartial tkTo tkDownto
%token <ti> tkLoop
%token <ti> tkSequence tkYield
@ -93,6 +93,7 @@
%type <id> func_name_ident param_name const_field_name func_name_with_template_args identifier_or_keyword unit_name exception_variable const_name func_meth_name_ident label_name type_decl_identifier template_identifier_with_equal
%type <id> program_param identifier identifier_keyword_operatorname func_class_name_ident optional_identifier visibility_specifier
%type <id> property_specifier_directives non_reserved
%type <id> typeclass_restriction
%type <stn> if_stmt
%type <stn> initialization_part
%type <stn> template_arguments label_list ident_or_keyword_pointseparator_list ident_list param_name_list
@ -1072,8 +1073,23 @@ simple_type_decl
{
$$ = new type_declaration($1, $2, @$);
}
| typeclass_restriction tkEqual tkTypeclass optional_base_classes optional_component_list_seq_end tkSemiColon
{
$$ = new type_declaration($1 as typeclass_restriction, new typeclass_definition($4 as named_type_reference_list, $5 as class_body_list, @$), @$);
}
| typeclass_restriction tkEqual tkInstance optional_component_list_seq_end tkSemiColon
{
$$ = new type_declaration($1 as typeclass_restriction, new instance_definition($4 as class_body_list, @$), @$);
}
;
typeclass_restriction
: simple_type_identifier tkSquareOpen template_param_list tkSquareClose
{
$$ = new typeclass_restriction(($1 as named_type_reference).ToString(), $3 as template_param_list, @$);
}
;
type_decl_identifier
: identifier
{ $$ = $1; }
@ -1550,6 +1566,10 @@ where_part
{
$$ = new where_definition($2 as ident_list, $4 as where_type_specificator_list, @$);
}
| tkWhere typeclass_restriction tkSemiColon
{
$$ = $1;
}
;
type_ref_and_secific_list

File diff suppressed because it is too large Load diff

View file

@ -142,6 +142,8 @@ namespace GPPGParserScanner
keywords.Add(Convert("sequence"), (int)Tokens.tkSequence);
keywords.Add(Convert("yield"), (int)Tokens.tkYield);
keywords.Add(Convert("namespace"), (int)Tokens.tkNamespace);
keywords.Add(Convert("typeclass"), (int)Tokens.tkTypeclass);
keywords.Add(Convert("instance"), (int)Tokens.tkInstance);
}
static Keywords()

View file

@ -8,16 +8,16 @@ namespace PascalABCCompiler.SyntaxTree
{
}
public virtual void visit(syntax_tree_node _syntax_tree_node)
{
DefaultVisit(_syntax_tree_node);
}
public virtual void visit(expression _expression)
{
DefaultVisit(_expression);
}
public virtual void visit(syntax_tree_node _syntax_tree_node)
{
DefaultVisit(_syntax_tree_node);
}
public virtual void visit(statement _statement)
{
DefaultVisit(_statement);
@ -1118,7 +1118,21 @@ namespace PascalABCCompiler.SyntaxTree
DefaultVisit(_double_question_node);
}
}
public virtual void visit(typeclass_restriction _typeclass_restriction)
{
DefaultVisit(_typeclass_restriction);
}
public virtual void visit(instance_definition _instance_definition)
{
DefaultVisit(_instance_definition);
}
public virtual void visit(typeclass_definition _typeclass_definition)
{
DefaultVisit(_typeclass_definition);
}
}
}

View file

@ -5,14 +5,6 @@ namespace PascalABCCompiler.SyntaxTree
public class HierarchyVisitor: AbstractVisitor
{
public virtual void pre_do_visit(syntax_tree_node _syntax_tree_node)
{
}
public virtual void post_do_visit(syntax_tree_node _syntax_tree_node)
{
}
public virtual void pre_do_visit(expression _expression)
{
}
@ -21,6 +13,14 @@ namespace PascalABCCompiler.SyntaxTree
{
}
public virtual void pre_do_visit(syntax_tree_node _syntax_tree_node)
{
}
public virtual void post_do_visit(syntax_tree_node _syntax_tree_node)
{
}
public virtual void pre_do_visit(statement _statement)
{
}
@ -1781,11 +1781,28 @@ namespace PascalABCCompiler.SyntaxTree
{
}
public override void visit(syntax_tree_node _syntax_tree_node)
public virtual void pre_do_visit(typeclass_restriction _typeclass_restriction)
{
}
public virtual void post_do_visit(typeclass_restriction _typeclass_restriction)
{
}
public virtual void pre_do_visit(instance_definition _instance_definition)
{
}
public virtual void post_do_visit(instance_definition _instance_definition)
{
}
public virtual void pre_do_visit(typeclass_definition _typeclass_definition)
{
}
public virtual void post_do_visit(typeclass_definition _typeclass_definition)
{
DefaultVisit(_syntax_tree_node);
pre_do_visit(_syntax_tree_node);
post_do_visit(_syntax_tree_node);
}
public override void visit(expression _expression)
@ -1795,6 +1812,13 @@ namespace PascalABCCompiler.SyntaxTree
post_do_visit(_expression);
}
public override void visit(syntax_tree_node _syntax_tree_node)
{
DefaultVisit(_syntax_tree_node);
pre_do_visit(_syntax_tree_node);
post_do_visit(_syntax_tree_node);
}
public override void visit(statement _statement)
{
DefaultVisit(_statement);
@ -3683,6 +3707,31 @@ namespace PascalABCCompiler.SyntaxTree
visit(double_question_node.right);
post_do_visit(_double_question_node);
}
public override void visit(typeclass_restriction _typeclass_restriction)
{
DefaultVisit(_typeclass_restriction);
pre_do_visit(_typeclass_restriction);
visit(typeclass_restriction.restriction_args);
post_do_visit(_typeclass_restriction);
}
public override void visit(instance_definition _instance_definition)
{
DefaultVisit(_instance_definition);
pre_do_visit(_instance_definition);
visit(instance_definition.body);
post_do_visit(_instance_definition);
}
public override void visit(typeclass_definition _typeclass_definition)
{
DefaultVisit(_typeclass_definition);
pre_do_visit(_typeclass_definition);
visit(typeclass_definition.additional_restrictions);
visit(typeclass_definition.body);
post_do_visit(_typeclass_definition);
}
}

View file

@ -21,9 +21,9 @@ namespace PascalABCCompiler.SyntaxTree
switch(node_class_number)
{
case 0:
return new syntax_tree_node();
case 1:
return new expression();
case 1:
return new syntax_tree_node();
case 2:
return new statement();
case 3:
@ -464,6 +464,12 @@ namespace PascalABCCompiler.SyntaxTree
return new sugared_addressed_value();
case 221:
return new double_question_node();
case 222:
return new typeclass_restriction();
case 223:
return new instance_definition();
case 224:
return new typeclass_definition();
}
return null;
}
@ -481,6 +487,17 @@ namespace PascalABCCompiler.SyntaxTree
}
}
public void visit(expression _expression)
{
read_expression(_expression);
}
public void read_expression(expression _expression)
{
read_declaration(_expression);
}
public void visit(syntax_tree_node _syntax_tree_node)
{
read_syntax_tree_node(_syntax_tree_node);
@ -509,17 +526,6 @@ namespace PascalABCCompiler.SyntaxTree
}
public void visit(expression _expression)
{
read_expression(_expression);
}
public void read_expression(expression _expression)
{
read_declaration(_expression);
}
public void visit(statement _statement)
{
read_statement(_statement);
@ -3920,6 +3926,43 @@ namespace PascalABCCompiler.SyntaxTree
_double_question_node.right = _read_node() as expression;
}
public void visit(typeclass_restriction _typeclass_restriction)
{
read_typeclass_restriction(_typeclass_restriction);
}
public void read_typeclass_restriction(typeclass_restriction _typeclass_restriction)
{
read_ident(_typeclass_restriction);
_typeclass_restriction.restriction_args = _read_node() as template_param_list;
}
public void visit(instance_definition _instance_definition)
{
read_instance_definition(_instance_definition);
}
public void read_instance_definition(instance_definition _instance_definition)
{
read_type_definition(_instance_definition);
_instance_definition.body = _read_node() as class_body_list;
}
public void visit(typeclass_definition _typeclass_definition)
{
read_typeclass_definition(_typeclass_definition);
}
public void read_typeclass_definition(typeclass_definition _typeclass_definition)
{
read_type_definition(_typeclass_definition);
_typeclass_definition.additional_restrictions = _read_node() as named_type_reference_list;
_typeclass_definition.body = _read_node() as class_body_list;
}
}

View file

@ -16,9 +16,21 @@ namespace PascalABCCompiler.SyntaxTree
public BinaryWriter bw;
public void visit(syntax_tree_node _syntax_tree_node)
public void visit(expression _expression)
{
bw.Write((Int16)0);
write_expression(_expression);
}
public void write_expression(expression _expression)
{
write_declaration(_expression);
}
public void visit(syntax_tree_node _syntax_tree_node)
{
bw.Write((Int16)1);
write_syntax_tree_node(_syntax_tree_node);
}
@ -55,18 +67,6 @@ namespace PascalABCCompiler.SyntaxTree
}
public void visit(expression _expression)
{
bw.Write((Int16)1);
write_expression(_expression);
}
public void write_expression(expression _expression)
{
write_declaration(_expression);
}
public void visit(statement _statement)
{
bw.Write((Int16)2);
@ -6139,6 +6139,78 @@ namespace PascalABCCompiler.SyntaxTree
}
}
public void visit(typeclass_restriction _typeclass_restriction)
{
bw.Write((Int16)222);
write_typeclass_restriction(_typeclass_restriction);
}
public void write_typeclass_restriction(typeclass_restriction _typeclass_restriction)
{
write_ident(_typeclass_restriction);
if (_typeclass_restriction.restriction_args == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_typeclass_restriction.restriction_args.visit(this);
}
}
public void visit(instance_definition _instance_definition)
{
bw.Write((Int16)223);
write_instance_definition(_instance_definition);
}
public void write_instance_definition(instance_definition _instance_definition)
{
write_type_definition(_instance_definition);
if (_instance_definition.body == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_instance_definition.body.visit(this);
}
}
public void visit(typeclass_definition _typeclass_definition)
{
bw.Write((Int16)224);
write_typeclass_definition(_typeclass_definition);
}
public void write_typeclass_definition(typeclass_definition _typeclass_definition)
{
write_type_definition(_typeclass_definition);
if (_typeclass_definition.additional_restrictions == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_typeclass_definition.additional_restrictions.visit(this);
}
if (_typeclass_definition.body == null)
{
bw.Write((byte)0);
}
else
{
bw.Write((byte)1);
_typeclass_definition.body.visit(this);
}
}
}

View file

@ -5,6 +5,106 @@ using System.Collections.Generic;
namespace PascalABCCompiler.SyntaxTree
{
///<summary>
///Выражение
///</summary>
[Serializable]
public partial class expression : declaration
{
///<summary>
///Конструктор без параметров.
///</summary>
public expression()
{
}
/// <summary> Создает копию узла </summary>
public override syntax_tree_node Clone()
{
expression copy = new expression();
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;
}
return copy;
}
/// <summary> Получает копию данного узла корректного типа </summary>
public new expression TypedClone()
{
return Clone() as expression;
}
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
public override void FillParentsInDirectChilds()
{
if (attributes != null)
attributes.Parent = this;
}
///<summary> Заполняет поля Parent во всем поддереве </summary>
public override void FillParentsInAllChilds()
{
FillParentsInDirectChilds();
attributes?.FillParentsInAllChilds();
}
///<summary>
///Свойство для получения количества всех подузлов без элементов поля типа List
///</summary>
public override Int32 subnodes_without_list_elements_count
{
get
{
return 0;
}
}
///<summary>
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
///</summary>
public override Int32 subnodes_count
{
get
{
return 0;
}
}
///<summary>
///Индексатор для получения всех подузлов
///</summary>
public override syntax_tree_node this[Int32 ind]
{
get
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
return null;
}
set
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
}
}
///<summary>
///Метод для обхода дерева посетителем
///</summary>
///<param name="visitor">Объект-посетитель.</param>
///<returns>Return value is void</returns>
public override void visit(IVisitor visitor)
{
visitor.visit(this);
}
}
///<summary>
///Базовый класс для всех классов синтаксического дерева
///</summary>
@ -133,106 +233,6 @@ namespace PascalABCCompiler.SyntaxTree
}
///<summary>
///Выражение
///</summary>
[Serializable]
public partial class expression : declaration
{
///<summary>
///Конструктор без параметров.
///</summary>
public expression()
{
}
/// <summary> Создает копию узла </summary>
public override syntax_tree_node Clone()
{
expression copy = new expression();
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;
}
return copy;
}
/// <summary> Получает копию данного узла корректного типа </summary>
public new expression TypedClone()
{
return Clone() as expression;
}
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
public override void FillParentsInDirectChilds()
{
if (attributes != null)
attributes.Parent = this;
}
///<summary> Заполняет поля Parent во всем поддереве </summary>
public override void FillParentsInAllChilds()
{
FillParentsInDirectChilds();
attributes?.FillParentsInAllChilds();
}
///<summary>
///Свойство для получения количества всех подузлов без элементов поля типа List
///</summary>
public override Int32 subnodes_without_list_elements_count
{
get
{
return 0;
}
}
///<summary>
///Свойство для получения количества всех подузлов. Подузлом также считается каждый элемент поля типа List
///</summary>
public override Int32 subnodes_count
{
get
{
return 0;
}
}
///<summary>
///Индексатор для получения всех подузлов
///</summary>
public override syntax_tree_node this[Int32 ind]
{
get
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
return null;
}
set
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
}
}
///<summary>
///Метод для обхода дерева посетителем
///</summary>
///<param name="visitor">Объект-посетитель.</param>
///<returns>Return value is void</returns>
public override void visit(IVisitor visitor)
{
visitor.visit(this);
}
}
///<summary>
///Оператор
///</summary>
@ -47404,6 +47404,594 @@ namespace PascalABCCompiler.SyntaxTree
}
///<summary>
///Представляет конструкцию вида Typeclass[T], где Typleclass это ограничение, которое накладывается на тип T
///</summary>
[Serializable]
public partial class typeclass_restriction : ident
{
///<summary>
///Конструктор без параметров.
///</summary>
public typeclass_restriction()
{
}
///<summary>
///Конструктор с параметрами.
///</summary>
public typeclass_restriction(template_param_list _restriction_args)
{
this._restriction_args=_restriction_args;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public typeclass_restriction(template_param_list _restriction_args,SourceContext sc)
{
this._restriction_args=_restriction_args;
source_context = sc;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public typeclass_restriction(string _name,template_param_list _restriction_args)
{
this._name=_name;
this._restriction_args=_restriction_args;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public typeclass_restriction(string _name,template_param_list _restriction_args,SourceContext sc)
{
this._name=_name;
this._restriction_args=_restriction_args;
source_context = sc;
FillParentsInDirectChilds();
}
protected template_param_list _restriction_args;
///<summary>
///
///</summary>
public template_param_list restriction_args
{
get
{
return _restriction_args;
}
set
{
_restriction_args=value;
}
}
/// <summary> Создает копию узла </summary>
public override syntax_tree_node Clone()
{
typeclass_restriction copy = new typeclass_restriction();
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;
}
copy.name = name;
if (restriction_args != null)
{
copy.restriction_args = (template_param_list)restriction_args.Clone();
copy.restriction_args.Parent = copy;
}
return copy;
}
/// <summary> Получает копию данного узла корректного типа </summary>
public new typeclass_restriction TypedClone()
{
return Clone() as typeclass_restriction;
}
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
public override void FillParentsInDirectChilds()
{
if (attributes != null)
attributes.Parent = this;
if (restriction_args != null)
restriction_args.Parent = this;
}
///<summary> Заполняет поля Parent во всем поддереве </summary>
public override void FillParentsInAllChilds()
{
FillParentsInDirectChilds();
attributes?.FillParentsInAllChilds();
restriction_args?.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;
}
}
///<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 restriction_args;
}
return null;
}
set
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
switch(ind)
{
case 0:
restriction_args = (template_param_list)value;
break;
}
}
}
///<summary>
///Метод для обхода дерева посетителем
///</summary>
///<param name="visitor">Объект-посетитель.</param>
///<returns>Return value is void</returns>
public override void visit(IVisitor visitor)
{
visitor.visit(this);
}
}
///<summary>
///Определение того как конкретный тип удовлетворяет классу типов.
///</summary>
[Serializable]
public partial class instance_definition : type_definition
{
///<summary>
///Конструктор без параметров.
///</summary>
public instance_definition()
{
}
///<summary>
///Конструктор с параметрами.
///</summary>
public instance_definition(class_body_list _body)
{
this._body=_body;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public instance_definition(class_body_list _body,SourceContext sc)
{
this._body=_body;
source_context = sc;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public instance_definition(type_definition_attr_list _attr_list,class_body_list _body)
{
this._attr_list=_attr_list;
this._body=_body;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public instance_definition(type_definition_attr_list _attr_list,class_body_list _body,SourceContext sc)
{
this._attr_list=_attr_list;
this._body=_body;
source_context = sc;
FillParentsInDirectChilds();
}
protected class_body_list _body;
///<summary>
///
///</summary>
public class_body_list body
{
get
{
return _body;
}
set
{
_body=value;
}
}
/// <summary> Создает копию узла </summary>
public override syntax_tree_node Clone()
{
instance_definition copy = new instance_definition();
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 (attr_list != null)
{
copy.attr_list = (type_definition_attr_list)attr_list.Clone();
copy.attr_list.Parent = copy;
}
if (body != null)
{
copy.body = (class_body_list)body.Clone();
copy.body.Parent = copy;
}
return copy;
}
/// <summary> Получает копию данного узла корректного типа </summary>
public new instance_definition TypedClone()
{
return Clone() as instance_definition;
}
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
public override void FillParentsInDirectChilds()
{
if (attributes != null)
attributes.Parent = this;
if (attr_list != null)
attr_list.Parent = this;
if (body != null)
body.Parent = this;
}
///<summary> Заполняет поля Parent во всем поддереве </summary>
public override void FillParentsInAllChilds()
{
FillParentsInDirectChilds();
attributes?.FillParentsInAllChilds();
attr_list?.FillParentsInAllChilds();
body?.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 attr_list;
case 1:
return body;
}
return null;
}
set
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
switch(ind)
{
case 0:
attr_list = (type_definition_attr_list)value;
break;
case 1:
body = (class_body_list)value;
break;
}
}
}
///<summary>
///Метод для обхода дерева посетителем
///</summary>
///<param name="visitor">Объект-посетитель.</param>
///<returns>Return value is void</returns>
public override void visit(IVisitor visitor)
{
visitor.visit(this);
}
}
///<summary>
///Определение класса типов
///</summary>
[Serializable]
public partial class typeclass_definition : type_definition
{
///<summary>
///Конструктор без параметров.
///</summary>
public typeclass_definition()
{
}
///<summary>
///Конструктор с параметрами.
///</summary>
public typeclass_definition(named_type_reference_list _additional_restrictions,class_body_list _body)
{
this._additional_restrictions=_additional_restrictions;
this._body=_body;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public typeclass_definition(named_type_reference_list _additional_restrictions,class_body_list _body,SourceContext sc)
{
this._additional_restrictions=_additional_restrictions;
this._body=_body;
source_context = sc;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public typeclass_definition(type_definition_attr_list _attr_list,named_type_reference_list _additional_restrictions,class_body_list _body)
{
this._attr_list=_attr_list;
this._additional_restrictions=_additional_restrictions;
this._body=_body;
FillParentsInDirectChilds();
}
///<summary>
///Конструктор с параметрами.
///</summary>
public typeclass_definition(type_definition_attr_list _attr_list,named_type_reference_list _additional_restrictions,class_body_list _body,SourceContext sc)
{
this._attr_list=_attr_list;
this._additional_restrictions=_additional_restrictions;
this._body=_body;
source_context = sc;
FillParentsInDirectChilds();
}
protected named_type_reference_list _additional_restrictions;
protected class_body_list _body;
///<summary>
///
///</summary>
public named_type_reference_list additional_restrictions
{
get
{
return _additional_restrictions;
}
set
{
_additional_restrictions=value;
}
}
///<summary>
///
///</summary>
public class_body_list body
{
get
{
return _body;
}
set
{
_body=value;
}
}
/// <summary> Создает копию узла </summary>
public override syntax_tree_node Clone()
{
typeclass_definition copy = new typeclass_definition();
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 (attr_list != null)
{
copy.attr_list = (type_definition_attr_list)attr_list.Clone();
copy.attr_list.Parent = copy;
}
if (additional_restrictions != null)
{
copy.additional_restrictions = (named_type_reference_list)additional_restrictions.Clone();
copy.additional_restrictions.Parent = copy;
}
if (body != null)
{
copy.body = (class_body_list)body.Clone();
copy.body.Parent = copy;
}
return copy;
}
/// <summary> Получает копию данного узла корректного типа </summary>
public new typeclass_definition TypedClone()
{
return Clone() as typeclass_definition;
}
///<summary> Заполняет поля Parent в непосредственных дочерних узлах </summary>
public override void FillParentsInDirectChilds()
{
if (attributes != null)
attributes.Parent = this;
if (attr_list != null)
attr_list.Parent = this;
if (additional_restrictions != null)
additional_restrictions.Parent = this;
if (body != null)
body.Parent = this;
}
///<summary> Заполняет поля Parent во всем поддереве </summary>
public override void FillParentsInAllChilds()
{
FillParentsInDirectChilds();
attributes?.FillParentsInAllChilds();
attr_list?.FillParentsInAllChilds();
additional_restrictions?.FillParentsInAllChilds();
body?.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 attr_list;
case 1:
return additional_restrictions;
case 2:
return body;
}
return null;
}
set
{
if(subnodes_count == 0 || ind < 0 || ind > subnodes_count-1)
throw new IndexOutOfRangeException();
switch(ind)
{
case 0:
attr_list = (type_definition_attr_list)value;
break;
case 1:
additional_restrictions = (named_type_reference_list)value;
break;
case 2:
body = (class_body_list)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

@ -4,12 +4,6 @@ namespace PascalABCCompiler.SyntaxTree
public interface IVisitor
{
///<summary>
///Method to visit syntax_tree_node.
///</summary>
///<param name="_syntax_tree_node">Node to visit</param>
///<returns> Return value is void </returns>
void visit(syntax_tree_node _syntax_tree_node);
///<summary>
///Method to visit expression.
///</summary>
@ -17,6 +11,12 @@ namespace PascalABCCompiler.SyntaxTree
///<returns> Return value is void </returns>
void visit(expression _expression);
///<summary>
///Method to visit syntax_tree_node.
///</summary>
///<param name="_syntax_tree_node">Node to visit</param>
///<returns> Return value is void </returns>
void visit(syntax_tree_node _syntax_tree_node);
///<summary>
///Method to visit statement.
///</summary>
///<param name="_statement">Node to visit</param>
@ -1336,6 +1336,24 @@ namespace PascalABCCompiler.SyntaxTree
///<param name="_double_question_node">Node to visit</param>
///<returns> Return value is void </returns>
void visit(double_question_node _double_question_node);
///<summary>
///Method to visit typeclass_restriction.
///</summary>
///<param name="_typeclass_restriction">Node to visit</param>
///<returns> Return value is void </returns>
void visit(typeclass_restriction _typeclass_restriction);
///<summary>
///Method to visit instance_definition.
///</summary>
///<param name="_instance_definition">Node to visit</param>
///<returns> Return value is void </returns>
void visit(instance_definition _instance_definition);
///<summary>
///Method to visit typeclass_definition.
///</summary>
///<param name="_typeclass_definition">Node to visit</param>
///<returns> Return value is void </returns>
void visit(typeclass_definition _typeclass_definition);
}

View file

@ -2855,6 +2855,57 @@
<TagIndices />
</Tags>
</SyntaxNode>
<SyntaxNode Name="typeclass_restriction" BaseName="ident">
<Fields>
<SyntaxField Name="restriction_args" SyntaxType="template_param_list" />
</Fields>
<Methods />
<Tags>
<CategoryIndices>
<CategoryIndex>0</CategoryIndex>
</CategoryIndices>
<TagIndices>
<TagIndex>9</TagIndex>
</TagIndices>
</Tags>
</SyntaxNode>
<SyntaxNode Name="instance_definition" BaseName="type_definition">
<Fields>
<SyntaxField Name="body" SyntaxType="class_body_list" />
</Fields>
<Methods />
<Tags>
<CategoryIndices>
<CategoryIndex>0</CategoryIndex>
<CategoryIndex>0</CategoryIndex>
<CategoryIndex>0</CategoryIndex>
</CategoryIndices>
<TagIndices>
<TagIndex>4</TagIndex>
<TagIndex>9</TagIndex>
<TagIndex>5</TagIndex>
</TagIndices>
</Tags>
</SyntaxNode>
<SyntaxNode Name="typeclass_definition" BaseName="type_definition">
<Fields>
<SyntaxField Name="additional_restrictions" SyntaxType="named_type_reference_list" />
<SyntaxField Name="body" SyntaxType="class_body_list" />
</Fields>
<Methods />
<Tags>
<CategoryIndices>
<CategoryIndex>0</CategoryIndex>
<CategoryIndex>0</CategoryIndex>
<CategoryIndex>0</CategoryIndex>
</CategoryIndices>
<TagIndices>
<TagIndex>9</TagIndex>
<TagIndex>4</TagIndex>
<TagIndex>5</TagIndex>
</TagIndices>
</Tags>
</SyntaxNode>
</SyntaxNodes>
<Settings>
<FileName>Tree.cs</FileName>
@ -2875,11 +2926,12 @@
<Tag Name="Выражения" ReferenceCount="36" />
<Tag Name="Константы" ReferenceCount="15" />
<Tag Name="Списки" ReferenceCount="23" />
<Tag Name="Типы" ReferenceCount="12" />
<Tag Name="Описания" ReferenceCount="23" />
<Tag Name="Типы" ReferenceCount="14" />
<Tag Name="Описания" ReferenceCount="25" />
<Tag Name="Важнейшие" ReferenceCount="207" />
<Tag Name="Method_Procedure_Call" ReferenceCount="2" />
<Tag Name="Yield" ReferenceCount="8" />
<Tag Name="Typeclasses" ReferenceCount="3" />
</Tags>
</FilterCategory>
</TagCategories>
@ -2895,9 +2947,11 @@
<HelpData Key=".UnknownID" Value="" />
<HelpData Key=".Vds" Value="" />
<HelpData Key="._realType" Value="" />
<HelpData Key=".additional_restrictions" Value="" />
<HelpData Key=".aloneparam" Value="" />
<HelpData Key=".attr" Value="" />
<HelpData Key=".attributes" Value="" />
<HelpData Key=".body" Value="" />
<HelpData Key=".cconst" Value="Значение константы." />
<HelpData Key=".char_num" Value="Номер символа." />
<HelpData Key=".count" Value="" />
@ -2927,6 +2981,7 @@
<HelpData Key=".params" Value="" />
<HelpData Key=".procdef" Value="" />
<HelpData Key=".res" Value="" />
<HelpData Key=".restriction_args" Value="" />
<HelpData Key=".right" Value="" />
<HelpData Key=".sharp_consts" Value="Список символьных констант в строке вида #123#124#125" />
<HelpData Key=".specificator" Value="" />
@ -3463,6 +3518,8 @@
<HelpData Key="initfinal_part.initfinal_part(statement_list init,statement_list fin,SourceContext sc)" Value="" />
<HelpData Key="initfinal_part.initfinal_part(syntax_tree_node stn1, statement_list init, syntax_tree_node stn2, statement_list fin, syntax_tree_node stn3, SourceContext sc)" Value="" />
<HelpData Key="initfinal_part.initialization_sect" Value="" />
<HelpData Key="instance_definition" Value="Определение того как конкретный тип удовлетворяет классу типов." />
<HelpData Key="instance_definition.body" Value="" />
<HelpData Key="int32_const" Value="Целая константа" />
<HelpData Key="int32_const." Value="" />
<HelpData Key="int32_const.override string ToString()" Value="" />
@ -4064,6 +4121,11 @@
<HelpData Key="typecast_node.left" Value="" />
<HelpData Key="typecast_node.right" Value="" />
<HelpData Key="typecast_node.type_def" Value="" />
<HelpData Key="typeclass_definition" Value="Определение класса типов" />
<HelpData Key="typeclass_definition.additional_restrictions" Value="" />
<HelpData Key="typeclass_definition.body" Value="" />
<HelpData Key="typeclass_restriction" Value="Представляет конструкцию вида Typeclass[T], где Typleclass это ограничение, которое накладывается на тип T" />
<HelpData Key="typeclass_restriction.restriction_args" Value="" />
<HelpData Key="typed_const_definition" Value="" />
<HelpData Key="typed_const_definition.const_type" Value="" />
<HelpData Key="typed_parameters" Value="" />

View file

@ -3125,7 +3125,7 @@ begin
while t<>typeof(Object) do
begin
meth := t.GetMethod('ToString',System.Reflection.BindingFlags.Public or
System.Reflection.BindingFlags.Instance or
System.Reflection.BindingFlags.&Instance or
System.Reflection.BindingFlags.DeclaredOnly,nil,new System.Type[0],nil);
if meth<>nil then
break;
@ -3209,8 +3209,8 @@ begin
else
while t<>typeof(object) do
begin
var ff := t.GetFields(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.DeclaredOnly);
var pp := t.GetProperties(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.DeclaredOnly);
var ff := t.GetFields(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.&Instance or System.Reflection.BindingFlags.DeclaredOnly);
var pp := t.GetProperties(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.&Instance or System.Reflection.BindingFlags.DeclaredOnly);
for var i:=ff.Length-1 downto 0 do
sb.Insert(1,StructuredObjectToString(ff[i].GetValue(o),n+1)+',');
@ -10667,7 +10667,7 @@ begin
begin
variable.GetType.InvokeMember('$Init$',
System.Reflection.BindingFlags.InvokeMethod or
System.Reflection.BindingFlags.Instance or
System.Reflection.BindingFlags.&Instance or
System.Reflection.BindingFlags.Public, nil, variable, nil);
result := variable;
end;

View file

@ -2,7 +2,7 @@
uses System,System.Reflection;
begin
var bf := BindingFlags.Public or BindingFlags.NonPublic or BindingFlags.Instance or BindingFlags.Static;
var bf := BindingFlags.Public or BindingFlags.NonPublic or BindingFlags.&Instance or BindingFlags.Static;
var t: &Type := typeof(DateTime);
var mi := t.GetMembers(bf);
foreach m: MemberInfo in mi do

View file

@ -3043,7 +3043,7 @@ begin
while t<>typeof(Object) do
begin
meth := t.GetMethod('ToString',System.Reflection.BindingFlags.Public or
System.Reflection.BindingFlags.Instance or
System.Reflection.BindingFlags.&Instance or
System.Reflection.BindingFlags.DeclaredOnly,nil,new System.Type[0],nil);
if meth<>nil then
break;
@ -3127,8 +3127,8 @@ begin
else
while t<>typeof(object) do
begin
var ff := t.GetFields(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.DeclaredOnly);
var pp := t.GetProperties(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.DeclaredOnly);
var ff := t.GetFields(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.&Instance or System.Reflection.BindingFlags.DeclaredOnly);
var pp := t.GetProperties(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.&Instance or System.Reflection.BindingFlags.DeclaredOnly);
for var i:=ff.Length-1 downto 0 do
sb.Insert(1,StructuredObjectToString(ff[i].GetValue(o),n+1)+',');
@ -10427,7 +10427,7 @@ begin
begin
variable.GetType.InvokeMember('$Init$',
System.Reflection.BindingFlags.InvokeMethod or
System.Reflection.BindingFlags.Instance or
System.Reflection.BindingFlags.&Instance or
System.Reflection.BindingFlags.Public, nil, variable, nil);
result := variable;
end;

View file

@ -2,7 +2,7 @@
uses System,System.Reflection;
begin
var bf := BindingFlags.Public or BindingFlags.NonPublic or BindingFlags.Instance or BindingFlags.Static;
var bf := BindingFlags.Public or BindingFlags.NonPublic or BindingFlags.&Instance or BindingFlags.Static;
var t: &Type := typeof(DateTime);
var mi := t.GetMembers(bf);
foreach m: MemberInfo in mi do

View file

@ -3125,7 +3125,7 @@ begin
while t<>typeof(Object) do
begin
meth := t.GetMethod('ToString',System.Reflection.BindingFlags.Public or
System.Reflection.BindingFlags.Instance or
System.Reflection.BindingFlags.&Instance or
System.Reflection.BindingFlags.DeclaredOnly,nil,new System.Type[0],nil);
if meth<>nil then
break;
@ -3209,8 +3209,8 @@ begin
else
while t<>typeof(object) do
begin
var ff := t.GetFields(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.DeclaredOnly);
var pp := t.GetProperties(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.DeclaredOnly);
var ff := t.GetFields(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.&Instance or System.Reflection.BindingFlags.DeclaredOnly);
var pp := t.GetProperties(System.Reflection.BindingFlags.Public or System.Reflection.BindingFlags.&Instance or System.Reflection.BindingFlags.DeclaredOnly);
for var i:=ff.Length-1 downto 0 do
sb.Insert(1,StructuredObjectToString(ff[i].GetValue(o),n+1)+',');
@ -10667,7 +10667,7 @@ begin
begin
variable.GetType.InvokeMember('$Init$',
System.Reflection.BindingFlags.InvokeMethod or
System.Reflection.BindingFlags.Instance or
System.Reflection.BindingFlags.&Instance or
System.Reflection.BindingFlags.Public, nil, variable, nil);
result := variable;
end;