private bool AreAttributesCorrect(Tag tag) { var attribLexer = new Lexer.Lexer( new TokenDefinition("equal", @"="), new TokenDefinition("string", @"""[^""']+"""), new TokenDefinition("string", @"'[^""']+'"), new TokenDefinition("float", @"[-+]?\d*\.\d+([eE][-+]?\d+)?"), new TokenDefinition("number", @"\d+"), new TokenDefinition("word", @"[^<>\s=""]+") ) { MatchEverything = true }; foreach (var attrib in tag.AttributesList) { if (!IsAttributeCorrect(attribLexer.Tokanize(attrib).Select(s => s.Type).ToArray())) { ErrorMessage = "Incorrect attribute\n" + $"in tag {tag.Name} at position ({tag.Line}, {tag.Line})."; return(false); } } return(true); }
public void PrintTokens(string html) { _lexer.Tokanize(html).ForEach(Console.WriteLine); }