|
|
|
|
|
by weinzierl
185 days ago
|
|
"This covers practically all programming languages, because they conform to a syntax tree where each branch is an application of such a production rule." Except that practically all practically used programming languages are not context-free. |
|
Programming languages usually have a number of "higher-level semantic layers" on top of the syntax tree that impose further constrains - e.g. that identifiers must have consistency between usage and definition, that all expressions are valid according to the type system, etc.
But all that stuff happens after an AST is created and so doesn't really affect the basic grammar.
I think if you ignore those higher-level constraints, a number of languages have valid context-free grammars.