/// <summary> /// Creates a redef expression based on the input of the parser /// </summary> /// <returns></returns> private Expression DerefExpression() { Expression retVal = null; List <Expression> derefArguments = new List <Expression>(); string id = Identifier(); while (id != null) { Designator designator = new Interpreter.Designator(Root, id); Term term = new Term(Root, designator); UnaryExpression unaryExpression = new UnaryExpression(Root, term); derefArguments.Add(unaryExpression); id = null; if (LookAhead(".")) { Match("."); id = Identifier(); } } if (derefArguments.Count == 1) { retVal = derefArguments[0]; } else if (derefArguments.Count > 1) { retVal = new DerefExpression(Root, derefArguments); } return(retVal); }
/// <summary> /// Visits a Deref expression /// </summary> /// <param name="derefExpression"></param> protected virtual void VisitDerefExpression(DerefExpression derefExpression) { foreach (Expression expression in derefExpression.Arguments) { if (expression != null) { VisitExpression(expression); } } }
/// <summary> /// Implements the dot continuation or the function call continuation /// </summary> /// <param name="expressionLevel">the level of the right expression</param> /// <param name="expressionLeft">the left part of the current expression</param> /// <returns></returns> private Expression Continuation(Expression expressionLeft) { Expression current = expressionLeft; int first = Index; List <Expression> derefArguments = new List <Expression>(); while (!Utils.Utils.isEmpty(LookAhead(CONTINUATION_OPERATORS))) { List <Expression> tmp = new List <Expression>(); while (LookAhead(".")) { if (current != null) { tmp.Add(current); } else { string invalidDeref = expressionLeft + (new String(Buffer).Substring(first, Index - first)); Root.AddWarning("Invalid deref expression for [" + invalidDeref + "] skipping empty dereference"); } Match("."); current = Expression(7); } if (tmp.Count > 0) { if (current != null) { tmp.Add(current); } else { string invalidDeref = expressionLeft + (new String(Buffer).Substring(first, Index - first)); Root.AddWarning("Invalid deref expression for [" + invalidDeref + "] skipping empty dereference"); } current = new DerefExpression(Root, tmp); } while (LookAhead("(")) { current = EvaluateFunctionCallExpression(current); } } if (derefArguments.Count > 0) { derefArguments.Add(current); current = new DerefExpression(Root, derefArguments); } return(current); }
/// <summary> /// Creates a redef expression based on the input of the parser /// </summary> /// <returns></returns> private Expression DerefExpression() { Expression retVal = null; List<Expression> derefArguments = new List<Expression>(); SkipWhiteSpaces(); int start = Index; string id = Identifier(); while (id != null) { Designator designator = new Designator(Root, RootLog, id, start, start + id.Length); Term term = new Term(Root, RootLog, designator, designator.Start, designator.End); UnaryExpression unaryExpression = new UnaryExpression(Root, RootLog, term, term.Start, term.End); derefArguments.Add(unaryExpression); id = null; if (LookAhead(".")) { Match("."); SkipWhiteSpaces(); start = Index; id = Identifier(); } } if (derefArguments.Count == 1) { retVal = derefArguments[0]; } else if (derefArguments.Count > 1) { retVal = new DerefExpression(Root, RootLog, derefArguments, derefArguments[0].Start, derefArguments[derefArguments.Count - 1].End); } return retVal; }
/// <summary> /// Implements the dot continuation or the function call continuation /// </summary> /// <param name="expressionLeft">the left part of the current expression</param> /// <returns></returns> private Expression Continuation(Expression expressionLeft) { Expression current = expressionLeft; int first = Index; List<Expression> derefArguments = new List<Expression>(); while (!Utils.Util.isEmpty(LookAhead(ContinuationOperators))) { List<Expression> tmp = new List<Expression>(); while (LookAhead(".")) { if (current != null) { tmp.Add(current); } else { string invalidDeref = expressionLeft + (new String(Buffer).Substring(first, Index - first)); RootLog.AddWarning("Invalid deref expression for [" + invalidDeref + "] skipping empty dereference"); } Match("."); current = Expression(7); } if (tmp.Count > 0) { if (current != null) { tmp.Add(current); } else { string invalidDeref = expressionLeft + (new String(Buffer).Substring(first, Index - first)); RootLog.AddWarning("Invalid deref expression for [" + invalidDeref + "] skipping empty dereference"); } current = new DerefExpression(Root, RootLog, tmp, expressionLeft.Start, tmp[tmp.Count - 1].End); } while (LookAhead("(")) { current = EvaluateFunctionCallExpression(current); } } if (derefArguments.Count > 0) { derefArguments.Add(current); current = new DerefExpression(Root, RootLog, derefArguments, derefArguments[0].Start, derefArguments[derefArguments.Count - 1].End); } return current; }
/// <summary> /// Creates a redef expression based on the input of the parser /// </summary> /// <returns></returns> private Expression DerefExpression() { Expression retVal = null; List<Expression> derefArguments = new List<Expression>(); string id = Identifier(); while (id != null) { Designator designator = new Interpreter.Designator(Root, id); Term term = new Term(Root, designator); UnaryExpression unaryExpression = new UnaryExpression(Root, term); derefArguments.Add(unaryExpression); id = null; if (LookAhead(".")) { Match("."); id = Identifier(); } } if (derefArguments.Count == 1) { retVal = derefArguments[0]; } else if (derefArguments.Count > 1) { retVal = new DerefExpression(Root, derefArguments); } return retVal; }