void EvalSubstitution(SubstitutionExpression expr, EvalOption option) { option = new EvalOption(); option.ForWriting = true; var target = Eval(expr.Target, option); var value = Eval(expr.Value, null); if (value is Attribute) { value = (value as Attribute).Value; } var targetAttribute = target as Attribute; if (targetAttribute == null) { throw new InvalidSubstitution(expr.Line); } if (value is Value) { targetAttribute.Value = value; } }
Expression[] Sentence() { List <Expression> sentences = new List <Expression>(); while (true) { var empty = Peek(); if (empty == null) { break; } if (empty.Type == TokenType.NewLine) { Next(); continue; } var lhs = Expr(); var token = Peek(); if (token != null) { if (token.Type == TokenType.Equal) { Next(); var rhs = Expr(); var substitution = new SubstitutionExpression(); substitution.Target = lhs; substitution.Value = rhs; substitution.Line = token.Line; sentences.Add(substitution); } else { sentences.Add(lhs); } } else { sentences.Add(lhs); break; } } return(sentences.ToArray()); }