How to can I develop a programming language like Coffee Script?

前端 未结 3 603
耶瑟儿~
耶瑟儿~ 2021-02-09 10:17

What are the initial requirement that i need to know to develop a programming language like coffee script that basically has its own syntax but after compilation changes into an

相关标签:
3条回答
  • 2021-02-09 10:55

    A good first step is to read Programming Languages: Application and Interpretation. It'll teach you how to design and implement languages with interpreters.

    0 讨论(0)
  • 2021-02-09 11:02

    The initial requirements are:

    • Determine the target computer language
    • Develop the syntax of your new language
    • Map the syntax of your new language to the target language.

    You'll still have plenty of work ahead, but basically, you're translating your new language into a target language.

    0 讨论(0)
  • 2021-02-09 11:10
    • Specify your language with a basic formal grammar in something like EBNF.

      statement        = if-statement
                       | return-statement
                       | expression
                       | ...
      
      if-statement     = "if" "(" expression ")" "{" statements "}"
      
      return-statement = "return" expression ";"
      
      ...
      
    • Learn about simple parsing by recursive descent and operator precedence.

    • Write a parser that creates an abstract syntax tree from a source file.

    • Write a code generator that converts this AST into your target language; or

    • Write an interpreter that merely evaluates the AST.

    0 讨论(0)
提交回复
热议问题