4 ms·
I am not sure if you can say that precisely -- I added the caveats about the rules for end tags, and the rules for stray < and >. But certainly a useful subset
by chubot 6y ago
I am not sure if you can say that precisely -- I added the caveats about the rules for end tags, and the rules for stray < and >.
But certainly a useful subset of HTML can be parsed with a DPDA. (I'd be interested in more analysis of that; arbitrary tags are another factor)
It's a matter of opinion but I would say recursive descent is "nontrivial", whereas matching tags is "trivial".
Recursive descent involves some choice around lookahead or backtracking. It can be slow if you do the wrong thing, hard to debug, etc. It takes a little practice, and correspondence with a grammar is important.
Whereas matching HTML tags requires no lookahead, and I would say anyone can figure it out just with a simple code reading. Even the "inverted" OOP style is "simple", but annoying for me to read and correctly modify. The call stack reads much better.