Utter coolness (my interpreter)

Started by
13 comments, last by GameDev.net 19 years, 3 months ago
I found the name of the book:

"C/C++ Annotated Archives" Although the reviews vary, I don't see why the code wouldn't be a good place to start/review...

Please excuse the lack of a real link.

http://www.amazon.com/exec/obidos/tg/detail/-/0078825040/qid=1108044207/sr=1-1/ref=sr_1_1/103-5009308-7389404?v=glance&s=books
Advertisement
Quote:Original post by CoffeeMug
You might want to take a look at DotLisp.


Yea, I have seen this and dotScheme also. I wanted to roll my own as a learning experience, I figure it couldn't hurt.
I don't mean to offend, but I think that's a bit of a cop out. You could be using Scheme or Lisp, but instead you are still going to program with what you are comfortable with but trying to convince yourself that you are somehow going to understand the power of Scheme.

I think you should just get another project that is suitable for Scheme and just do it in Scheme.

How about a directed common subgraph detector. Take a directed graph and find subgraphs that have a lot in common. This could mean that they have a common idea. I could really use your algorithm when you're done with it. :)
Quote:Original post by CoffeeMug
Ok, so this may not be much for you people who write your own compiler every day, but for me it's a pretty cool achievement. I decided to write a language that would allow me to extend and script my graphics framework as well as type commands at runtime. Here's what I have so far (after four days of work, spending about one hour every day):
*** Source Snippet Removed ***
Essentially a calculator with variables. All that's supported at the moment is add (+), sub (-) and let (assignment). The interpreter already supports macros and functions under the hood, I just have to expose them to the language. I decided to use s-expressions because they're trivial to parse (I hate parsers!) and allow for pretty amazing macro functionality. I will soon add support for logic, functions, conditionals, and of course loops. After that I plan to expose the macro functionality as well as creating lists and preventing evaluation. From there I have a basic lisp interpreter! I can implement the rest of the language constructs in the language itself!

Compiler class was not a requirement in my uni. Oh well, better late than never. I'm having a blast doing this, I just wish I had more time. I decided to use boost.variant to implement the lists in the interpreter and it made my code incredibly ugly. I'll have to refactor it later. Or may be I'll just let it be, add more constructs and then write a new compiler in the language itself! I encourage everyone who didn't tackle this yet to do it. First, you'll have a blast creating your own language. Second, you'll get a chance to learn Lisp. Third, you'll have a great language to use for your future projects. And the bast part: you wrote it yourself!







This is the trival part.

What do you have for objects (access to elements/attributes, definitions - including parameter substitution, etc..)

tests of Arithmetic ops/ comparator ops / Boolean ops / Bitmask ops


For Control structures ??? (if-then-else and other sequential flow mechanisms)

Lists/arrays iterators (for loop processing actions)

Mapping data in.out from the app data ???


Believe me, it gets alot more complicated for a useful lanquage.

Ive done this more than once and the features grow like a monster...




You mention 'compiler' -- then a bytecode system ......








Quote:Original post by CoffeeMug
Yeah, it looks similar due to s-expressions and will have some similar features. Yesterday I checked the size of the .lib file that implements the features above and it's already 17(!) megs in release mode. Man, heavy template use sure does increase the size. Most of that is thrown out during linking the executable but this is still not acceptable. I guess I'll use the current interpreter as a bootstrap to create a self-hosting compiler.





?????? ACK!!!!! does your file link in the entire OPSYS library set???


Something like this should fit in 50K .....


CodeBloat Alert, Will Robinson......

This topic is closed to new replies.

Advertisement