chomsky hierarchy and programming languages

后端 未结 3 1189
日久生厌
日久生厌 2021-02-01 22:05

I\'m trying to learn some aspects of the Chomsky Hierarchy which are related to programming languages, and i still have to read the Dragon Book.

I\'ve read that most pro

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-01 22:14

    This is absolutely not true. Most programming languages have a syntax that can be described by a CFG or BNG, but conforming to the syntax does not guarantee a legal program. There are all sorts of extra conditions such as "variables must be declared before use" or "the types in this expression must be combined in a legal way" that are not covered by the grammar, and that is what makes the languages non-context-free. (This is a bit like XML, which has a formally verifiable definition, but usually also extra constraints that a parser cannot verify.)

提交回复
热议问题