Writing a scripting language
How do you write your own scripting language? I mean, do you have to use tools like lex and yacc? Or can you just write it in C/C++?
The language itself is an abstract concept that you decide on. A program which makes use of that language is made just like any other program, although software such as Lex and Yacc help to automate some of the well-understood stages of using a language (such as lexing and parsing).
Keep one thing in mind: Implementing a non-trivial scripting language directly in C++ will be much harder than learning and using tools for lexing and parsing such as lex and yacc.
i wrote my own compiler system in less than 3 weeks
its not complete, but its extremely usable.
check it out, its on these forumns (Tribute BASIC; in the
scriping and mod forumns)
its not complete, but its extremely usable.
check it out, its on these forumns (Tribute BASIC; in the
scriping and mod forumns)
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)
http://www.silvermace.com/ -- My personal website
http://www.silvermace.com/ -- My personal website
Quote:
Original post by silvermace
i wrote my own compiler system in less than 3 weeks
its not complete, but its extremely usable.
check it out, its on these forumns (Tribute BASIC; in the
scriping and mod forumns)
realy?
i have had people tell me that it isnt posible
im not saying its a miracle language or anything, but there
is very little it can't do - and those will definatly be addressed in the next release in 2 or so weeks
check it out.
http://www.gamedev.net/community/forums/topic.asp?topic_id=270108
PS. I'm not kidding about the 3 weeks, it will be 3 weeks on
thursday (tommorow here in NZ)
is very little it can't do - and those will definatly be addressed in the next release in 2 or so weeks
check it out.
http://www.gamedev.net/community/forums/topic.asp?topic_id=270108
PS. I'm not kidding about the 3 weeks, it will be 3 weeks on
thursday (tommorow here in NZ)
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)
http://www.silvermace.com/ -- My personal website
http://www.silvermace.com/ -- My personal website
Quote:
Original post by Sneftel
Keep one thing in mind: Implementing a non-trivial scripting language directly in C++ will be much harder than learning and using tools for lexing and parsing such as lex and yacc.
To be honest I found it easier to write a simple recursive descent parser than to work out how lex and yacc work, and that was with a background in Backus-Naur form and various grammars. Those tools are awkward and poorly-documented in my opinion. But maybe others find it to be the other way around.
Quote:I haven't finished my scripting language yet(and I'm not even sure I will), but so far I've found it extremely easy to manually create a recursive descent parser as well. I implemented a tokenizer without any assistance, and after reading a few chapters in the dragon book I already know how to completely implement the parser (its just actually doing it that is the problem - I have a tendency to lose interest once I know how to finish something).
Original post by Kylotan Quote:
Original post by Sneftel
Keep one thing in mind: Implementing a non-trivial scripting language directly in C++ will be much harder than learning and using tools for lexing and parsing such as lex and yacc.
To be honest I found it easier to write a simple recursive descent parser than to work out how lex and yacc work, and that was with a background in Backus-Naur form and various grammars. Those tools are awkward and poorly-documented in my opinion. But maybe others find it to be the other way around.
Looking at Lex and Yacc, I find they do hardly and of the work for you really{like I said tokenizing is simple, and parsing isn't at all difficult once you have the basic idea down), and the code they make is useless except as a stand-alone program because its 'coding style' is horrendous(and I've heard people say there are some that generate nice code, but none of them look nice to me).
For making your own scripting language, I suggest reading any internet tutorials you can find (plenty on google) but also getting the "dragon book". You'll have to look in some of my past threads to get the actual title of the book because I'm being lazy right now.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Game Scripting Mastery helped me immensely in understanding the basics of parsing a script language. It's not too hard to create a basic VM and assembly-like language, however the parsing of a higher level language seemed much harder. Alex Varanese does a decent job at providing a beginner's guide to parsing, IMHO.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement