Sign in to follow this  

Gruv: Scripting Language

This topic is 4729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well the time has come finally thanks to Pse and brandon. Ive finally become familiar with string manip. and file i/o which was the only thing stopping me from doing this project. The command based scripting language is already complete now im moving onto Gruv: A Procedural Scripting Language its similar to C and also has a Assembaly compiler also :) This project is aimed to all not only game developers but im making versions that are bare minimum to intergrate into the applications we use today and also a more complete version aimed at game development, as of now there are really not much detail on this cuz i just started planning and i havent had much sleep cuz i was working on the cbl however: It will MOST LIKELY NOT use Flex or Bison the lexer and parser will be written by me There will be two versions of code one will be straight C and the other will be Object-Oriented (C++) (for some reason i like converting things like that) There will be option flags to run the script uncompiled, or compiled which will interface between the compiled script and the virtual machine. Eventually the compiler will support optimization to optimize the code outputted by the I-Code Generator and ASM Generator. layout: Lexer->Parser->Semantic_Analyzer->I-Code_Gen->ASM_Gen->ByteCode_Compiler |_________|_____________|_______________|________|______________________| | Symbol Table If anybody wants to help or contribute just tell me :)

Share this post


Link to post
Share on other sites
Theres a few things you oculd do with scripting, one of them is a jit compiler for your language.

One of the things you should consider.

Get your script into a tree

for eg.


Function main()
declare int x
for x = 0 to 100
two(x)
next x

Function two(variable)
print variable


You then create a tree.
The root is main, you then store that it is a function
Now its child is declare int x.
Its sibline is the function two

The roots child's sibling is tbe for
The fors child is the function call
The fors child doesn't have children or a sibling, so you go up the tree to the parent
The fors sibling is the next

The next doesn't have children, nor does it have siblings (the next line of code) so you go up one spot on the tree
Your now at main
Main's sibling is the function two
Its child is the print statement
The print statement has no children, so you go to the parent. the parent has already been processed, so you go to root.

Now you have your tree, you compile on demand.

So when you execute, you go and compile the decleration, you go your register/memory assignment, and you onto the next line.
You then compile the for,
Which is then turned into vm code
The vm code is stored on the tree so it doens't have to recompile
You then execute it, and keep going until it jumps somewhere where it hasn't been compiled. you compile the subtree.

Now, you also shove a counter on each spot on the tree, which records how many times execution has passed through. You also have another global counter.
What you do, is figure out which parts of the code are worth optimising, so that the time spent optimising is less then the time saved from the optimisations.

From,
nice coder

Share this post


Link to post
Share on other sites
Well im thinking of having it similar to C as of now it WONT be object oriented
basically im thinking of having it be a stripped version of C

However im thinking about if i should use the tools to generate a lexer and parser...
what do u guys think
I have a better idea on how to write one by hand cuz i dont know how to use the tools at all

Share this post


Link to post
Share on other sites
C is pretty stripped down. I'm curious to know what you think could be taken out of it and still keep it useful. Maybe unions and dynamic memory allocation (or perhaps remove malloc and replace it with a garbage collected allocator).

Share this post


Link to post
Share on other sites
Quote:
Original post by flangazor
C is pretty stripped down. I'm curious to know what you think could be taken out of it and still keep it useful. Maybe unions and dynamic memory allocation (or perhaps remove malloc and replace it with a garbage collected allocator).


Well, here are some possible enhancements to C which you could do in your scripting language: proper strings instead of a char* and arrays with bounds checking.

Why would you need a separate "garbage collected allocator"? Wouldn't all the declared variables be garbage collected automatically..

Share this post


Link to post
Share on other sites

This topic is 4729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this