public HamlDocument ParseHamlFile(HamlFile hamlFile) { var result = new HamlDocument(hamlFile.FileName); ParseNode(result, hamlFile); return result; }
private void ReadHamlLine(TextReader reader, HamlFile result) { string currentLine = ReadLine(reader); while (_lineLexer.GetEndOfTagIndex(currentLine) < 0) { if (_eof) throw new HamlMalformedTagException("Multi-line tag found with no end token.", _sourceFileLineIndex); currentLine += " " + ReadLine(reader); } result.AddRange(new HamlLineLexer().ParseHamlLine(currentLine, _sourceFileLineIndex - 1)); }
private void ReadHamlLine(TextReader reader, HamlFile result) { string currentLine = ReadLine(reader); while (_lineLexer.GetEndOfTagIndex(currentLine) < 0) { if (_eof) { throw new HamlMalformedTagException("Multi-line tag found with no end token.", _sourceFileLineIndex); } currentLine += " " + ReadLine(reader); } result.AddRange(new HamlLineLexer().ParseHamlLine(currentLine, _sourceFileLineIndex - 1)); }
public HamlFile Read(TextReader reader, string fileName) { _sourceFileLineIndex = 1; if (reader == null) throw new ArgumentNullException("reader"); var result = new HamlFile(fileName); _eof = (reader.Peek() < 0); while (_eof == false) ReadHamlLine(reader, result); return result; }
public HamlFile Read(TextReader reader, string fileName) { _sourceFileLineIndex = 1; if (reader == null) { throw new ArgumentNullException("reader"); } var result = new HamlFile(fileName); _eof = (reader.Peek() < 0); while (_eof == false) { ReadHamlLine(reader, result); } return(result); }
private void ParseNode(HamlNode node, HamlFile hamlFile) { //node.IsMultiLine = true; while ((!hamlFile.EndOfFile) && (hamlFile.CurrentLine.IndentCount > node.IndentCount)) { var nodeLine = hamlFile.CurrentLine; var childNode = HamlNodeFactory.GetHamlNode(nodeLine); node.AddChild(childNode); hamlFile.MoveNext(); if (hamlFile.EndOfFile == false && hamlFile.CurrentLine.IndentCount > nodeLine.IndentCount) { if (hamlFile.CurrentLine.IsInline == false) childNode.AppendInnerTagNewLine(); ParseNode(childNode, hamlFile); } if (hamlFile.EndOfFile == false && hamlFile.CurrentLine.IndentCount >= nodeLine.IndentCount) { node.AppendPostTagNewLine(childNode, hamlFile.CurrentLine.Metrics.LineNo); } } }
public void ParseHamlFile_UnknownRuleType_ThrowsUnknownRuleException() { var line = new HamlLine("", HamlRuleEnum.Unknown, indent: ""); var file = new HamlFile(""); file.AddLine(line); Assert.Throws<HamlParserUnknownRuleException>(() => _parser.ParseHamlFile(file)); }