public override object VisitAssignmentExpression(CLanguageParser.AssignmentExpressionContext context) { if (context.ChildCount == 3) { var functionName = context .GetFunction() .GetFirstDescendant <CLanguageParser.DirectDeclaratorContext>() .GetName(); var operand = context .unaryExpression() .GetDirectDescendant <CLanguageParser.PrimaryExpressionContext>(); List <string> dependentTokens = context .assignmentExpression() .GetDescendants <CLanguageParser.PrimaryExpressionContext>() .Select(x => x.GetName()) .ToList(); string variableName = operand.GetName(); if (DataStructure[functionName] != null && DataStructure[functionName][variableName] == null) { return(base.VisitAssignmentExpression(context)); } DataStructure[functionName].AddVariable(variableName, string.Empty, dependentTokens, context.Start.StartIndex); } return(base.VisitAssignmentExpression(context)); }
private RelationalExpression GetRelationalExpression(CLanguageParser.AssignmentExpressionContext context) { var leftExpression = context.unaryExpression(); var rightExpression = context.assignmentExpression(); var method = context.GetFunction().GetFirstDescendant <CLanguageParser.DirectDeclaratorContext>().GetName(); var result = new RelationalExpression { LeftOperand = leftExpression.GetText(), RightOperand = rightExpression.GetText(), LeftOperandSnapshot = GetSnapshotDeclaration(leftExpression.GetText(), method), RightOperandSnapshot = GetSnapshotDeclaration(rightExpression.GetText(), method), LeftOperandInterval = new Interval(leftExpression.GetStartIndex(), leftExpression.GetStopIndex()), RightOperandInterval = new Interval(rightExpression.GetStartIndex(), rightExpression.GetStopIndex()), Method = method }; return(result); }