HTML-Validator
README.md

C VERSION:

Compile using:

On Windows & Linux
  • gcc -o validator C/validator.c

Run using:

On Windows
  • ./validator.exe (this will default to opening file.html)

  • ./validator.exe <filepath>

    On Linux

  • ./validator (this will default to opening file.html)

  • ./validator <filepath>

Notes regarding tokenize

  • void tokenize(char* stringPtr)

It may not be much but im proud of this little function It cleans out attributes and field contents while still lexing the html susbet. While it does clear out field contents, it can pick up on mistakes caused by angle brackets

  • Floating <'s and >'s will be errored up
    • Special case ....<...>..., which is incorrect will cause <...>, can be identified
  • Unclosed tags i.e. </p will be tokenized verbatim, thus can identify this mistake
  • Unopened tags i.e. p> will be errored

Notes regarding exit()

  • Calling exit implicitly free's all pointers and memory allocations, thus we do not need to explicitly call free, in fact when testing on ubuntu the terminal does not like that we use free().

  • The code always terminates using exit(), whether it be exit(ON_FAILURE) or exit(ON_SUCESS). And thus, all free's were taken out. The code has to hold onto the token array and token stack whilst it is in use, and will always terminate thus deallocating using free seems intuitive to use.

Testing

This code has been tested on a windows machine and a portable install of linux, access to mac is limited and an install of some linux distro may not be possible given the current timeframe.

Haskell VERSION:

Run using:

  • runhaskell .\validator.hs