4 ms·
And now you have 404 problems. In all seriousness, this is why I don't like the IETF's documents. They write in a verbose way and then don't even provide a ref
by k_sze 11y ago
And now you have 404 problems.
In all seriousness, this is why I don't like the IETF's documents. They write in a verbose way and then don't even provide a reference implementation, in this case, a reference regex that would have done away with lots of dispute and ambiguity. It is my opinion that, in practice, your specification is inherently broken if you can't provide a reference implementation.
(No, BNF doesn't count as reference "implementation". Who uses BNF in their programs to validate strings anyway?)
- SFjulie1 11y agoThere is more than grammar in URL: there is politics like gov.uk is a TLD. And that is why IETF RFC are so verbose. Because there is politics in them. That is why you can't provide regexps. url because of politics are not context free. https://www.cs.rochester.edu/~nelson/courses/csc_173/grammars/cfg.html https://www.cs.rochester.edu/~nelson/courses/csc_173/grammar... So a URL because of politics is a context full grammar. And regexp cannot parse anything else than context free stuff. To be honest I doubt anything useful is context free. I doubt, therefore, that anything useful can be parsed with regexp... Except float, integer, and other basic types that are useful to build a context full grammar... But for this RFC should separate standards in context free stuffs (rules/context free stuff) and config file for the political/commercial stuffs (context that changes meanings of atoms being parsed for illogical reasons). The problem is politics is fucking hard to normalize, we have no BSML yet.
- pekk 11y agoA minor clarification for those who might be learning from HN: regular expressions aren't equivalent to context-free grammars, they are even more limited than context-free grammars. Things which involve arbitrary-depth nesting or recursion, like HTML, can't be parsed by regular expressions, but that is exactly what context-free grammars are for. Where regular expressions correspond to finite state automata (essentially directed graphs where nodes are states and edges are input-driven transitions between states), context-free grammars correspond to pushdown automata (with a stack, this is the recursion secret sauce). Lots of interesting things are context-free. For example, any good programming language grammar should be context-free, to allow sane and efficient parsing. I welcome further corrections.
- pjtr 11y agoIn other words regular expressions are equivalent to regular grammars [1]. (Except "modern regular expressions" support some construct that make them match some non-regular grammars. [2]) [1] https://en.wikipedia.org/wiki/Regular_grammar https://en.wikipedia.org/wiki/Regular_grammar [2] https://en.wikipedia.org/wiki/Regular_expression#Patterns_for_non-regular_languages https://en.wikipedia.org/wiki/Regular_expression#Patterns_fo...
- georgerobinson 11y agoCould you write a blog post on this? I want to learn more!