News for hackers. Stuff that matters.
Re:Scandalous Weird Old Things About The C Preprocessor (2015) by chubot on Wednesday May 31, 2017 @05:33AM (#14451278)
I don't think most languages in widespread use have lexers that are regular. Here the same author gives the example of Python's indentation requiring a stack: http://trevorjim.com/python-is-not-context-free/

Also Haskell: http://trevorjim.com/haskell-is-not-context-free/

I'm pretty sure in JavaScript that the /s+/ regex syntax can't be recognized with a regular language. Perl is of course insane -- it's not even statically parseable [1]. Shell isn't context-free.

The theme of this set of posts is that most languages used in practice aren't expressible with CFGs, and I agree. I didn't prove it but he shows how you would prove it.

[1] http://www.oilshell.org/blog/2016/10/20.html (see the end of this post for links about C++, Perl, Make)

There are no comments on this comment yet.