Sorry if its in wrong place.
Can anybody suggest me how to programm a programming language in scratch plz i need it for a game so be quite reasonable as huge programming language will kill the game and also the language should be type based i will give credits to the one who helps even giving a link will do.
For now i can programm
Conditional Operator (if and else)
For loop
Variable Declaration
well i know thats all it needs for the game but i need a compiler actually
like to compile
void main()
{ var i = 0 ;
for ( int k;k<2;k++)
{ i = i+1;
}
show<<i;
}
now i want something to compile
as execution works as this
it declares a couple list called RAM(he he a virtual solution of lack of pointer) and Index.
Index stores the name while RAM stores the DATA when u call a value it first finds it in INDEX and then reads it from RAM.
so when u do something like this
if x = y;
it searches for x&y in index and then reads value if they are equal then it gives equal anyone can suggest how to build a compiler to simplify that into some faster processing version.
The current compiler is like
from a list called program it divides all the commands condition into separate entities of a list
like the above example is compiled in terms of
if
x
=
y
%-this tells it where to give up a thread
PLZ HELP
Offline
I guess I'm not totally clear on what areas you are looking for help on. Can you break it down into smaller parts? I'm guessing you are trying to make something like this:
1. Obtain a list of computer commands in a "C" like sytax, maybe just use the Import
feature initially to expand later into a IDE of some sort.
2. Parse each line into variables, operators, command parts and construct a data
representation in Scratch of the program, probably using a large list.
3. Run the program by processing the Scratch representation of the program,
displaying output and requesting input as needed.
Step 2 is the tough one...It's not hard to write a routine to parse out a command line but turning it into essentially machine code is not something I have tried. Do you have a textbook on compiler design? That might be a good place to start.
You've probably already looked at the Wikipedia article http://en.wikipedia.org/wiki/Compiler but it will give you an idea of the complexity of the task you are trying to take on. Maybe you should start a level lower and write an Assembly language processor (an Assembler) http://en.wikipedia.org/wiki/Assembly_language and then work up later to a higher level compiler.
Offline
Hmm thanks a lot sir but actually what i want to do is actually make a c++ compiler and executer quite like virtual c++ thanks for the assembler idea i think of using scratch macros for call functions now thanks a lot for guiding me once again
Offline
So you want to create a programming language as a project in scratch? Like you start it up, and then type some things in using the 'ask', then it puts it together like a real programming language? That sounds difficult, but I'll look into it.
Offline
do you need help??<go back( )layers>
Offline
I made a very nice parser here that interprets commands like:
ask(How are you?)
Makes: ask, How are you?
NewVar(hello?)
Makes: NewVar,hello?
Can't Paddle help you? He made a very complicated and quick calculator.
Offline
He doesn't understand what cena is asking for though.
Offline
One solution is instead of this:
start program() say "" show goto x(0)y(0) say "Hi There!" for 2 say "Byeeeeee!" wait(2) hide say"" end program()
Is to make each line seperate, and then you don't need to compile, etc.
start program() say" <<null>> " show goto x y( 0 0 ) say for( Hi There! 2 ) say" Byeeeeee! " wait( 2 ) hide say" <<null>> " end program()
Each input is a seperate line. It is much longer, but so much more effective. What's REALLY cool is that you can edit things in notepad, import them into Scratch, and run them much more easily. That way, you have a "multi-IDE language".
Last edited by Greatdane (2010-01-12 23:23:51)
Offline
Greatdane wrote:
One solution is instead of this:
Code:
start program() say "" show goto x(0)y(0) say "Hi There!" for 2 say "Byeeeeee!" wait(2) hide say"" end program()Is to make each line seperate, and then you don't need to compile, etc.
Code:
start program() say" <<null>> " show goto x y( 0 0 ) say for( Hi There! 2 ) say" Byeeeeee! " wait( 2 ) hide say" <<null>> " end program()Each input is a seperate line. It is much longer, but so much more effective. What's REALLY cool is that you can edit things in notepad, import them into Scratch, and run them much more easily. That way, you have a "multi-IDE language".
![]()
Actually i want a converter to convert c syntax to that level my language is like virtual C++ it understands line by line but a programmer of C++ types as he is used to so i think of making a converter \ assembler
Offline
ok so listen i want a game in which u program in a language due to my background i choose c and also its too limited to program the game is called THE HACKER RPG . now does this makes a sense or should i send u the executer script in a byob file
Offline