MochaBASIC (Switch Compiler)

Developed or developing a new product in PureBasic? Tell the world about it.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

MochaBASIC (Switch Compiler)

Post by Killswitch »

[Edit] Nuts, this was supposed to be in the annoucments forum - can someone move it please? Thanks!

After many more hours hammering out code I've added some new functionality to my compiler and given it a new name!

Just as a recap Mocha is a Basic > FASM compiler which I've writeen from scratch, it supports:

Operators

Code: Select all

  + - * / ( ) / ^


Variables

Code: Select all

  Long.l
  Float.f
  String.s
Constants *New*

Code: Select all

  #Number=1
  #String="constant"
Structures *New*

Code: Select all

  Structure Test
  {
    Long.l
    Float.f
    String.s
  }

  MyVariable.Test
  MyVariable\Long=1
Enumerations *New*

Code: Select all

  Enumeration
  {
    #Constant1
    #Constant2
    #Constant3
   }
Inline ASM *New*

Code: Select all

  ASM
  {
     Mov eax,1
     ;Essentially this code block is ignored by the compiler - so no error checking is performed
   }
As before write your code in Code.txt and run Compiler.exe - don't worry about Optimizier.exe as it is run automatically. Code written between the ASM braces is subject to the optimizer as well.

A small note on brace syntax. The following are all ok (using Enumeration as an example, but applicable to all):

Code: Select all

  Enumeration {
    #Constant
  }

  Enumeration 
  {
     #Constant2
   }

   Enumeration{
     #Constant3
   }
   
   Enumeration
   {
     #Constant4 }
You can do a bit of mixing and matching - open and close braces on the same line result in a syntax error.

Enjoy!

DOWNLOAD
~I see one problem with your reasoning: the fact is thats not a chicken~
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

You know, your compiler gets better and better with each release. .. I love {}
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Let's hope I continue the trend :D. I'm considering what I should put into the next release, either conditional statements and loops OR some actual commands. Who'd like to see which?
~I see one problem with your reasoning: the fact is thats not a chicken~
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Great job! When it will be ready, I'll use it next after PureBasic :).

[Edit]
Both conditional and some commands :D. Just joking. I guess it's better to add some loops and conditionals. It's better to finish the structure first, than add a command set ;).
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Inf0Byt3 wrote:Great job! When it will be ready, I'll use it next after PureBasic :).

[Edit]
Both conditional and some commands :D. Just joking. I guess it's better to add some loops and conditionals. It's better to finish the structure first, than add a command set ;).
I agree

ps: great stuff. But I'd call it MOCCA instead of MOCHA ..
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Edit: Hang on are you sure MOCCHA is the correct spelling?

Damnit. My bad spelling is the root cause of like 60% of all the bugs in my code, I should really do something about it.

Note: I've edited the name of the file, thread etc dagcrack isn't mad :P
~I see one problem with your reasoning: the fact is thats not a chicken~
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

and i was thinking you were calling it MACHObasic :-)
Last edited by blueznl on Mon Apr 10, 2006 4:39 pm, edited 1 time in total.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

You don't want to make the Pineappliser angry.....<<<

:P
~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 »

I know you've stopped working on this, but...

I was just messing around with it to see how you did the strings and to see the quality of the generated code, and I can't get the strings to work.

I do it like this:

Code: Select all

MyString.s
MyString = "Whatever"
By the way, don't stop working on this because you don't know enough ASM. All the ASM I know I've learned by working on my compiler.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

I've had to update the code so it works in PB 4.0, so I've included what I've used here (Main - Compiler.pb is the one to run).

I can't seem to recreate the problem you had though, can you explain what problem you had a little bit more?

P.S I've decided to move from FASM to HLA (which can compile into FASM), and that's making progress a lot easier.
~I see one problem with your reasoning: the fact is thats not a chicken~
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Killswitch wrote:P.S I've decided to move from FASM to HLA (which can compile into FASM), and that's making progress a lot easier.
Which hla version? 1.x or 2.x

IIRC version 1.x is no longer in development, and 2.x doesn't compile to other assemblers anymore but creates native exes.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Killswitch wrote:I've had to update the code so it works in PB 4.0, so I've included what I've used here (Main - Compiler.pb is the one to run).

I can't seem to recreate the problem you had though, can you explain what problem you had a little bit more?

P.S I've decided to move from FASM to HLA (which can compile into FASM), and that's making progress a lot easier.
When I used the code I posted above with the version of Mocha from the first post I get the following error: Line: 3. Can't write a float into a variable of this type.

I don't have the problem with the other version you uploaded, though.

I get so confused every time I read HLA code because it puts the last operand first. So mov eax, b in fasm becomes mov b, eax in HLA.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

I was using 1.x, I didn't realise there was a 2.x version out - I'll have a look for it now, but (just in case) do you happen to have a link?
~I see one problem with your reasoning: the fact is thats not a chicken~
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Killswitch wrote:I was using 1.x, I didn't realise there was a 2.x version out - I'll have a look for it now, but (just in case) do you happen to have a link?
Well the official release didn't happen yet, but source code, binaries and documentation are already available.
Here the homepage:
http://webster.cs.ucr.edu/AsmTools/HLA/hla2/0_hla2.html

Version 1.x is AFAIK no longer in development.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Thanks for that mate :)
~I see one problem with your reasoning: the fact is thats not a chicken~
Post Reply