Formatter fixes.
This commit is contained in:
parent
22151fef3a
commit
7bfd788ef5
|
|
@ -3193,6 +3193,68 @@ namespace CodeFormatters
|
|||
add_space_after = false;
|
||||
}
|
||||
|
||||
public override void visit(const_pattern_parameter _const_parameter)
|
||||
{
|
||||
visit_node(_const_parameter.const_param);
|
||||
add_space_after = false;
|
||||
}
|
||||
|
||||
public override void visit(wild_card_deconstructor_parameter _wild_card_deconstructor_parameter)
|
||||
{
|
||||
add_space_after = false;
|
||||
}
|
||||
|
||||
public override void visit(tuple_pattern_var_parameter _tuple_pattern_var_parameter)
|
||||
{
|
||||
sb.Append("var");
|
||||
SetKeywordOffset("var");
|
||||
read_from_beg_pos = true;
|
||||
visit_node(_tuple_pattern_var_parameter.identifier);
|
||||
}
|
||||
|
||||
public override void visit(tuple_pattern_wild_card _tuple_pattern_wild_card)
|
||||
{
|
||||
add_space_after = false;
|
||||
}
|
||||
|
||||
public override void visit(tuple_pattern _tuple_pattern)
|
||||
{
|
||||
foreach (var parameter in _tuple_pattern.parameters)
|
||||
{
|
||||
visit_node(parameter);
|
||||
add_space_after = true;
|
||||
}
|
||||
add_space_after = false;
|
||||
}
|
||||
|
||||
public override void visit(collection_pattern _collection_pattern)
|
||||
{
|
||||
foreach (var parameter in _collection_pattern.parameters)
|
||||
{
|
||||
visit_node(parameter);
|
||||
add_space_after = true;
|
||||
}
|
||||
add_space_after = false;
|
||||
}
|
||||
|
||||
public override void visit(collection_pattern_gap_parameter _collection_pattern_gap_parameter)
|
||||
{
|
||||
add_space_after = false;
|
||||
}
|
||||
|
||||
public override void visit(collection_pattern_var_parameter _collection_pattern_var_parameter)
|
||||
{
|
||||
sb.Append("var");
|
||||
SetKeywordOffset("var");
|
||||
read_from_beg_pos = true;
|
||||
visit_node(_collection_pattern_var_parameter.identifier);
|
||||
}
|
||||
|
||||
public override void visit(collection_pattern_wild_card _collection_pattern_wild_card)
|
||||
{
|
||||
add_space_after = false;
|
||||
}
|
||||
|
||||
public override void visit(deconstructor_pattern _deconstructor_pattern)
|
||||
{
|
||||
visit_node(_deconstructor_pattern.type);
|
||||
|
|
@ -3206,18 +3268,34 @@ namespace CodeFormatters
|
|||
|
||||
public override void visit(var_deconstructor_parameter _var_deconstructor_parameter)
|
||||
{
|
||||
sb.Append("var");
|
||||
SetKeywordOffset("var");
|
||||
read_from_beg_pos = true;
|
||||
if (_var_deconstructor_parameter.var_keyword_used)
|
||||
{
|
||||
sb.Append("var");
|
||||
SetKeywordOffset("var");
|
||||
read_from_beg_pos = true;
|
||||
}
|
||||
visit_node(_var_deconstructor_parameter.identifier);
|
||||
if (_var_deconstructor_parameter.type != null)
|
||||
visit_node(_var_deconstructor_parameter.type);
|
||||
}
|
||||
|
||||
public override void visit(recursive_pattern_parameter _recursive_pattern_parameter)
|
||||
{
|
||||
visit_node(_recursive_pattern_parameter.pattern);
|
||||
}
|
||||
|
||||
public override void visit(recursive_deconstructor_parameter _recursive_deconstructor_parameter)
|
||||
{
|
||||
visit_node(_recursive_deconstructor_parameter.pattern);
|
||||
}
|
||||
public override void visit(recursive_tuple_parameter _recursive_tuple_parameter)
|
||||
{
|
||||
visit_node(_recursive_tuple_parameter.pattern);
|
||||
}
|
||||
public override void visit(recursive_collection_parameter _recursive_collection_parameter)
|
||||
{
|
||||
visit_node(_recursive_collection_parameter.pattern);
|
||||
}
|
||||
|
||||
public override void visit(var_tuple_def_statement _var_tuple_def_statement)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-IF20NRO
|
||||
// DateTime: 4/25/2019 5:35:11 PM
|
||||
// DateTime: 5/20/2019 1:17:15 PM
|
||||
// UserName: FatCow
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -3497,11 +3497,11 @@ pattern_out_param
|
|||
}
|
||||
| tkVar identifier tkColon type_ref
|
||||
{
|
||||
$$ = new var_deconstructor_parameter($2, $4, @$);
|
||||
$$ = new var_deconstructor_parameter($2, $4, true, @$);
|
||||
}
|
||||
| tkVar identifier
|
||||
{
|
||||
$$ = new var_deconstructor_parameter($2, null, @$);
|
||||
$$ = new var_deconstructor_parameter($2, null, true, @$);
|
||||
}
|
||||
| pattern
|
||||
{
|
||||
|
|
@ -3528,19 +3528,19 @@ pattern_out_param_optional_var
|
|||
}
|
||||
| identifier tkColon type_ref
|
||||
{
|
||||
$$ = new var_deconstructor_parameter($1, $3, @$);
|
||||
$$ = new var_deconstructor_parameter($1, $3, false, @$);
|
||||
}
|
||||
| identifier
|
||||
{
|
||||
$$ = new var_deconstructor_parameter($1, null, @$);
|
||||
$$ = new var_deconstructor_parameter($1, null, false, @$);
|
||||
}
|
||||
| tkVar identifier tkColon type_ref
|
||||
{
|
||||
$$ = new var_deconstructor_parameter($2, $4, @$);
|
||||
$$ = new var_deconstructor_parameter($2, $4, true, @$);
|
||||
}
|
||||
| tkVar identifier
|
||||
{
|
||||
$$ = new var_deconstructor_parameter($2, null, @$);
|
||||
$$ = new var_deconstructor_parameter($2, null, true, @$);
|
||||
}
|
||||
| pattern_optional_var
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// GPPG version 1.3.6
|
||||
// Machine: DESKTOP-IF20NRO
|
||||
// DateTime: 4/25/2019 5:35:12 PM
|
||||
// DateTime: 5/20/2019 1:17:16 PM
|
||||
// UserName: FatCow
|
||||
// Input file <ABCPascal.y>
|
||||
|
||||
|
|
@ -5796,12 +5796,12 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
break;
|
||||
case 647: // pattern_out_param -> tkVar, identifier, tkColon, type_ref
|
||||
{
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan);
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, true, CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 648: // pattern_out_param -> tkVar, identifier
|
||||
{
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, CurrentLocationSpan);
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, true, CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 649: // pattern_out_param -> pattern
|
||||
|
|
@ -5831,22 +5831,22 @@ public partial class GPPGParser: ShiftReduceParser<PascalABCSavParser.Union, Lex
|
|||
break;
|
||||
case 654: // pattern_out_param_optional_var -> identifier, tkColon, type_ref
|
||||
{
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan);
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, false, CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 655: // pattern_out_param_optional_var -> identifier
|
||||
{
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, CurrentLocationSpan);
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, false, CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 656: // pattern_out_param_optional_var -> tkVar, identifier, tkColon, type_ref
|
||||
{
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, CurrentLocationSpan);
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].td, true, CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 657: // pattern_out_param_optional_var -> tkVar, identifier
|
||||
{
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, CurrentLocationSpan);
|
||||
CurrentSemanticValue.stn = new var_deconstructor_parameter(ValueStack[ValueStack.Depth-1].id, null, true, CurrentLocationSpan);
|
||||
}
|
||||
break;
|
||||
case 658: // pattern_out_param_optional_var -> pattern_optional_var
|
||||
|
|
|
|||
|
|
@ -4130,6 +4130,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
read_pattern_parameter(_var_deconstructor_parameter);
|
||||
_var_deconstructor_parameter.identifier = _read_node() as ident;
|
||||
_var_deconstructor_parameter.type = _read_node() as type_definition;
|
||||
_var_deconstructor_parameter.var_keyword_used = br.ReadBoolean();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6481,6 +6481,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
bw.Write((byte)1);
|
||||
_var_deconstructor_parameter.type.visit(this);
|
||||
}
|
||||
bw.Write(_var_deconstructor_parameter.var_keyword_used);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50181,25 +50181,28 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public var_deconstructor_parameter(ident _identifier,type_definition _type)
|
||||
public var_deconstructor_parameter(ident _identifier,type_definition _type,bool _var_keyword_used)
|
||||
{
|
||||
this._identifier=_identifier;
|
||||
this._type=_type;
|
||||
this._var_keyword_used=_var_keyword_used;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Конструктор с параметрами.
|
||||
///</summary>
|
||||
public var_deconstructor_parameter(ident _identifier,type_definition _type,SourceContext sc)
|
||||
public var_deconstructor_parameter(ident _identifier,type_definition _type,bool _var_keyword_used,SourceContext sc)
|
||||
{
|
||||
this._identifier=_identifier;
|
||||
this._type=_type;
|
||||
this._var_keyword_used=_var_keyword_used;
|
||||
source_context = sc;
|
||||
FillParentsInDirectChilds();
|
||||
}
|
||||
protected ident _identifier;
|
||||
protected type_definition _type;
|
||||
protected bool _var_keyword_used;
|
||||
|
||||
///<summary>
|
||||
///
|
||||
|
|
@ -50235,6 +50238,21 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
public bool var_keyword_used
|
||||
{
|
||||
get
|
||||
{
|
||||
return _var_keyword_used;
|
||||
}
|
||||
set
|
||||
{
|
||||
_var_keyword_used=value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Создает копию узла </summary>
|
||||
public override syntax_tree_node Clone()
|
||||
|
|
@ -50253,6 +50271,7 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
copy.type = (type_definition)type.Clone();
|
||||
copy.type.Parent = copy;
|
||||
}
|
||||
copy.var_keyword_used = var_keyword_used;
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2999,6 +2999,7 @@
|
|||
<Fields>
|
||||
<SyntaxField Name="identifier" SyntaxType="ident" />
|
||||
<SyntaxField Name="type" SyntaxType="type_definition" />
|
||||
<ExtendedField Name="var_keyword_used" Type="bool" CreateVariable="false" DeleteVariable="false" />
|
||||
</Fields>
|
||||
<Methods />
|
||||
<Tags>
|
||||
|
|
@ -4652,6 +4653,7 @@
|
|||
<HelpData Key="var_deconstructor_parameter" Value="Параметр-объявление переменной (возможно без типа)" />
|
||||
<HelpData Key="var_deconstructor_parameter.identifier" Value="" />
|
||||
<HelpData Key="var_deconstructor_parameter.type" Value="" />
|
||||
<HelpData Key="var_deconstructor_parameter.var_keyword_used" Value="" />
|
||||
<HelpData Key="var_def_list" Value="" />
|
||||
<HelpData Key="var_def_list.var_def_list Add(var_def_statement _var_def_statement)" Value="" />
|
||||
<HelpData Key="var_def_list.var_def_list Add(var_def_statement _var_def_statement, SourceContext sc)" Value="" />
|
||||
|
|
|
|||
|
|
@ -249,6 +249,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
pattern.parameters[i] = new var_deconstructor_parameter(
|
||||
constParamIdent,
|
||||
GetTypeDefinitionForConstParam(constPattern.const_param),
|
||||
false,
|
||||
pattern.parameters[i].source_context);
|
||||
|
||||
paramCheckExpr = paramCheckExpr == null ? (expression)constParamCheck : bin_expr.LogicalAnd(paramCheckExpr, constParamCheck);
|
||||
|
|
@ -260,6 +261,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
pattern.parameters[i] = new var_deconstructor_parameter(
|
||||
wildCardGeneratedParamIdent,
|
||||
null,
|
||||
false,
|
||||
pattern.parameters[i].source_context);
|
||||
}
|
||||
|
||||
|
|
@ -651,7 +653,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
pattern_parameter varParameter = null;
|
||||
if (pattern is deconstructor_pattern)
|
||||
{
|
||||
varParameter = new var_deconstructor_parameter(newName, null);
|
||||
varParameter = new var_deconstructor_parameter(newName, null, false);
|
||||
}
|
||||
else if (pattern is collection_pattern)
|
||||
{
|
||||
|
|
@ -671,6 +673,7 @@ namespace SyntaxVisitors.SugarVisitors
|
|||
|
||||
private void DesugarIsExpressionInAssignment(is_pattern_expr isExpression)
|
||||
{
|
||||
// Кинуть тут эксепшн
|
||||
Debug.Assert(isExpression.right is deconstructor_pattern, "Only deconstructor patterns can be used in assignment");
|
||||
var statementsToAdd = ProcessDesugaringForDeconstructorPattern(isExpression);
|
||||
AddDefinitionsInUpperStatementList(isExpression, statementsToAdd);
|
||||
|
|
|
|||
Loading…
Reference in a new issue