• Advertisement

• ### Popular Now

• 15
• 15
• 11
• 9
• 10
• Advertisement
• Advertisement
• Advertisement

# Gruv: Scripting Language

This topic is 4827 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

##### Share on other sites
Advertisement
I'm glad to see that you're up and running. I look forward to hearing about your progress.

Good luck and cheers.

#### Share this post

##### Share on other sites
Thanks
I'll Keep everyone updated

#### Share this post

##### Share on other sites
Do you have any examples of use?

I'm quite interested in language design, so if you have more details to share, I would enjoy reading about it.

#### Share this 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 xFunction 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

##### 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

##### Share on other sites
A lisp/python (i'd go for lisp), parser is much easier to do. * 2^infinity + 1

From,
Nice coder

#### Share this 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

##### Share on other sites
Quote:
 Original post by flangazorC 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

##### Share on other sites

• Advertisement