Типы (integer,real) теперь работают и не конкурируют с перечислимыми типами!!!!!

Пришлось запретить скобки в range-типе - иначе были конфликты.
Пока не проверяю неправильность записи (integer = 1, integer = 1) - надо обязательно выдавать ошибку
This commit is contained in:
miks1965 2016-01-15 22:06:39 +03:00
parent 937c990181
commit 711cba9c11
17 changed files with 2257 additions and 2208 deletions

View file

@ -2758,14 +2758,15 @@ namespace CodeCompletion
if (_enum_type_definition.enumerators != null)
foreach (enumerator en in _enum_type_definition.enumerators.enumerators)
{
ElementScope ss = new ElementScope(new SymInfo(en.name.name, SymbolKind.Constant, en.name.name),/*cur_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name)*/enum_scope, cur_scope);
var name = (en.name as named_type_reference).FirstIdent.name;
ElementScope ss = new ElementScope(new SymInfo(name, SymbolKind.Constant, name),/*cur_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name)*/enum_scope, cur_scope);
ss.is_static = true;
ss.cnst_val = en.name.name;
ss.cnst_val = name;
elems.Add(ss);
ss.loc = get_location(en);
cur_scope.AddName(en.name.name, ss);
enum_scope.AddName(en.name.name, ss);
enum_scope.AddEnumConstant(en.name.name);
cur_scope.AddName(name, ss);
enum_scope.AddName(name, ss);
enum_scope.AddEnumConstant(name);
ss.AddDocumentation(this.converter.controller.docs[en]);
}
for (int i=0; i<elems.Count; i++)
@ -4102,7 +4103,7 @@ namespace CodeCompletion
if (_modern_proc_type.el != null)
foreach (enumerator en in _modern_proc_type.el.enumerators)
{
ttr.params_list.params_list.Add(new named_type_reference(en.name.name));
ttr.params_list.params_list.Add(en.name); // Здесь исправил SSM 15.1.16
}
if (_modern_proc_type.res != null)
ttr.params_list.params_list.Add(_modern_proc_type.res);

View file

@ -1544,7 +1544,7 @@ namespace CodeCompletion
{
foreach (enumerator en in _modern_proc_type.el.enumerators)
{
new named_type_reference(en.name.name, en.source_context).visit(this);
en.name.visit(this); // Ýòî èñïðàâèë - SSM 15.1.16
}
if (_modern_proc_type.res != null)
_modern_proc_type.res.visit(this);

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "0";
public const string Build = "0";
public const string Revision = "1140";
public const string Revision = "1143";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=1141
%REVISION%=1143
%MINOR%=0
%MAJOR%=3

Binary file not shown.

View file

@ -2,7 +2,7 @@
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: SSM
// DateTime: 14.01.2016 20:18:07
// DateTime: 15.01.2016 21:15:29
// UserName: ?????????
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>

View file

@ -1184,13 +1184,6 @@ range_factor
{
$$ = new method_call($1 as addressed_value, $3 as expression_list, @$);
}
| tkRoundOpen const_expr tkRoundClose
{
if (!parsertools.build_tree_for_brackets)
$$ = $2;
else
$$ = new bracket_expr($2, @$);
}
;
simple_type_identifier
@ -1217,11 +1210,11 @@ enumeration_id_list
;
enumeration_id
: identifier
: type_ref
{
$$ = new enumerator($1, null, @$);
}
| identifier tkEqual expr
| type_ref tkEqual expr
{
$$ = new enumerator($1, $3, @$);
}

File diff suppressed because it is too large Load diff

View file

@ -89,6 +89,10 @@ script=

View file

@ -177,7 +177,7 @@ namespace PascalABCCompiler.VBNETParser
ICSharpCode.NRefactory.Ast.FieldDeclaration fld = node as ICSharpCode.NRefactory.Ast.FieldDeclaration;
foreach (ICSharpCode.NRefactory.Ast.VariableDeclaration vd in fld.Fields)
{
enumerator en = new enumerator(new ident(vd.Name),null);
enumerator en = new enumerator(new named_type_reference(vd.Name),null); // SSM здесь исправил 15.1.16
en.source_context = get_source_context(fld);
enum_td.enumerators.enumerators.Add(en);
}

View file

@ -1 +1 @@
!define VERSION '3.0.0.1140'
!define VERSION '3.0.0.1143'

View file

@ -2936,7 +2936,7 @@ namespace PascalABCCompiler.SyntaxTree
public void read_enumerator(enumerator _enumerator)
{
read_syntax_tree_node(_enumerator);
_enumerator.name = _read_node() as ident;
_enumerator.name = _read_node() as type_definition;
_enumerator.value = _read_node() as expression;
}

View file

@ -21363,7 +21363,7 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Конструктор с параметрами.
///</summary>
public enumerator(ident _name,expression _value)
public enumerator(type_definition _name,expression _value)
{
this._name=_name;
this._value=_value;
@ -21372,20 +21372,20 @@ namespace PascalABCCompiler.SyntaxTree
///<summary>
///Конструктор с параметрами.
///</summary>
public enumerator(ident _name,expression _value,SourceContext sc)
public enumerator(type_definition _name,expression _value,SourceContext sc)
{
this._name=_name;
this._value=_value;
source_context = sc;
}
protected ident _name;
protected type_definition _name;
protected expression _value;
///<summary>
///
///</summary>
public ident name
public type_definition name
{
get
{
@ -21458,7 +21458,7 @@ namespace PascalABCCompiler.SyntaxTree
switch(ind)
{
case 0:
name = (ident)value;
name = (type_definition)value;
break;
case 1:
value = (expression)value;

View file

@ -270,6 +270,11 @@ namespace PascalABCCompiler.SyntaxTree
sb.Append("." + names[i].ToString());
return sb.ToString();
}
public ident FirstIdent
{
get { return names[0]; }
}
}
public partial class template_type_reference

Binary file not shown.

View file

@ -3411,6 +3411,55 @@ namespace PascalABCCompiler.TreeConverter
public override void visit(SyntaxTree.enum_type_definition _enum_type_definition)
{
//SSM Proba 15/01/16 для (integer,integer)
// Если кто-то - не named_type_reference с одним ident, то надо идти по ветке типов - это не м.б.перечисление
bool is_tuple_type = false;
foreach (SyntaxTree.enumerator en in _enum_type_definition.enumerators.enumerators)
{
if (!((en.name is named_type_reference) && (en.name as named_type_reference).names.Count()==1))
{
is_tuple_type = true;
break;
}
}
bool is_enum = false;
if (!is_tuple_type) // Значит, все - идентификаторы и сказать пока ничего нельзя
foreach (SyntaxTree.enumerator en in _enum_type_definition.enumerators.enumerators)
{
SyntaxTree.ident id = (en.name as named_type_reference).FirstIdent;
var si = context.CurrentScope.Find(id.name);
if ((si==null) || !(si.sym_info is type_node))
{
is_enum = true;
break;
}
}
if (!is_enum) // Значит, это определение типа
{
var lt = new List<type_definition>();
for (var iii=0; iii<_enum_type_definition.enumerators.enumerators.Count(); iii++)
{
var name = _enum_type_definition.enumerators.enumerators[iii].name;
lt.Add(name);
}
var l = new List<ident>();
l.Add(new ident("System"));
l.Add(new ident("Tuple"));
var tp = new template_param_list(lt);
// значит, это Tuple - создать его, обойти и выйти
var ttr = new SyntaxTree.template_type_reference(new named_type_reference(l), tp);
visit(ttr);
return;
}
//end SSM
// Если мы здесь - значит, это перечислимый тип
//throw new NotSupportedError(get_location(_enum_type_definition));
//ivan added
int num = 0;
@ -3418,7 +3467,8 @@ namespace PascalABCCompiler.TreeConverter
check_if_has_enum_consts(_enum_type_definition);
foreach (SyntaxTree.enumerator en in _enum_type_definition.enumerators.enumerators)
{
SyntaxTree.ident id = en.name;
SyntaxTree.ident id = (en.name as named_type_reference).FirstIdent; // это - точно идентификаторы
constant_definition_node cdn = context.add_const_definition(id.name, get_location(id));
if (en.value == null)
cdn.const_value = new enum_const_node(num++, null, get_location(id));
@ -3434,7 +3484,7 @@ namespace PascalABCCompiler.TreeConverter
num = 0;
foreach (SyntaxTree.enumerator en in _enum_type_definition.enumerators.enumerators)
{
SyntaxTree.ident id = en.name;
SyntaxTree.ident id = (en.name as named_type_reference).FirstIdent;
constant_definition_node cdn = context.add_const_definition(id.name, get_location(id));
if (en.value == null)
cdn.const_value = new enum_const_node(num++, null, get_location(id));
@ -9906,8 +9956,8 @@ namespace PascalABCCompiler.TreeConverter
}
SyntaxTree.array_type arr = tpars.vars_type as SyntaxTree.array_type;
if (tpars.vars_type is SyntaxTree.class_definition || tpars.vars_type is SyntaxTree.enum_type_definition ||
(arr != null && arr.indexers != null && arr.indexers.indexers.Count > 0 && arr.indexers.indexers[0] != null))
if (tpars.vars_type is SyntaxTree.class_definition || /*tpars.vars_type is SyntaxTree.enum_type_definition ||*/
(arr != null && arr.indexers != null && arr.indexers.indexers.Count > 0 && arr.indexers.indexers[0] != null))
{
AddError(get_location(tpars.vars_type), "STRUCT_TYPE_DEFINITION_IN_FORMAL_PARAM");
}
@ -12171,7 +12221,7 @@ namespace PascalABCCompiler.TreeConverter
public void check_parameter_on_complex_type(SyntaxTree.type_definition type)
{
SyntaxTree.array_type arr = type as SyntaxTree.array_type;
if (type is SyntaxTree.class_definition || type is SyntaxTree.enum_type_definition ||
if (type is SyntaxTree.class_definition || /*type is SyntaxTree.enum_type_definition ||*/
(arr != null && arr.indexers != null && arr.indexers.indexers.Count > 0 && arr.indexers.indexers[0] != null))
{
AddError(get_location(type), "STRUCT_TYPE_DEFINITION_IN_FORMAL_PARAM");
@ -18593,7 +18643,11 @@ namespace PascalABCCompiler.TreeConverter
{
if (en.enumerators[i].value != null)
AddError(get_location(en.enumerators[i].name), "ONE_TKIDENTIFIER");
t.Add(new named_type_reference(en.enumerators[i].name, en.enumerators[i].name.source_context));
if (!(en.enumerators[i].name is named_type_reference))
AddError(get_location(en.enumerators[i].name), "ONE_TKIDENTIFIER");
t.Add(en.enumerators[i].name); // ???????????????
}
}
t.Add(_modern_proc_type.res, _modern_proc_type.res.source_context);
@ -18616,9 +18670,14 @@ namespace PascalABCCompiler.TreeConverter
AddError(get_location(en.enumerators[0].name), "ONE_TYPE_PARAMETER_MUSTBE_WITHOUT_PARENTHESES");
for (int i = 0; i < en.enumerators.Count; i++)
{
if (en.enumerators[i].value != null)
AddError(get_location(en.enumerators[i].name), "ONE_TKIDENTIFIER");
t.Add(new named_type_reference(en.enumerators[i].name, en.enumerators[i].name.source_context));
if (!(en.enumerators[i].name is named_type_reference))
AddError(get_location(en.enumerators[i].name), "ONE_TKIDENTIFIER");
t.Add(en.enumerators[i].name);
}
}
t.source_context = _modern_proc_type.source_context;

Binary file not shown.