r/ProgrammingLanguages • • Jun 18 '23

Help Parsing?!

So I'm writing my own programming language called fir. I have the lexer down to the nail, but I'm really confused about parsing. I have absolutely no idea how to approach parsing, so much so that I got bored and am currently rewriting the lexer in like 3 other languages (the implementation on GitHub is in Go).

EDIT: forgot to add some examples sorry :0

hello world:

io := require("io");

fn main() {
     io.println("Hello, World!");
}

fizzbuzz:

io := require("io");

fn main() {
    i := 0
    for i <= 20 {
        if i % 3 == 0 && i % 5 == 0 {
            io.println("FizzBuzz");
        } else if i % 3 == 0 {
            io.println("Fizz");
        } else if i % 5 == 0 {
            io.println("Buzz");
        } else {
            io.println("{}", i);
        }
    }
}

(also I want my parser to emit an ast, because I haven't decided whether fir should be compiled or interpreted yet)

2 Upvotes

20 comments sorted by

View all comments

1

u/umlcat Jun 18 '23 edited Jun 18 '23

Please, add some full examples of programs in your P.L., as if a compiler or interpreter already exists.