a is [collection], a is (tuple) теперь нелегальны. Починил вложенный матчинг

This commit is contained in:
Александр Погорелов 2020-07-03 06:45:23 +03:00
parent 129cefd7e7
commit e8e70ff33d
4 changed files with 2184 additions and 2192 deletions

View file

@ -1,9 +1,9 @@
//
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-G8V08V4
// DateTime: 21.06.2020 18:37:06
// UserName: ?????????
// Machine: DESKTOP-P4NLNB1
// DateTime: 6/25/2020 11:59:19 AM
// UserName: fatco
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>
//

View file

@ -3365,7 +3365,7 @@ relop_expr
var deconstructorPattern = new deconstructor_pattern($3 as List<pattern_parameter>, isTypeCheck.type_def, null, @$);
$$ = new is_pattern_expr(isTypeCheck.expr, deconstructorPattern, @$);
}
/*
| term tkIs collection_pattern
{
$$ = new is_pattern_expr($1, $3 as pattern_node, @$);
@ -3374,6 +3374,7 @@ relop_expr
{
$$ = new is_pattern_expr($1, $3 as pattern_node, @$);
}
*/
;
pattern

File diff suppressed because it is too large Load diff

View file

@ -100,6 +100,7 @@ namespace SyntaxVisitors.SugarVisitors
private int successVariableCounter = 0;
private int labelVariableCounter = 0;
private int deconstructParamVariableCounter = 0;
private int matchExprVariableCounter = 0;
private if_node _previousIf;
private statement desugaredMatchWith;
@ -116,11 +117,12 @@ namespace SyntaxVisitors.SugarVisitors
desugaredMatchWith = null;
_previousIf = null;
var matchExprVariableName = NewMatchExprVariableId();
matchedExprVarDeclaration = new var_statement(
new ident(GeneratedMatchExprVariableName, matchWith.expr.source_context),
new ident(matchExprVariableName, matchWith.expr.source_context),
matchWith.expr.Clone() as expression,
matchWith.expr.source_context);
ReplaceUsingParent(matchWith.expr, new ident(GeneratedMatchExprVariableName, matchWith.expr.source_context));
ReplaceUsingParent(matchWith.expr, new ident(matchExprVariableName, matchWith.expr.source_context));
/*if (matchWith.Parent is statement_list stl)
{
@ -1059,6 +1061,11 @@ namespace SyntaxVisitors.SugarVisitors
{
return GeneratedPatternNamePrefix + "DeconstructParam" + deconstructParamVariableCounter++.ToString();
}
private string NewMatchExprVariableId()
{
return GeneratedMatchExprVariableName + "matchExprVariableCounter" + deconstructParamVariableCounter++.ToString();
}
}
}