Hacker News new | past | comments | ask | show | jobs | submit login

#2 is incorrect. Being sensitive to line breaks does not make a grammar context-sensitive. It just means you have to treat line breaks as tokens rather than ignorable whitespace (which is exactly what the context-free grammar given in the C11 standard does).

Same with the bit about concatenating tokens. Every single one of those examples has a static parse tree, which, for the C preprocessor, is a sequence of tokens and directives. The author seems to be confusing the preprocessor's parse tree with the effect it has on the underlying text.

(Yes, the output of the preprocessor is dependent on what you define, but that has nothing to do with the grammar. What the author claims is like saying a Lisp is context-sensitive because the factorial function produces a different values for different inputs!)

Now, if you could do this:

    #define foobar define
    #foobar x 123
    x
and get "123", that would be a context-sensitive grammar. But that is NOT a thing you can do!



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: