Published On: February 3rd, 2023Categories: AI News

Recently I wrote a very simple programming language, here is the repo, the language is extremely small, my objective was to write a programming language that can do fibonacci, that’s it.
fib written in square

[>:fib n:
  [:if n < 3:
    return n - 1
  ]
  return [:fib n - 1] + [:fib n - 2]
]
[:fib 10]

[:print n]
Enter fullscreen mode

Exit fullscreen mode

Image description

it works!!!

It uses one of the most popular tools to write the grammar, the AST is very minimal and is executed in C, today I’m gonna explain the main components of a programming language trying to be as concise as possible.



The Grammar

This is the heart of the language, This is how you interact with the language, the grammar rules define how to write code for the language, I used flex and bison to write the grammar, the grammar of the language is written on square.y skim through those rules just to get a idea of how they work.

Here’s a grammar rule from the…

Source link

Recently I wrote a very simple programming language, here is the repo, the language is extremely small, my objective was to write a programming language that can do fibonacci, that’s it.
fib written in square

[>:fib n:
  [:if n < 3:
    return n - 1
  ]
  return [:fib n - 1] + [:fib n - 2]
]
[:fib 10]

[:print n]
Enter fullscreen mode

Exit fullscreen mode

Image description

it works!!!

It uses one of the most popular tools to write the grammar, the AST is very minimal and is executed in C, today I’m gonna explain the main components of a programming language trying to be as concise as possible.



The Grammar

This is the heart of the language, This is how you interact with the language, the grammar rules define how to write code for the language, I used flex and bison to write the grammar, the grammar of the language is written on square.y skim through those rules just to get a idea of how they work.

Here’s a grammar rule from the…

, How To Write A Programming Language , Marcell Cruz , 2023-02-03 00:13:58 , DEV Community 👩‍💻👨‍💻 , , https://res.cloudinary.com/practicaldev/image/fetch/s–lKdvE0aN–/c_imagga_scale,f_auto,fl_progressive,h_500,q_auto,w_1000/https://www.itprotoday.com/sites/itprotoday.com/files/styles/article_featured_retina/public/Screen%2520Shot%25202018-12-08%2520at%25204.45.18%2520PM_0.png%3Fitok%3DUvQJWfWh , [rule_{ruleNumber}] , [rule_{ruleNumber}_plain] , , , https://dev.to/____marcell/how-to-write-a-programming-language-1o99 , https://dev.to/____marcell/how-to-write-a-programming-language-1o99 , dev.to , https%3A%2F%2Fdev.to%2F____marcell%2Fhow-to-write-a-programming-language-1o99 , programming,c,computerscience , Prompt, #Write #Programming #Language

Leave A Comment