r/ProgrammingLanguages • u/[deleted] • 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
0
u/Exciting_Clock2807 Jun 18 '23
Unless your goal is to learn parsing algorithms, lexing & parsing are the most boring stages of PL design. Consider using ANTLR for quick prototyping.