Spectacle (Programming Language) - *Update*

Everything else that doesn't fall into one of the other PB categories.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Spectacle (Programming Language) - *Update*

Post by Killswitch »

13/11/05

A brand-spanking new version or Spectacle has just been released! I've the main change is that the keywords list is defined in source, and not read from an external file. This should speed up the program a tiny bit and remove an error some of you might have experienced. There is also two new commands:

Debug
FreeVariable

Code: Select all

 'All of the following are valid!
 Debug "bob"
 Debug 1
 Debug 1.1
 Debug "bob", 1, 1.1

Code: Select all

  'Use this is if you want to free up some memory (it's not the fastest  command in the world though)
 ;Bob.s
 FreeVariable "Bob"
All of the other commands work in the same way as PB commands. 'Wait' is 'Delay', 'Rnd' is Random, 'RndF' is Random (returning a float), and 'Seed' is a command to set the seed of the Random number generator.

Hopefully you'll find spectacle more useful as you now have a debugger!

DOWNLOAD HERE

12/11/05 - Update

Edit: You are free to use all or part of Spectacles source so long as you GIVE CREDIT for it!

Well I've been working on Spectacle (a BASIC programming langauge written in PB) for well over a month now and I thought it's about time I relased an alpha, as I'm quite proud of how the langage is progressing!

This is more of a sneaky-peak relase, as many parts of the language are incomplete (such as the debugger, and many command sets). I've introduced a new feature: Result Warping. I don't know about you, but I really get annoyed having to use Str(), Val() (etc) lots and lots of times. So, with specticle you can define a return type of a command, in the same way you'd define a variables type!

Here's some code exaples:

Comments

Code: Select all

 Rem This is a comment

 Command Arg1,Arg2 Rem this isn't a valid comment 

 RemStart
   This is a comment
   This is a comment
 RemEnd

 'This is a comment

 Commadn Arg1,Arg2 'This is a valid comment
Maths

Code: Select all

 ;Bob.s
 ;Bob="bob"
 ;Jim.l=123+1
 DEF.l Tim, Kim
Operators

Code: Select all

+
-
*
/
^
<>
<=
>=
And
Not
Or
XOr
Binary, Octal and Hexadecimal support

Code: Select all

 ;%10101+7c8+0xDEADBEEF
Commands

Code: Select all

 
 Len "bob is cool"
 
 Val.l = Val "123"
 
 Bob.s = Len.s "Test" 'Will return 4 as string

Meta Expression

Code: Select all

 &Test=x+1
 ;&Test=1
 ;x.l=1
 ;&Test=2
I've also implimented a whole new, stack based, variable-handling system which has reduced memory usuage dramatically!

Here's the command set:

End
Val
ValF
Len
LCase
UCase
Right
Left
Asc
Chr
RTrim
LTrim
Trim
Space
Binary
Hex2Bin
Oct2Bin
Bin2Hex
Bin2Oct
hex2Dec
Oct2Dec
ElapsedMilliseconds
Wait
Rnd
RndF
Seed

I'd still like some help with the project, as well as ideas and comments! contray to what I've said before the source is avaliable as it's easier to see whats going on with it than the .exe.

To Spectacle code you must write your soure in a file called 'Code.txt' in the same directory as either the .exe or Main.pb (depending on how you want to run it).

The exe will probally look like it's doing nothing - that's why the source is included!

DOWNLOAD
Last edited by Killswitch on Sun Nov 13, 2005 10:54 pm, edited 4 times in total.
~I see one problem with your reasoning: the fact is thats not a chicken~
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Hey looks like it might be cool - thx for shring the source.

When I run the exe I get "could not read keywords file"

cheers
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Ah, just move the .exe into the same directory as Main.pb - I've changed the .zip folder so this isn't an issue any more.
~I see one problem with your reasoning: the fact is thats not a chicken~
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

I don't like the style of procedures without () sorry
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

You're too used to PB, 'real' BASICs don't have the () format! :P
Last edited by Killswitch on Sat Nov 12, 2005 7:50 pm, edited 1 time in total.
~I see one problem with your reasoning: the fact is thats not a chicken~
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

Yeah I really like that PB isn't that far away form c and c++ :D
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Is this is an interpreter?
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

It is indeedy, but it's quite speedy :shock:. I'd like to make a compiler, but I don't know how :( . Thanks to PB it interprets code amazingly quickly, in fact I tested my expression solving functions against PBs internal expression solving functions, and the average difference over 1000 tests was less than 150ms, most of the time it was about 30ms and a few times it was less than 20ms!
~I see one problem with your reasoning: the fact is thats not a chicken~
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

This is great, thanks for sharing the source! :)
I like logic, hence I dislike humans but love computers.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Killswitch wrote:I'd like to make a compiler, but I don't know how :( .
It's not as difficult as people say. Simply output the appropriate assembly instructions instead of actually DOING. For example when you parse a this statement in your interpreter:
apple = 5*banana

you must first store apple somewhere so that you remember what you should put the expression into after you've solved it. You need to that for the compiler, too.

Then you multiply 5 by banana. Simply output the assembly instructions for a multiply instead of actually DOING the multiply.l

Then you output the assembly instructions to move the result of your multiply into apple. Very simple! (In theory only of course.)
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

I was exaggerating a bit before I knew all I had to do was output the ASM instructions then use a free ASM compiler to create a .exe but I don't know any ASM. This is the main reason why I'd like some help - to turn the interpreter into a compiler.
~I see one problem with your reasoning: the fact is thats not a chicken~
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Killswitch wrote:I was exaggerating a bit before I knew all I had to do was output the ASM instructions then use a free ASM compiler to create a .exe but I don't know any ASM. This is the main reason why I'd like some help - to turn the interpreter into a compiler.
Other thing you can do is output C Code from the basic code, and then compile the C code to ASM, and them compile it to machine code :) Maybe it will be slower to compile, but it will be REALLY fast (as fast as... guess what ;))
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Guess what, I don't know any C either! :( Would anybody here be interested in helping create a compiler?
~I see one problem with your reasoning: the fact is thats not a chicken~
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Killswitch wrote:I was exaggerating a bit before I knew all I had to do was output the ASM instructions then use a free ASM compiler to create a .exe but I don't know any ASM. This is the main reason why I'd like some help - to turn the interpreter into a compiler.
You should really learn some. It's not as difficult as you might think. Also, you only need to know a _very_ tiny bit to make a pretty complete compiler.

It's not really difficult, the difference between a very basic BASIC and ASM is that in ASM there is no expressions. You need to break every expression down into instruction with two operands. And there is no IF/WHILE, etc, only labels and goto.

I've added this tool in my tools menu, it's very handy for showing the assembly output of the PureBasic compiler. You only need fasm for windows installed if you want syntax highlighting (highly recommended).

Code: Select all

RunProgram("pbcompiler", ProgramParameter() + " /COMMENTED", "", 1)
RunProgram("c:\programfiler\PureBasic\Compilers\PureBasic.asm")
Really, simple, but very useful. In the parameters field type %TEMPFILE. You need to have pbcompiler in path of course, of you can fill inn the absolute path.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Killswitch wrote:Guess what, I don't know any C either!
How about FORTRAN? It's extremely simply to learn. And if you've got Dev-C++ installed you've got a FORTRAN compiler disguised as g77.exe in the bin directory.
Post Reply