Made a grammer... what next?

Mar 18, 2013 at 2:02am
closed account (Dy7SLyTq)
I made a grammer with the GPB. nothing to amazing. then i exported the file. what do i do next to make an interpreted language?
Mar 18, 2013 at 7:27am
What's GPB? Anyway, once you've got a grammar figured out, you need to write a parser for it. You need to parse the program text into some sort of data structure. For instance, in LISP, that structure is just a pair of pointers (and all the lists and trees you can make out of that). For you it would involve a list of functions and a list of statements for each function and etc. Finally just write a function to execute that structure.
Mar 18, 2013 at 2:57pm
closed account (Dy7SLyTq)
thank you and its the GOLD parser builder
Mar 18, 2013 at 11:11pm
closed account (Dy7SLyTq)
so should i use something like bison then?
Mar 19, 2013 at 6:18am
It seems that GPB is going to take care of the parser for you (with the Engine bit, whatever it outputs). Although I'm not sure why use anything at all. Parsing isn't that hard, especially if your grammar is simple enough for a recursive descent parser. The task is generally automated, because all parsers are pretty much the same (same methods, only different grammars), but the whole point of making toy projects is to learn, so you might as well do it yourself...
Mar 19, 2013 at 2:30pm
closed account (Dy7SLyTq)
one last question before i get started. am i limited to one language when making this or can i use whatever i need when i need it
Mar 19, 2013 at 2:54pm
I have no idea what you're asking about...
Mar 19, 2013 at 8:37pm
closed account (Dy7SLyTq)
am i limited to one language when making the parser, or can it be a hybrid, like compiled python and c++
Mar 20, 2013 at 7:01am
I don't know if GPB forces you into something, but apart from that, a parser is no different from any other project - sure you can.
Mar 20, 2013 at 11:35am
closed account (D4S8vCM9)
bison already creates the parser code for you, so if you think your grammar will grow more complex with time, I would move to it.
Else writing an object oriented recursive parser is not that much to do.
Mar 23, 2013 at 7:27pm
closed account (Dy7SLyTq)
hey i know this is an old thread, but is it allowed to have multiple start symbols?
Mar 23, 2013 at 8:35pm
@DTSCode, how in the world would that work? You probably just want to have S -> S1 | S2 | ...
Mar 23, 2013 at 8:38pm
closed account (Dy7SLyTq)
yes i know i realized that. i had actually copied the original grammar so now im writing my own. i now realize after reading a tutorial why that wouldnt work. im sorry for bothering you guys
Mar 23, 2013 at 11:50pm
closed account (Dy7SLyTq)
hey do you guys know on a good tutorial that teaches me how to build a recursive parser builder? i can only find source code
Mar 24, 2013 at 6:02am
Here is a link to one of a series of videos that helped me:
http://www.youtube.com/watch?v=bV39OfzMjT8
Topic archived. No new replies allowed.