Advertisement

Needed: lisp parser

Started by December 04, 2003 11:44 PM
5 comments, last by Benjamin Heath 20 years, 11 months ago
WITHOUT ADO: Just point me to an open-source lisp parser. WITH ADO: First off, I have an announcement about my team: My best friend, Phil Sorem, and I just had the first programming session for our game after months of just talking about it. We made so much progress in just that one day that I haven''t stopped thinking about the code since! We''re getting the team together right now and setting everything up. In six months to a year from now, we''ll hopefully have something for you to see! (Man I''m excited!) I just had to say that, man, because... I''M FINALLY MAKIN'' A VIDEO GAME!!!! YEEEEEEEEEAAAAAAAAAH! Okay, the coding is going well. I have the (compact) program structure all in mind. What I need now is a parser for Lisp. It has to be open-source, because our games will be open-source. (I''ve got plans, ya know...) The program has to load in a lisp script at runtime, parse it, and dynamically compile it to byte-code in work memory. Then you''d have script register structures that have things like a pointer to the script''s byte-code, the current instruction, et cetera. Then your game objects have a pointer to a script register structure. At every frame, the active game objects are processed and their script''s byte-code is interpreted. Because of this structure, there may be multiple instances of the same script, even though the script may be in memory only once. I''ve chosen Lisp because it''s easy, it''s fun, and it won''t be hard to show to get my team to use it. PS: Our first game will be an R-Type clone. After that, I plan on a some games that are inspired by (but not clones of) Metal Gear, F-Zero, and one game about superheroes. PSS: I''ve been programming for 5 years and I keep everything simple. Don''t worry. ================== Benjamin Heath ==================
Do you mean a Lisp interpreter, an open-source parser specification ala Yacc file, or actual code to take token stream and reduce it an AST?

Any hoo for the first one, Corman Lisp, while not-open source, is free (as in beer) for non-commercial use. ( http://www.cormanlisp.com/index.html )

GCL is the GNU project''s Common Lisp implementation (obviously open source). http://www.gnu.org/software/gcl/gcl.html
Advertisement
I was thinking of a yacc file. I don''t want an interpreter with the program structure I have in mind, and everyone knows you don''t ask someone to do your homework for you.

I need the parser to do its job and that''s it. I''ll do the rest.



==================
Benjamin Heath
==================
Abuse used Lisp for its game logic. You can download the source for free. I don''t know if they used lex/yacc but maybe you can use it as a start. I think the source code is under the GPL.
Yeah I have that on hand. I was just looking at it and thinking about using that. I dunno though.

Okay, I''ll just rephrase my question: If you were to write a program to import a script and compile it to an array of instructions in memory, how would you do it?

I''m not asking for code, but I am interested in some ideas. The language of the script is variable and does not matter. The same goes for where or how the instructions are put in memory, and what an instruction is exactly. An instruction could be a data structure or an integer. (If C++/OO is your thing, just think in templates. That''s kind of what I''m talking about.)

I like to keep that flexibility because of the Unix Rule of Diversity, which states that there is no best and only way to do something. Understand? I have some ideas too, but please, what would you do?



==================
Benjamin Heath
==================
I used Common Lisp the Language, 2nd Edition as a guide and just built one from scratch. I haven''t finished it yet, but Common Lisp is such a simple language that parsing it isn''t at all difficult. All you need is an array containing the properties for each character and then a few simple loops, branches, and flags is all you need in the main read loop. Eval is also really easy, you just have a few loops and recursive calls and thats it. If you want to implement the full language, its a little more difficult, but not much.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Advertisement
quote: Original post by Extrarius
I used Common Lisp the Language, 2nd Edition as a guide and just built one from scratch. I haven''t finished it yet, but Common Lisp is such a simple language that parsing it isn''t at all difficult. All you need is an array containing the properties for each character and then a few simple loops, branches, and flags is all you need in the main read loop. Eval is also really easy, you just have a few loops and recursive calls and thats it. If you want to implement the full language, its a little more difficult, but not much.


Thank you! ''Preciate that Extrarius! I''ll be working on the byte-code compiler for our next games, and in the meantime, the simple games we''ll write will simply be written in C. It''s not that hard to do it, but it will be more work on my part, so the games will remain simple until the compiler is stable and functional.

The work will progress!



==================
Benjamin Heath
==================

This topic is closed to new replies.

Advertisement