@@ -48,6 +48,11 @@ public class Expression : NonTerminatedSyntaxNode
|
||||
/// </summary>
|
||||
public bool IsIfCondition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为条件判断语句
|
||||
/// </summary>
|
||||
public bool IsCondition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为WHILE语句中的条件语句
|
||||
/// </summary>
|
||||
|
@@ -50,6 +50,11 @@ public class Factor : NonTerminatedSyntaxNode
|
||||
{
|
||||
public override NonTerminatorType Type => NonTerminatorType.Factor;
|
||||
|
||||
/// <summary>
|
||||
/// 是否为条件判断语句
|
||||
/// </summary>
|
||||
public bool IsCondition { get; set; }
|
||||
|
||||
public override void PreVisit(SyntaxNodeVisitor visitor)
|
||||
{
|
||||
visitor.PreVisit(this);
|
||||
@@ -158,10 +163,11 @@ public class Factor : NonTerminatedSyntaxNode
|
||||
else
|
||||
{
|
||||
// factor -> id ( )
|
||||
OnProcedureCallGenerator?.Invoke(this, new ProcedureCallGeneratorEventArgs
|
||||
{
|
||||
ProcedureName = terminatedSyntaxNode.Token.Convert<IdentifierSemanticToken>()
|
||||
});
|
||||
OnProcedureCallGenerator?.Invoke(this,
|
||||
new ProcedureCallGeneratorEventArgs
|
||||
{
|
||||
ProcedureName = terminatedSyntaxNode.Token.Convert<IdentifierSemanticToken>()
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (Children.Count == 4)
|
||||
@@ -177,7 +183,6 @@ public class Factor : NonTerminatedSyntaxNode
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SemanticToken token = Children[0].Convert<TerminatedSyntaxNode>().Token;
|
||||
Factor factor = Children[1].Convert<Factor>();
|
||||
|
||||
|
@@ -21,6 +21,11 @@ public class SimpleExpression : NonTerminatedSyntaxNode
|
||||
{
|
||||
public override NonTerminatorType Type => NonTerminatorType.SimpleExpression;
|
||||
|
||||
/// <summary>
|
||||
/// 是否为条件判断语句
|
||||
/// </summary>
|
||||
public bool IsCondition { get; set; }
|
||||
|
||||
public override void PreVisit(SyntaxNodeVisitor visitor)
|
||||
{
|
||||
visitor.PreVisit(this);
|
||||
@@ -52,19 +57,17 @@ public class SimpleExpression : NonTerminatedSyntaxNode
|
||||
{
|
||||
if (Children.Count == 1)
|
||||
{
|
||||
OnTermGenerator?.Invoke(this, new TermGeneratorEventArgs
|
||||
{
|
||||
Term = Children[0].Convert<Term>()
|
||||
});
|
||||
OnTermGenerator?.Invoke(this, new TermGeneratorEventArgs { Term = Children[0].Convert<Term>() });
|
||||
}
|
||||
else
|
||||
{
|
||||
OnAddGenerator?.Invoke(this, new AddGeneratorEventArgs
|
||||
{
|
||||
Left = Children[0].Convert<SimpleExpression>(),
|
||||
Operator = Children[1].Convert<AddOperator>(),
|
||||
Right = Children[2].Convert<Term>()
|
||||
});
|
||||
OnAddGenerator?.Invoke(this,
|
||||
new AddGeneratorEventArgs
|
||||
{
|
||||
Left = Children[0].Convert<SimpleExpression>(),
|
||||
Operator = Children[1].Convert<AddOperator>(),
|
||||
Right = Children[2].Convert<Term>()
|
||||
});
|
||||
}
|
||||
|
||||
OnTermGenerator = null;
|
||||
|
@@ -21,6 +21,11 @@ public class Term : NonTerminatedSyntaxNode
|
||||
{
|
||||
public override NonTerminatorType Type => NonTerminatorType.Term;
|
||||
|
||||
/// <summary>
|
||||
/// 是否为条件判断语句
|
||||
/// </summary>
|
||||
public bool IsCondition { get; set; }
|
||||
|
||||
public override void PreVisit(SyntaxNodeVisitor visitor)
|
||||
{
|
||||
visitor.PreVisit(this);
|
||||
@@ -52,19 +57,17 @@ public class Term : NonTerminatedSyntaxNode
|
||||
{
|
||||
if (Children.Count == 1)
|
||||
{
|
||||
OnFactorGenerator?.Invoke(this, new FactorGeneratorEventArgs
|
||||
{
|
||||
Factor = Children[0].Convert<Factor>()
|
||||
});
|
||||
OnFactorGenerator?.Invoke(this, new FactorGeneratorEventArgs { Factor = Children[0].Convert<Factor>() });
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMultiplyGenerator?.Invoke(this, new MultiplyGeneratorEventArgs
|
||||
{
|
||||
Left = Children[0].Convert<Term>(),
|
||||
Operator = Children[1].Convert<MultiplyOperator>(),
|
||||
Right = Children[2].Convert<Factor>()
|
||||
});
|
||||
OnMultiplyGenerator?.Invoke(this,
|
||||
new MultiplyGeneratorEventArgs
|
||||
{
|
||||
Left = Children[0].Convert<Term>(),
|
||||
Operator = Children[1].Convert<MultiplyOperator>(),
|
||||
Right = Children[2].Convert<Factor>()
|
||||
});
|
||||
}
|
||||
|
||||
OnFactorGenerator = null;
|
||||
|
Reference in New Issue
Block a user