private void InitialiseExpression() { foreach (SubtractionString sub in Value.List) { if (sub.List.Count > 1) { Simple = false; } foreach (MultiplicationString mult in sub.List) { foreach (DivisionString div in mult.List) { if (div.List.Count > 1) { Simple = false; } foreach (ExpressionAtom atom in div.List) { switch (atom.AtomType) { case ExpressionAtomType.SubExpression: Expression tmp = ((SubExpressionAtom)atom).Expression; Layer = Math.Max(tmp.Subexpressions.Select(s => s.Layer).Max() + 1, Layer); Subexpressions.AddRange(tmp.Subexpressions); Subexpressions.Add(tmp); break; case ExpressionAtomType.Register: RegisterTargets.Add((RegisterAtom)atom); break; case ExpressionAtomType.Static: break; } } } } } }
public TokenExpression(IEnumerable <TokenExpression> expressions, TokenType tokenType) : this(new Token("...")) { if (this.Subexpressions == null) { this.Subexpressions = new TokenExpressionCollection(this); } this.TokenType = tokenType; if (expressions != null) { Subexpressions.AddRange(expressions); } if (tokenType == TokenType.First) { var first = Subexpressions.FirstOrDefault(); if (first != null) { this.TokenType = first.TokenType; } } }