Building a Regex Engine in Fewer Than 40 Lines of Code
1–10 of 37 posts
Re: Building a Regex Engine in Fewer Than 40 Lines of Code
#2Re: Building a Regex Engine in Fewer Than 40 Lines of Code
#3This does not implement grouping "()" or alternatives "|". Hence, looping is only required on individual characters. This is a considerable simplification over full regexp.
"considerable simplification" sounds like it's kinda regex. It's not even basic regular expressions/regular languages.
Edit: The author reimplements code from https://www.cs.princeton.edu/courses/archive/spr09/cos333/be... which acknowledges that the implemented subset does not match all classes but they propose that the classes they can parse, are already useful. The author of the new article makes no such acknowledgement that their implementation just represents a subset of regular languages.
Of course, the regular languages themselves are also just a subset of regexp, which can match more languages due to constructs like references.
Re: Building a Regex Engine in Fewer Than 40 Lines of Code
#4Re: Building a Regex Engine in Fewer Than 40 Lines of Code
#5Code golf link to a similar challenge https://codegolf.stackexchange.com/questions/125708/regular-...
Re: Building a Regex Engine in Fewer Than 40 Lines of Code
#6Re: Building a Regex Engine in Fewer Than 40 Lines of Code
#7Re: Building a Regex Engine in Fewer Than 40 Lines of Code
#8The most obnoxious part is backreferences. The atom \3 is a backreference if the whole regexp contains at least 3 capture groups; otherwise it is an octal (!) escape for char code 3. But you don't know how many capture groups there are until you're done parsing. This is why JS regexp parsers sometimes must make two passes!
Re: Building a Regex Engine in Fewer Than 40 Lines of Code
#9This does not implement grouping "()" or alternatives "|". Hence, looping is only required on individual characters. This is a considerable simplification over full regexp.