新增赋值操作
This commit is contained in:
@@ -589,6 +589,38 @@ namespace Flee.Parsing
|
||||
return node;
|
||||
}
|
||||
|
||||
public override Node ExitAssign(Token node)
|
||||
{
|
||||
node.AddValue("=");
|
||||
return node;
|
||||
}
|
||||
|
||||
public override Node ExitAssignmentExpression(Production node)
|
||||
{
|
||||
// 获取子节点:标识符和表达式
|
||||
var children = this.GetChildValues(node);
|
||||
if (children.Count != 3) // IDENTIFIER, ASSIGN, Expression
|
||||
{
|
||||
throw new InvalidOperationException("Assignment expression must have exactly 3 children");
|
||||
}
|
||||
|
||||
string variableName = (string)children[0];
|
||||
ExpressionElement valueExpression = (ExpressionElement)children[2];
|
||||
|
||||
// 获取表达式上下文
|
||||
var context = _myServices.GetService(typeof(ExpressionContext)) as ExpressionContext;
|
||||
if (context == null)
|
||||
{
|
||||
throw new InvalidOperationException("ExpressionContext not found in services");
|
||||
}
|
||||
|
||||
// 创建赋值表达式元素
|
||||
var assignmentElement = new AssignmentElement(variableName, valueExpression, context);
|
||||
node.AddValue(assignmentElement);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
public override void Child(Production node, Node child)
|
||||
{
|
||||
base.Child(node, child);
|
||||
|
Reference in New Issue
Block a user