ForeStrikeGallery / Mamba

A programming language inspired by python
0 stars 0 forks source link

Implement the parser #1

Open ForeStrikeGallery opened 2 years ago

ForeStrikeGallery commented 2 years ago

Write the parsing logic which converts tokens generated by the lexer into a syntax tree.

ForeStrikeGallery commented 2 years ago

Sample code and it's parsed syntax:

int a;
a = 3 + twice(2)
[
 14     {
 15         "declaration": {
 16             "type": "int",
 17             "identifier": "a"
 18         }
 19     },
 20
 21     {
 22         "assignment": {
 23             "identifier": "a",
 24             "value": {
 25                 "operation": {
 26                     "type": "addition",
 27                     "arg1": {
 28                         "type": number,
 29                         "value": 3
 30                     }
 31                     "arg2": {
 32                         "value": {
 33                             "function_call": {
 34                                 "identifier": "twice",
 35                                 "args": [2]
 37                             }
 38                         }
 39                     }
 40                 }
 41             }
 42         }
 43     }
ForeStrikeGallery commented 2 years ago

Added parser and executor for num variable declaration https://github.com/ForeStrikeGallery/Mamba/pull/4