What programming languages are context-free?

前端 未结 9 967
萌比男神i
萌比男神i 2020-12-07 13:17

Or, to be a little more precise: which programming languages are defined by a context-free grammar?

From what I gather C++ is not context-free due to things like mac

相关标签:
9条回答
  • 2020-12-07 13:57

    I think Haskell and ML are supporting context free. See this link for Haskell.

    0 讨论(0)
  • 2020-12-07 13:58

    Depending on how you understand the question, the answer changes. But IMNSHO, the proper answer is that all modern programming languages are in fact context sensitive. For example there is no context free grammar that accepts only syntactically correct C programs. People who point to yacc/bison context free grammars for C are missing the point.

    0 讨论(0)
  • 2020-12-07 14:02

    Most of the modern programming languages are not context-free languages. As a proof, if I delve into the root of CFL its corresponding machine PDA can't process string matchings like {ww | w is a string}. So most programming languages require that.

    Example:

    int fa; // w
    fa=1; // ww as parser treat it like this
    
    0 讨论(0)
提交回复
热议问题