This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-01-11 08:18:45

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

I need help

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


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#2 2010-01-11 09:01:51

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: I need help

will noone help


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#3 2010-01-12 07:53:26

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: I need help

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.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#4 2010-01-12 08:09:09

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: I need help

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


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#5 2010-01-12 08:14:20

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: I need help

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.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

#6 2010-01-12 21:16:54

spideygallo
Scratcher
Registered: 2009-12-17
Posts: 4

Re: I need help

do you need help??<go back(  )layers>

Offline

 

#7 2010-01-12 21:26:36

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: I need help

spideygallo wrote:

do you need help??<go back(  )layers>

Highly


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#8 2010-01-12 23:10:47

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: I need help

I made a very nice parser here that interprets commands like:

Code:

ask(How are you?)

Makes: ask, How are you?

Code:

NewVar(hello?)

Makes: NewVar,hello?

Can't Paddle help you? He made a very complicated and quick calculator.


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#9 2010-01-12 23:19:42

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: I need help

He doesn't understand what cena is asking for though.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

#10 2010-01-12 23:22:34

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: I need help

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".  tongue

Last edited by Greatdane (2010-01-12 23:23:51)


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#11 2010-01-12 23:56:37

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: I need help

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".  tongue

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


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#12 2010-01-13 19:16:22

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: I need help

Right now, I have absolutely no idea why or how or what you are trying to do, like Paddle2See.  sad


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#13 2010-01-13 21:30:00

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: I need help

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


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#14 2010-01-13 22:26:58

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: I need help

Let me get this straight, you are trying to make something import C code and run it?


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

Board footer