misc: 清除冗余的代码

Reviewed-on: PostGuard/Canon#75
Co-authored-by: Lan_G <2911328695@qq.com>
Co-committed-by: Lan_G <2911328695@qq.com>
This commit is contained in:
Lan_G
2024-05-06 00:12:57 +08:00
committed by jackfiled
parent 6e8e3885ac
commit 160fafef70
30 changed files with 11 additions and 896 deletions

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;
using Canon.Core.SemanticParser;
@@ -10,7 +9,6 @@ public class BasicType : NonTerminatedSyntaxNode
{
public override NonTerminatorType Type => NonTerminatorType.BasicType;
public bool IsProcedure;
/// <summary>
/// BasicType代表的Pascal类型
/// </summary>

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;
using Canon.Core.SemanticParser;

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;

View File

@@ -1,8 +1,5 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;
using Canon.Core.SemanticParser;
namespace Canon.Core.SyntaxNodes;
@@ -36,21 +33,6 @@ public class Expression : NonTerminatedSyntaxNode
RaiseEvent();
}
public bool IsParam; //是否为传参
public bool ReferenceParam; //是否为引用传参
public bool LastParam; //是否为传参列表里最后一个参数
/// <summary>
/// 是否为数组下标
/// </summary>
public bool IsIndex { get; set; }
/// <summary>
/// 当前表达式对应的数组下标维度的左边界
/// </summary>
public int LeftBound;
/// <summary>
/// 是否为FOR语句中的起始语句
/// </summary>
@@ -60,32 +42,12 @@ public class Expression : NonTerminatedSyntaxNode
/// 是否为FOR语句中的结束语句
/// </summary>
public bool IsForConditionEnd { get; set; }
public bool IsAssign { get; set; }
/// <summary>
/// 是否为IF语句中的条件语句
/// </summary>
public bool IsIfCondition { get; set; }
private IdentifierSemanticToken? _iterator;
public IdentifierSemanticToken Iterator
{
get
{
if (_iterator is null)
{
throw new InvalidOperationException();
}
return _iterator;
}
set
{
_iterator = value;
}
}
/// <summary>
/// 直接赋值产生式的事件
/// </summary>
@@ -96,25 +58,6 @@ public class Expression : NonTerminatedSyntaxNode
/// </summary>
public event EventHandler<RelationGeneratorEventArgs>? OnRelationGenerator;
private PascalType? _expressionType;
public PascalType ExpressionType
{
get
{
if (_expressionType is null)
{
throw new InvalidOperationException();
}
return _expressionType;
}
set
{
_expressionType = value;
}
}
public static Expression Create(List<SyntaxNodeBase> children)
{
return new Expression { Children = children };

View File

@@ -1,6 +1,5 @@
using Canon.Core.Abstractions;
using Canon.Core.Enums;
using Canon.Core.SemanticParser;
namespace Canon.Core.SyntaxNodes;
@@ -18,23 +17,6 @@ public class ExpressionList : NonTerminatedSyntaxNode
/// </summary>
public List<Expression> Expressions { get; } = [];
/// <summary>
/// 是否为传参列表
/// </summary>
public bool IsParamList;
public List<PascalParameterType> ParameterTypes { get; } = [];
/// <summary>
/// 是否为数组下标索引
/// </summary>
public bool IsIndex { get; set; }
/// <summary>
/// 数组左边界列表
/// </summary>
public List<int> LeftBounds = new();
/// <summary>
/// 当前ExpressionList中的Expression定义
/// </summary>

View File

@@ -1,7 +1,6 @@
using Canon.Core.Abstractions;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;
using Canon.Core.SemanticParser;
namespace Canon.Core.SyntaxNodes;
@@ -103,22 +102,6 @@ public class Factor : NonTerminatedSyntaxNode
/// </summary>
public event EventHandler<ProcedureCallGeneratorEventArgs>? OnProcedureCallGenerator;
private PascalType? _factorType;
public PascalType FactorType
{
get
{
if (_factorType is null)
{
throw new InvalidOperationException();
}
return _factorType;
}
set { _factorType = value; }
}
public static Factor Create(List<SyntaxNodeBase> children)
{
return new Factor { Children = children };

View File

@@ -1,6 +1,5 @@
using Canon.Core.Abstractions;
using Canon.Core.Enums;
using Canon.Core.SemanticParser;
namespace Canon.Core.SyntaxNodes;
@@ -18,11 +17,6 @@ public class IdentifierVarPart : NonTerminatedSyntaxNode
/// </summary>
public int IndexCount { get; set; }
/// <summary>
/// 数组左边界列表
/// </summary>
public List<int> LeftBounds = new();
/// <summary>
/// 索引中的表达式
/// </summary>

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;

View File

@@ -12,12 +12,6 @@ public class Parameter : NonTerminatedSyntaxNode
/// </summary>
public bool IsVar { get; private init; }
/// <summary>
/// 声明的变量名称
/// </summary>
public ValueParameter ValueParameter =>
IsVar ? Children[0].Convert<VarParameter>().ValueParameter : Children[0].Convert<ValueParameter>();
public override void PreVisit(SyntaxNodeVisitor visitor)
{
visitor.PreVisit(this);

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;
@@ -8,21 +7,6 @@ public class ProgramBody : NonTerminatedSyntaxNode
{
public override NonTerminatorType Type => NonTerminatorType.ProgramBody;
/// <summary>
/// 常量声明
/// </summary>
public ConstDeclarations ConstDeclarations => Children[0].Convert<ConstDeclarations>();
/// <summary>
/// 变量声明
/// </summary>
public VarDeclarations VarDeclarations => Children[1].Convert<VarDeclarations>();
/// <summary>
/// 子程序声明
/// </summary>
public SubprogramDeclarations SubprogramDeclarations => Children[2].Convert<SubprogramDeclarations>();
/// <summary>
/// 语句声明
/// </summary>

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;
@@ -13,11 +12,6 @@ public class ProgramStruct : NonTerminatedSyntaxNode
/// </summary>
public ProgramHead Head => Children[0].Convert<ProgramHead>();
/// <summary>
/// 程序体
/// </summary>
public ProgramBody Body => Children[2].Convert<ProgramBody>();
public override void PreVisit(SyntaxNodeVisitor visitor)
{
visitor.PreVisit(this);

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;

View File

@@ -1,7 +1,5 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.SemanticParser;
namespace Canon.Core.SyntaxNodes;
@@ -45,25 +43,6 @@ public class SimpleExpression : NonTerminatedSyntaxNode
/// </summary>
public event EventHandler<AddGeneratorEventArgs>? OnAddGenerator;
private PascalType? _simpleExpressionType;
public PascalType SimpleExpressionType
{
get
{
if (_simpleExpressionType is null)
{
throw new InvalidOperationException();
}
return _simpleExpressionType;
}
set
{
_simpleExpressionType = value;
}
}
public static SimpleExpression Create(List<SyntaxNodeBase> children)
{
return new SimpleExpression { Children = children };

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;
@@ -8,16 +7,6 @@ public class Subprogram : NonTerminatedSyntaxNode
{
public override NonTerminatorType Type => NonTerminatorType.Subprogram;
/// <summary>
/// 子程序头部
/// </summary>
public SubprogramHead Head => Children[0].Convert<SubprogramHead>();
/// <summary>
/// 子程序体
/// </summary>
public SubprogramBody Body => Children[2].Convert<SubprogramBody>();
public override void PreVisit(SyntaxNodeVisitor visitor)
{
visitor.PreVisit(this);

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;
@@ -8,21 +7,6 @@ public class SubprogramBody : NonTerminatedSyntaxNode
{
public override NonTerminatorType Type => NonTerminatorType.SubprogramBody;
/// <summary>
/// 常量声明部分
/// </summary>
public ConstDeclarations ConstDeclarations => Children[0].Convert<ConstDeclarations>();
/// <summary>
/// 变量声明部分
/// </summary>
public VarDeclarations VarDeclarations => Children[1].Convert<VarDeclarations>();
/// <summary>
/// 语句声明部分
/// </summary>
public CompoundStatement CompoundStatement => Children[2].Convert<CompoundStatement>();
public override void PreVisit(SyntaxNodeVisitor visitor)
{
visitor.PreVisit(this);

View File

@@ -26,8 +26,6 @@ public class SubprogramHead : NonTerminatedSyntaxNode
public IdentifierSemanticToken SubprogramName =>
Children[1].Convert<TerminatedSyntaxNode>().Token.Convert<IdentifierSemanticToken>();
public FormalParameter Parameters => Children[2].Convert<FormalParameter>();
public override void PreVisit(SyntaxNodeVisitor visitor)
{
visitor.PreVisit(this);

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;

View File

@@ -1,7 +1,5 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.SemanticParser;
namespace Canon.Core.SyntaxNodes;
@@ -45,25 +43,6 @@ public class Term : NonTerminatedSyntaxNode
/// </summary>
public event EventHandler<MultiplyGeneratorEventArgs>? OnMultiplyGenerator;
private PascalType? _termType;
public PascalType TermType
{
get
{
if (_termType is null)
{
throw new InvalidOperationException();
}
return _termType;
}
set
{
_termType = value;
}
}
public static Term Create(List<SyntaxNodeBase> children)
{
return new Term { Children = children };

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
using Canon.Core.SemanticParser;
@@ -37,11 +36,6 @@ public class TypeSyntaxNode : NonTerminatedSyntaxNode
public event EventHandler<ArrayTypeGeneratorEventArgs>? OnArrayTypeGenerator;
/// <summary>
/// 是否在过程定义中使用
/// </summary>
public bool IsProcedure { get; set; }
private PascalType? _pascalType;
/// <summary>

View File

@@ -1,5 +1,4 @@
using Canon.Core.Abstractions;
using Canon.Core.CodeGenerators;
using Canon.Core.Enums;
namespace Canon.Core.SyntaxNodes;

View File

@@ -1,7 +1,6 @@
using Canon.Core.Abstractions;
using Canon.Core.Enums;
using Canon.Core.LexicalParser;
using Canon.Core.SemanticParser;
namespace Canon.Core.SyntaxNodes;