Search code examples
parsingsyntaxlanguage-featureslanguage-designsyntactic-sugar

What syntax sugar or language features makes a language hard/tough to parse?


I did some searching and didn't find a question that "directly" answered this question.

Anyway the basic gist of this question is I am wondering what "language feature" or "syntax" that makes a language be a major pain to build a parser, syntax highlighting, etc?

This might be subjective but I was thinking of like for example the difference in parsing a language like say Lisp for example with its (func parms etc..) structure, as versus to something like C++ with all of the templates, brackets and so forth.


Solution

  • Languages that support syntax extension through macros or other means cannot be fully parsed unless you can properly expand the macros. For languages with full procedural macros such as Lisp or Curl, you can't fully parse without implementing the language itself!

    Typically for the purposes of syntax highlighting for such languages you don't try to expand macros and assume that macros follow conventional language idioms.