internal static bool TryParse(Node parent, Queue<Word> remainingWords, out PropertyAssignment property) { if (remainingWords.Skip(1).First().Text != ":") { property = null; return false; } property = new PropertyAssignment(parent); property.Name = remainingWords.Dequeue().Text; // remove ':' remainingWords.Dequeue(); Block block; if (Block.TryParse(property, remainingWords, out block)) { property.Value = block; return true; } Expression expression; if (Expression.TryParse(property, remainingWords, out expression)) { property.Value = expression; // remove ';' if (remainingWords.Peek().Text == ";") { remainingWords.Dequeue(); } return true; } property = null; return false; }
public override Node Clone(Node newParent) { var newAssignment = new PropertyAssignment(newParent); newAssignment.Name = Name; newAssignment.Value = Value.Clone(newAssignment); return newAssignment; }
public override Node Clone(Node newParent) { var newAssignment = new PropertyAssignment(newParent); newAssignment.Name = Name; newAssignment.Value = Value.Clone(newAssignment); return(newAssignment); }
internal static bool TryParse(Node parent, Queue <Word> remainingWords, out Block block) { if (remainingWords.Peek().Text != "{") { block = null; return(false); } remainingWords.Dequeue(); block = new Block(parent); while (remainingWords.Peek().Text != "}") { IncludeDirective includeDirective; if (IncludeDirective.TryParse(block, remainingWords, out includeDirective)) { block.Children.Add(includeDirective); continue; } ExtendDirective excludeDirective; if (ExtendDirective.TryParse(block, remainingWords, out excludeDirective)) { block.Children.Add(excludeDirective); continue; } PropertyAssignment property; if (PropertyAssignment.TryParse(block, remainingWords, out property)) { block.Children.Add(property); continue; } Selector selector; if (Selector.TryParse(block, remainingWords, out selector)) { block.Children.Add(selector); continue; } } remainingWords.Dequeue(); return(true); }
internal static bool TryParse(Node parent, Queue <Word> remainingWords, out PropertyAssignment property) { if (remainingWords.Skip(1).First().Text != ":") { property = null; return(false); } property = new PropertyAssignment(parent); property.Name = remainingWords.Dequeue().Text; // remove ':' remainingWords.Dequeue(); Block block; if (Block.TryParse(property, remainingWords, out block)) { property.Value = block; return(true); } Expression expression; if (Expression.TryParse(property, remainingWords, out expression)) { property.Value = expression; // remove ';' if (remainingWords.Peek().Text == ";") { remainingWords.Dequeue(); } return(true); } property = null; return(false); }