Рефакторинг
This commit is contained in:
parent
48765f1ada
commit
6aee6c9add
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "2";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "1377";
|
||||
public const string Revision = "1379";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=0
|
||||
%REVISION%=1377
|
||||
%REVISION%=1379
|
||||
%MINOR%=2
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-8EAQPI9
|
||||
// DateTime: 09.01.2017 15:07:29
|
||||
// DateTime: 21.01.2017 21:29:18
|
||||
// UserName: ?????????
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -2945,6 +2945,7 @@ default_expr
|
|||
tuple
|
||||
: tkRoundOpen expr_l1 tkComma expr_l1_list lambda_type_ref optional_full_lambda_fp_list tkRoundClose // lambda_type_ref optional_full_lambda_fp_list íóæíî îñòàâèòü ÷òîáû íå áûëî êîíôëèêòîâ ñ ãðàììàòèêîé ëÿìáä
|
||||
{
|
||||
/*
|
||||
($4 as expression_list).expressions.Insert(0,$2);
|
||||
if (($4 as expression_list).expressions.Count>7)
|
||||
parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",@5);
|
||||
|
|
@ -2955,7 +2956,15 @@ tuple
|
|||
{
|
||||
var dn = new dot_node(new dot_node(new ident("?System"),new ident("Tuple")),new ident("Create",@$));
|
||||
$$ = new method_call(dn,$4 as expression_list,@$);
|
||||
}
|
||||
}*/
|
||||
|
||||
/*if ($5 != null)
|
||||
parsertools.AddErrorFromResource("BAD_TUPLE",@5);
|
||||
if ($6 != null)
|
||||
parsertools.AddErrorFromResource("BAD_TUPLE",@6);*/
|
||||
|
||||
($4 as expression_list).expressions.Insert(0,$2);
|
||||
$$ = new tuple_node_for_formatter($4 as expression_list,@$);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// GPPG version 1.3.6
|
||||
// Machine: DESKTOP-8EAQPI9
|
||||
// DateTime: 09.01.2017 15:07:30
|
||||
// DateTime: 21.01.2017 21:29:18
|
||||
// UserName: ?????????
|
||||
// Input file <J:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.y>
|
||||
|
||||
|
|
@ -4902,17 +4902,26 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
case 595: // tuple -> tkRoundOpen, expr_l1, tkComma, expr_l1_list, lambda_type_ref,
|
||||
// optional_full_lambda_fp_list, tkRoundClose
|
||||
{
|
||||
(ValueStack[ValueStack.Depth-4].stn as expression_list).expressions.Insert(0,ValueStack[ValueStack.Depth-6].ex);
|
||||
if ((ValueStack[ValueStack.Depth-4].stn as expression_list).expressions.Count>7)
|
||||
parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",LocationStack[LocationStack.Depth-3]);
|
||||
/*
|
||||
($4 as expression_list).expressions.Insert(0,$2);
|
||||
if (($4 as expression_list).expressions.Count>7)
|
||||
parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",@5);
|
||||
|
||||
if (parsertools.build_tree_for_formatter)
|
||||
CurrentSemanticValue.ex = new tuple_node_for_formatter(ValueStack[ValueStack.Depth-4].stn as expression_list,CurrentLocationSpan);
|
||||
$$ = new tuple_node_for_formatter($4 as expression_list,@$);
|
||||
else
|
||||
{
|
||||
var dn = new dot_node(new dot_node(new ident("?System"),new ident("Tuple")),new ident("Create",CurrentLocationSpan));
|
||||
CurrentSemanticValue.ex = new method_call(dn,ValueStack[ValueStack.Depth-4].stn as expression_list,CurrentLocationSpan);
|
||||
}
|
||||
var dn = new dot_node(new dot_node(new ident("?System"),new ident("Tuple")),new ident("Create",@$));
|
||||
$$ = new method_call(dn,$4 as expression_list,@$);
|
||||
}*/
|
||||
|
||||
/*if ($5 != null)
|
||||
parsertools.AddErrorFromResource("BAD_TUPLE",@5);
|
||||
if ($6 != null)
|
||||
parsertools.AddErrorFromResource("BAD_TUPLE",@6);*/
|
||||
|
||||
(ValueStack[ValueStack.Depth-4].stn as expression_list).expressions.Insert(0,ValueStack[ValueStack.Depth-6].ex);
|
||||
CurrentSemanticValue.ex = new tuple_node_for_formatter(ValueStack[ValueStack.Depth-4].stn as expression_list,CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 596: // factor -> tkNil
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@ script=
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -358,10 +358,10 @@
|
|||
<Items>
|
||||
<Node ID="visit" Name="visit(SyntaxTree.assign_var_tuple" NL="0,9414063" NG="-1">
|
||||
<FileName>\TreeConverter\TreeConversion\syntax_tree_visitor.cs</FileName>
|
||||
<Text>public override void visit(SyntaxTree.assign_var_tuple assvartup)</Text>
|
||||
<Text>public override void visit(SyntaxTree.assign_var_tuple assvartup) // сахарный узел</Text>
|
||||
<OCtx>
|
||||
<i Type="Method">public override void visit ( SyntaxTree . assign_var_tuple assvartup )</i>
|
||||
<i Type="ClassOrNamespace">public class syntax_tree_visitor : SyntaxTree . WalkingVisitorNew</i>
|
||||
<i Type="ClassOrNamespace">public partial class syntax_tree_visitor : SyntaxTree . WalkingVisitorNew</i>
|
||||
<i Type="ClassOrNamespace">namespace PascalABCCompiler . TreeConverter</i>
|
||||
<i Type="CS_TreeNode">
|
||||
</i>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.2.0.1377'
|
||||
!define VERSION '3.2.0.1379'
|
||||
|
|
|
|||
|
|
@ -20,9 +20,15 @@ namespace PascalABCCompiler.SyntaxTreeConverters
|
|||
// Выносим выражения с лямбдами из заголовка foreach
|
||||
StandOutExprWithLambdaInForeachSequenceVisitor.New.ProcessNode(root);
|
||||
|
||||
//--- Обработка синтаксически сахарных узлов
|
||||
|
||||
// tuple_node
|
||||
TupleVisitor.New.ProcessNode(root);
|
||||
|
||||
// assign_tuple и assign_var_tuple
|
||||
AssignTuplesDesugarVisitor.New.ProcessNode(root);
|
||||
|
||||
// Пока не доделали
|
||||
// slice_expr и slice_expr_question
|
||||
SliceQuestionDesugarVisitor.New.ProcessNode(root);
|
||||
|
||||
// Всё, связанное с yield
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
<Compile Include="ChangeWhileVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\AssignTuplesDesugarVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\SliceQuestionDesugarVisitor.cs" />
|
||||
<Compile Include="SugarVisitors\TupleVisitor.cs" />
|
||||
<Compile Include="YieldVisitors\ObjectCopier\ObjectCopier.cs" />
|
||||
<Compile Include="Optimization\CalcConstExprs.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
|||
|
|
@ -34,18 +34,24 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (semvar is typed_expression)
|
||||
semvar = convert_typed_expression_to_function_call(semvar as typed_expression);
|
||||
|
||||
var t = ConvertSemanticTypeNodeToNETType(semvar.type);
|
||||
|
||||
var IsSlicedType = 0; // проверим, является ли semvar.type динамическим массивом, списком List или строкой
|
||||
// semvar.type должен быть array of T, List<T> или string
|
||||
if (t == null)
|
||||
IsSlicedType = 0; // можно ничего не присваивать :)
|
||||
else if (t.IsArray)
|
||||
if (semvar.type.type_special_kind == SemanticTree.type_special_kind.array_kind)
|
||||
IsSlicedType = 1;
|
||||
else if (t == typeof(System.String))
|
||||
IsSlicedType = 2;
|
||||
else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(System.Collections.Generic.List<>))
|
||||
IsSlicedType = 3;
|
||||
|
||||
if (IsSlicedType == 0)
|
||||
{
|
||||
var t = ConvertSemanticTypeNodeToNETType(semvar.type); // не работает для array of T
|
||||
|
||||
// semvar.type должен быть array of T, List<T> или string
|
||||
if (t == null)
|
||||
IsSlicedType = 0; // можно ничего не присваивать :)
|
||||
// else if (t.IsArray)
|
||||
// IsSlicedType = 1;
|
||||
else if (t == typeof(System.String))
|
||||
IsSlicedType = 2;
|
||||
else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(System.Collections.Generic.List<>))
|
||||
IsSlicedType = 3;
|
||||
}
|
||||
|
||||
if (IsSlicedType == 0)
|
||||
AddError(get_location(sl.v), "BAD_SLICE_OBJECT");
|
||||
|
|
@ -67,6 +73,12 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (!b)
|
||||
AddError(get_location(sl.step), "INTEGER_VALUE_EXPECTED");
|
||||
}
|
||||
|
||||
}
|
||||
void semantic_check_tuple(SyntaxTree.tuple_node_for_formatter tup)
|
||||
{
|
||||
if (tup.el.expressions.Count > 7)
|
||||
AddError(get_location(tup),"TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19022,19 +19022,10 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public override void visit(matching_expression _matching_expression)
|
||||
{
|
||||
SyntaxTree.procedure_call pc = new SyntaxTree.procedure_call();
|
||||
SyntaxTree.method_call mc = new SyntaxTree.method_call();
|
||||
dot_node dot = new dot_node(new ident("PABCSystem"), new ident("KV"));
|
||||
mc.dereferencing_value = dot;
|
||||
pc.func_name = mc;
|
||||
pc.source_context = _matching_expression.source_context;
|
||||
SyntaxTree.expression_list exl = new PascalABCCompiler.SyntaxTree.expression_list();
|
||||
exl.Add(_matching_expression.left);
|
||||
exl.Add(_matching_expression.right);
|
||||
mc.parameters = exl;
|
||||
visit(pc);
|
||||
throw new NotSupportedError(get_location(_matching_expression));
|
||||
}
|
||||
public override void visit(SyntaxTree.sequence_type _sequence_type)
|
||||
|
||||
public override void visit(SyntaxTree.sequence_type _sequence_type) // сахарный узел
|
||||
{
|
||||
// SSM 11/05/15 sugared node
|
||||
var l = new List<ident>();
|
||||
|
|
@ -19047,7 +19038,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
_sequence_type.source_context);
|
||||
visit(tr);
|
||||
}
|
||||
public override void visit(SyntaxTree.modern_proc_type _modern_proc_type)
|
||||
|
||||
public override void visit(SyntaxTree.modern_proc_type _modern_proc_type) // сахарный узел
|
||||
{
|
||||
if (_modern_proc_type.res != null)
|
||||
{
|
||||
|
|
@ -19142,62 +19134,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
return null;
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.assign_tuple asstup)
|
||||
{
|
||||
AddError(get_location(asstup), "SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR", asstup.GetType().Name);
|
||||
|
||||
/*semantic_check_assign_tuple(asstup);
|
||||
|
||||
var tname = "#temp_var" + UniqueNumStr();
|
||||
|
||||
//var tt = new var_statement(new ident(tname), new semantic_addr_value(expr)); // тут semantic_addr_value хранит на самом деле expr - просто неудачное название
|
||||
var tt = new var_statement(new ident(tname), asstup.expr); // тут semantic_addr_value хранит на самом деле expr - просто неудачное название
|
||||
var st = new statement_list(tt);
|
||||
|
||||
var n = asstup.vars.variables.Count();
|
||||
for (var i = 0; i < n; i++)
|
||||
{
|
||||
var a = new assign(asstup.vars.variables[i], new dot_node(new ident(tname),
|
||||
new ident("Item" + (i + 1).ToString())), Operators.Assignment,
|
||||
asstup.vars.variables[i].source_context);
|
||||
st.Add(a);
|
||||
}
|
||||
visit(st);
|
||||
// Замена 1 оператор на 1 оператор - всё OK
|
||||
ReplaceUsingParent(asstup, st);*/
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.assign_var_tuple assvartup)
|
||||
{
|
||||
AddError(get_location(assvartup), "SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR", assvartup.GetType().Name);
|
||||
|
||||
/*check_sugared(assvartup);
|
||||
|
||||
var tname = "#temp_var" + UniqueNumStr();
|
||||
|
||||
var tt = new var_statement(new ident(tname), assvartup.expr); // тут для assvartup.expr внутри повторно вызывается convert_strong, это плохо, но если там лямбда, то иначе - с semantic_addr_value - не работает!!!
|
||||
//var tt = new var_statement(new ident(tname), new semantic_addr_value(expr)); // тут semantic_addr_value хранит на самом деле expr - просто неудачное название
|
||||
visit(tt); // обходится первый элемент - вместо asstup
|
||||
|
||||
var sl = new List<statement>();
|
||||
sl.Add(tt); // он же помещается в новое синтаксическое дерево
|
||||
|
||||
var n = assvartup.vars.variables.Count();
|
||||
for (var i = 0; i < n; i++)
|
||||
{
|
||||
var rr = assvartup.vars.variables[i] as ident;
|
||||
var a = new var_statement(rr,
|
||||
new dot_node(new ident(tname),new ident("Item" + (i + 1).ToString())),
|
||||
assvartup.vars.variables[i].source_context
|
||||
);
|
||||
// Остальные элементы обходить не надо (!!!уже надо!) - они обходятся на следующих итерациях при обходе внешнего statement_list
|
||||
//visit(a);
|
||||
sl.Add(a);
|
||||
}
|
||||
ReplaceStatementUsingParent(assvartup, sl);*/
|
||||
}
|
||||
|
||||
expression_list construct_expression_list_for_slice_expr(SyntaxTree.slice_expr sl)
|
||||
/*expression_list construct_expression_list_for_slice_expr(SyntaxTree.slice_expr sl)
|
||||
{
|
||||
// situation = 0 - ничего не пропущено
|
||||
// situation = 1 - пропущен from
|
||||
|
|
@ -19223,37 +19160,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
el.Add(sl.step);
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.slice_expr sl)
|
||||
{
|
||||
AddError(get_location(sl), "SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR", sl.GetType().Name);
|
||||
|
||||
/*
|
||||
// Преобразуется в вызов a.SystemSlice(situation,from,to,step)
|
||||
// Тип a должен быть array of T, List<T> или string
|
||||
semcheck(sl);
|
||||
|
||||
// Действия уровня синтаксиса. Можно вынести на синтаксический уровень как desugaring для сахарного узла
|
||||
var el = construct_expression_list_for_slice_expr(sl);
|
||||
var mc = new method_call(new dot_node(sl.v, new ident("SystemSlice", sl.v.source_context), sl.v.source_context), el, sl.source_context);
|
||||
|
||||
visit(mc);*/
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.slice_expr_question sl)
|
||||
{
|
||||
AddError(get_location(sl), "SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR", sl.GetType().Name);
|
||||
/*
|
||||
// Преобразуется в вызов a.SystemSlice(situation,from,to,step)
|
||||
// Тип a должен быть array of T, List<T> или string
|
||||
semcheck(sl);
|
||||
|
||||
var el = construct_expression_list_for_slice_expr(sl);
|
||||
var mc = new method_call(new dot_node(sl.v, new ident("SystemSliceQuestion", sl.v.source_context), sl.v.source_context), el, sl.source_context);
|
||||
|
||||
visit(mc);*/
|
||||
}
|
||||
}*/
|
||||
|
||||
// frninja 04/03/16 - для yield
|
||||
|
||||
|
|
@ -19420,6 +19327,23 @@ namespace PascalABCCompiler.TreeConverter
|
|||
visit(pc);
|
||||
}
|
||||
|
||||
/*public SyntaxTree.question_colon_expression ConvertToQCE(dot_question_node dqn)
|
||||
{
|
||||
// Неверно работает. Пока не используется. Доделать
|
||||
addressed_value left = dqn.left;
|
||||
addressed_value right = dqn.right;
|
||||
var eq = new bin_expr(left, new nil_const(), Operators.Equal, left.source_context);
|
||||
var dn = new dot_node(left, right, dqn.source_context);
|
||||
var q = new SyntaxTree.question_colon_expression(eq, new nil_const(), dn, dqn.source_context);
|
||||
return q;
|
||||
}
|
||||
public override void visit(SyntaxTree.dot_question_node dqn)
|
||||
{
|
||||
// a?.b
|
||||
var q = ConvertToQCE(dqn);
|
||||
visit(q);
|
||||
}*/
|
||||
|
||||
public override void visit(SyntaxTree.semantic_check_sugared_statement_node st)
|
||||
{
|
||||
if (st.stat is SyntaxTree.assign_tuple)
|
||||
|
|
@ -19428,20 +19352,20 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
else
|
||||
{
|
||||
AddError(get_location(st), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}");
|
||||
AddError(get_location(st), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}", st.GetType().Name);
|
||||
}
|
||||
ret.reset(); // обязательно очистить - этот узел в семантику ничего не должен приносить!
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.sugared_expression ex)
|
||||
{
|
||||
/*if (ex.sugared_expr is SyntaxTree.slice_expr) // и slice_expr_question
|
||||
if (ex.sugared_expr is SyntaxTree.tuple_node_for_formatter)
|
||||
{
|
||||
//semantic_check_slice_expr(ex.sugared_expr as SyntaxTree.slice_expr);
|
||||
semantic_check_tuple(ex.sugared_expr as SyntaxTree.tuple_node_for_formatter);
|
||||
}
|
||||
else*/
|
||||
else
|
||||
{
|
||||
AddError(get_location(ex), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}");
|
||||
AddError(get_location(ex), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}", ex.GetType().Name);
|
||||
}
|
||||
|
||||
ProcessNode(ex.new_expr); // обойти десахарное выражение - обязательно ProcessNode - visit нельзя!
|
||||
|
|
@ -19455,27 +19379,95 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
else
|
||||
{
|
||||
AddError(get_location(av), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}");
|
||||
AddError(get_location(av), "MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}", av.GetType().Name);
|
||||
}
|
||||
|
||||
ProcessNode(av.new_addr_value); // обойти десахарное
|
||||
}
|
||||
|
||||
/*public SyntaxTree.question_colon_expression ConvertToQCE(dot_question_node dqn)
|
||||
{
|
||||
// Неверно работает. Пока не используется. Доделать
|
||||
addressed_value left = dqn.left;
|
||||
addressed_value right = dqn.right;
|
||||
var eq = new bin_expr(left, new nil_const(), Operators.Equal, left.source_context);
|
||||
var dn = new dot_node(left, right, dqn.source_context);
|
||||
var q = new SyntaxTree.question_colon_expression(eq, new nil_const(), dn, dqn.source_context);
|
||||
return q;
|
||||
}
|
||||
public override void visit(SyntaxTree.dot_question_node dqn)
|
||||
{
|
||||
// a?.b
|
||||
var q = ConvertToQCE(dqn);
|
||||
visit(q);
|
||||
}*/
|
||||
public override void visit(SyntaxTree.assign_tuple asstup) // сахарный узел
|
||||
{
|
||||
AddError(get_location(asstup), "SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR", asstup.GetType().Name);
|
||||
|
||||
/*semantic_check_assign_tuple(asstup);
|
||||
|
||||
var tname = "#temp_var" + UniqueNumStr();
|
||||
|
||||
//var tt = new var_statement(new ident(tname), new semantic_addr_value(expr)); // тут semantic_addr_value хранит на самом деле expr - просто неудачное название
|
||||
var tt = new var_statement(new ident(tname), asstup.expr); // тут semantic_addr_value хранит на самом деле expr - просто неудачное название
|
||||
var st = new statement_list(tt);
|
||||
|
||||
var n = asstup.vars.variables.Count();
|
||||
for (var i = 0; i < n; i++)
|
||||
{
|
||||
var a = new assign(asstup.vars.variables[i], new dot_node(new ident(tname),
|
||||
new ident("Item" + (i + 1).ToString())), Operators.Assignment,
|
||||
asstup.vars.variables[i].source_context);
|
||||
st.Add(a);
|
||||
}
|
||||
visit(st);
|
||||
// Замена 1 оператор на 1 оператор - всё OK
|
||||
ReplaceUsingParent(asstup, st);*/
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.assign_var_tuple assvartup) // сахарный узел
|
||||
{
|
||||
AddError(get_location(assvartup), "SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR", assvartup.GetType().Name);
|
||||
|
||||
/*check_sugared(assvartup);
|
||||
|
||||
var tname = "#temp_var" + UniqueNumStr();
|
||||
|
||||
var tt = new var_statement(new ident(tname), assvartup.expr); // тут для assvartup.expr внутри повторно вызывается convert_strong, это плохо, но если там лямбда, то иначе - с semantic_addr_value - не работает!!!
|
||||
//var tt = new var_statement(new ident(tname), new semantic_addr_value(expr)); // тут semantic_addr_value хранит на самом деле expr - просто неудачное название
|
||||
visit(tt); // обходится первый элемент - вместо asstup
|
||||
|
||||
var sl = new List<statement>();
|
||||
sl.Add(tt); // он же помещается в новое синтаксическое дерево
|
||||
|
||||
var n = assvartup.vars.variables.Count();
|
||||
for (var i = 0; i < n; i++)
|
||||
{
|
||||
var rr = assvartup.vars.variables[i] as ident;
|
||||
var a = new var_statement(rr,
|
||||
new dot_node(new ident(tname),new ident("Item" + (i + 1).ToString())),
|
||||
assvartup.vars.variables[i].source_context
|
||||
);
|
||||
// Остальные элементы обходить не надо (!!!уже надо!) - они обходятся на следующих итерациях при обходе внешнего statement_list
|
||||
//visit(a);
|
||||
sl.Add(a);
|
||||
}
|
||||
ReplaceStatementUsingParent(assvartup, sl);*/
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.slice_expr sl) // сахарный узел
|
||||
{
|
||||
AddError(get_location(sl), "SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR", sl.GetType().Name);
|
||||
|
||||
/*
|
||||
// Преобразуется в вызов a.SystemSlice(situation,from,to,step)
|
||||
// Тип a должен быть array of T, List<T> или string
|
||||
semcheck(sl);
|
||||
|
||||
// Действия уровня синтаксиса. Можно вынести на синтаксический уровень как desugaring для сахарного узла
|
||||
var el = construct_expression_list_for_slice_expr(sl);
|
||||
var mc = new method_call(new dot_node(sl.v, new ident("SystemSlice", sl.v.source_context), sl.v.source_context), el, sl.source_context);
|
||||
|
||||
visit(mc);*/
|
||||
}
|
||||
|
||||
public override void visit(SyntaxTree.slice_expr_question sl) // сахарный узел
|
||||
{
|
||||
AddError(get_location(sl), "SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR", sl.GetType().Name);
|
||||
/*
|
||||
// Преобразуется в вызов a.SystemSlice(situation,from,to,step)
|
||||
// Тип a должен быть array of T, List<T> или string
|
||||
semcheck(sl);
|
||||
|
||||
var el = construct_expression_list_for_slice_expr(sl);
|
||||
var mc = new method_call(new dot_node(sl.v, new ident("SystemSliceQuestion", sl.v.source_context), sl.v.source_context), el, sl.source_context);
|
||||
|
||||
visit(mc);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,6 @@
|
|||
<Compile Include="TreeConversion\syntax_tree_visitor.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TreeConversion\syntax_tree_visitor_semcheck_helper.cs" />
|
||||
<Compile Include="TreeConversion\type_constructor.cs" />
|
||||
<Compile Include="TreeRealization\attributes.cs" />
|
||||
<Compile Include="TreeRealization\events.cs" />
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -49,7 +49,6 @@ ONE_TKIDENTIFIER=Expected identefier
|
|||
ONE_OPERATOR=Expected operator
|
||||
ONE_STMT=Expected statement
|
||||
BAD_TUPLE=Badly formed Tuple
|
||||
TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7=Count of Tuple elements must be <=7
|
||||
EMPTY_STATEMENT_IN_SHORT_PROC_DEFINITION=Statement expected
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ ONLY_IN_SHORT_FUNC_DEFS_RETURN_TYPE_CANBE_OMITTED=Only in short function definit
|
|||
ONE_TKIDENTIFIER=Type here must be identifier
|
||||
SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR=Sugared node {0} must not be visited in syntax_tree_visitor
|
||||
MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}=Missed semantic check for sugared node {0}
|
||||
TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7=Count of Tuple elements must be <=7
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ ONE_TKIDENTIFIER=Ожидался идентификатор
|
|||
ONE_OPERATOR=Ожидался оператор
|
||||
ONE_STMT=Ожидался оператор
|
||||
BAD_TUPLE=Неправильно сформированный кортеж
|
||||
TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7=Количество элементов кортежа не должно быть больше 7
|
||||
EMPTY_STATEMENT_IN_SHORT_PROC_DEFINITION=Ожидался оператор
|
||||
|
||||
DUPLICATE_NAMES_IN_ANON_TYPE=Анонимный тип не может содержать поля с одинаковыми именами
|
||||
|
|
|
|||
|
|
@ -10,3 +10,4 @@ ONLY_IN_SHORT_FUNC_DEFS_RETURN_TYPE_CANBE_OMITTED=Только в коротки
|
|||
ONE_TKIDENTIFIER=В качестве типа ожидался идентификатор
|
||||
SUGARED_NODE_{0}_IN_SYNTAX_TREE_VISITOR=Сахарный узел {0} не должен обходиться в syntax_tree_visitor. Обратитесь к разработчикам PascalABC.NET
|
||||
MISSED_SEMANTIC_CHECK_FOR_SUGARED_NODE_{0}=Отсутствует семантическая проверка для сахарного узла {0}
|
||||
TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7=Количество элементов кортежа не должно быть больше 7
|
||||
|
|
|
|||
Loading…
Reference in a new issue