Creating your own language

前端 未结 4 1347
梦毁少年i
梦毁少年i 2020-12-02 18:05

If I were looking to create my own language are there any tools that would help me along? I have heard of yacc but I\'m wondering how I would implement features that I want

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 18:21

    I like Flex (Fast Lex) [Lexical scanner]
    and Bison (A Hairy Yacc) [Yet another compiler compiler]

    Both are free and available on all *NIX installations. For Windows just install cygwin.
    But I old school.

    By using these tools you can also find the lex rules and yacc gramers for a lot of popular languages on the internet. Thus providing you with a quick way to get up and running and then you can customize the grammers as you go.

    Example: Arithmetic expression handling [order of precedence etc is a done to death problem] you can quickly get the grammer for this from the web.

    An alternative to think about is to write a front-end extension to GCC.
    Non Trivial but if you want a compiled language it saves a lot of work in the code generation section (you will still need to know love and understand flex/bison).

提交回复
热议问题