Parser and Abstract Syntax Tree

looks like I’m not gonna get an explanation. Oh well


Yeah but I still can’t understand it. This time should be the final time.

Here’s what I need to be explained (please don’t use too much terms so I can understand lol):




Let me specify so I don’t have to make another post



Summary

How do I make a parser that creates a bunch of nodes that eventually form a Abstract Syntax Tree (AST) specifically for Lua, specifically Lua




What do I wanna know

Now what do I want to learn to do? I want to learn how to create a parser; not the super complicated ones like a full LR Parser.

I wanna be able to understand how each part of the parsing process works (doesn’t got to be in extreme detail, just enough so that I understand).

Like how to generate nodes for the AST and overall preparing it to be put thru an interpreter (which I’m not tryna do rn)

I do understand that I’ve made many posts like this but I can’t seem to get an actual grasp of how it works; and how I’d apply it and make my own.



extra stuff

I feel like that if I can’t actually use what I learn and actually make it work, then I haven’t really learned it



Thank you… hopefully this is the last time I have to make a post about learning about parsers

or not I’m not sure but hopefully this answers all my questions (thank y’all for the help)

3 Likes

I’m assuming that you already know how a lexer works and how to generate tokens from a source string. I recommend you look into recursive descent parsing and maybe watch a few videos on the subject. Parsers are what define the grammar of your language, so you can do it however you’d like.

3 Likes

Hmm alright I’ll look in Recursive Descent Parsing

Doesn’t seem like any one else is gonna explain it so I guess I’ll have to try to scour for stuff myself.

Thanks though!

Sorry to kinda bump this again but I found a nice resource that dives into how parsers work a bit, even though it still doesn’t really answer my question. Just wanna share this for anyone else who stumbles across this

article 1

article 2

Even though I have marked a solution, if anyone else can help it would be very greatly appreciated

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.