0

Hi I have an assignment which is supposed to check given a string if it can become a valid html file. like for example running this:

doc2 = “<head> Test2 <body> Testing </body>"

should output this:

λ parse hmtl doc2
(False, “<head> Test2 <body> Testing </body>”)

the trouble I am having is creating a parser for the tags. I know that there is a package, but we are not allowed to use it. Any ideas on how to do this?

PyRulez
  • 10,513
  • 10
  • 42
  • 87
user3324236
  • 5
  • 1
  • 8
  • [Don't use regular expressions.](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) – PyRulez Apr 04 '16 at 16:35
  • Also, after you turn in your assignment, take a look at the source code of the package. Haskell is easy to read for the most part. – PyRulez Apr 04 '16 at 16:37
  • The question is very broad.... Can you use parser packages? Which one, parsec, happy (the approaches are very different)? Do you have to write a parser from first principles? Are you building for performance? – jamshidh Apr 04 '16 at 17:57
  • @PyRulez that doesn't really help me writing the function. – user3324236 Apr 05 '16 at 00:05
  • @jamshidh we can not use any parser packages. We have to write a parser from first principles. No performance does not matter. – user3324236 Apr 05 '16 at 00:07
  • @user3324236 Okay, sorry. This may be more helpful: http://dev.stephendiehl.com/fun/002_parsers.html – PyRulez Apr 05 '16 at 00:13

0 Answers0