Author Topic: Axe Parser  (Read 551967 times)

0 Members and 6 Guests are viewing this topic.

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Axe Parser
« Reply #1725 on: February 10, 2011, 02:42:26 pm »
Those already exist ;)
Since 0.4.5, I think, although they were buggy until recently.
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Parser
« Reply #1726 on: February 10, 2011, 02:43:08 pm »
Those already exist ;)
Since 0.4.5, I think, although they were buggy until recently.

I meant how to use them xD

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Axe Parser
« Reply #1727 on: February 10, 2011, 02:48:25 pm »
Oh.

Let's say that I have this:

Code: [Select]
If A=1
    .Do something
End
If A=2
    .Do something
End
...
If A=(some_number)
    .Do something
End

This can be shortened to
Code: [Select]
If A=1
    .Do something
ElseIf A=2
    .Do something
ElseIf ...(etc.)
    .Do something
ElseIf A=(some_number)
    .Do something
End

It can be useful when you have a whole string of If statements -- it makes things easier.

However, if you use ElseIf, once one part becomes true, it skips all the other If statements.

So if I have
Code: [Select]
3->A
If A>1
    Text(10,10,Str1)
End
If A>2
    Text(10,20,Str2)
End
That would display both Str1 and Str2.
But if I have
Code: [Select]
3->A
If A>1
    Text(10,10,Str1)
ElseIf A>2
    Text(10,20,Str2)
End
That would display only Str1 because that was the first conditional to become true.
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Parser
« Reply #1728 on: February 10, 2011, 02:49:54 pm »
All I need was to be told 'ElseIf' but you made a great explanation.

Looks very good, well-explained ;D

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Axe Parser
« Reply #1729 on: February 10, 2011, 02:51:15 pm »
Really?  Guess I went a tad bit overboard <.<
Glad you liked it though.
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Parser
« Reply #1730 on: February 10, 2011, 03:34:29 pm »
Really?  Guess I went a tad bit overboard <.<
Glad you liked it though.

I always like you indent your Axe code, I've seen some code made by you and I always love it.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Axe Parser
« Reply #1731 on: February 10, 2011, 05:36:38 pm »
ElseIf is Elif

And you cant repeat elses, one else per if.

Wow, old ninja. :P I guess I should have refreshed.
« Last Edit: February 10, 2011, 05:45:44 pm by willrandship »

Offline NinjaKnight

  • LV2 Member (Next: 40)
  • **
  • Posts: 20
  • Rating: +2/-0
  • Hey! Look behind you! It's a -- (runs)
    • View Profile
Re: Axe Parser
« Reply #1732 on: February 10, 2011, 06:59:03 pm »
Are you talking about me? :P
Also, is there a way to compile a program externally?
Ninja vs. Chuck Norris == n/0. Both end with the world blowing up.

"We could use up two eternities in learning all that is to be learned about our own world and the thousands of nations that have arisen and flourished and vanished from it. Mathematics alone would occupy me eight million years."
-Mark Twain

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Parser
« Reply #1733 on: February 10, 2011, 08:00:17 pm »
Are you talking about me? :P
Also, is there a way to compile a program externally?

Nope, that's been suggested several times, but someone would have to get Quigibo's permission (and the source for Axe) to make an off-calc compiler. You can use Wabbit, though.




Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Parser
« Reply #1734 on: February 11, 2011, 12:28:22 pm »
Nope, that's been suggested several times, but someone would have to get Quigibo's permission (and the source for Axe) to make an off-calc compiler. You can use Wabbit, though.

I think he means compile a program externally, but still on calc.  Like a hook or an entry point.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Parser
« Reply #1735 on: February 11, 2011, 12:30:42 pm »
I think he means a PC compiler, but if he meant a hook... Has a hook for Axe like Celtic ever been tried?

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Parser
« Reply #1736 on: February 11, 2011, 04:58:13 pm »
Nope, that's been suggested several times, but someone would have to get Quigibo's permission (and the source for Axe) to make an off-calc compiler. You can use Wabbit, though.
I think he means compile a program externally, but still on calc.  Like a hook or an entry point.
That's what I thought too. :D

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Parser
« Reply #1737 on: February 12, 2011, 12:09:52 pm »
Ooh, in that case I've wanted it for a while now. Feature request! :D
« Last Edit: February 12, 2011, 12:10:02 pm by Deep Thought »




Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Axe Parser
« Reply #1738 on: February 12, 2011, 02:58:26 pm »
Code: [Select]
If A=1
    .Do something
End
If A=2
    .Do something
End
...
If A=(some_number)
    .Do something
End

This can be shortened to
Code: [Select]
If A=1
    .Do something
ElseIf A=2
    .Do something
ElseIf ...(etc.)
    .Do something
ElseIf A=(some_number)
    .Do something
End

Just to clarify, this would not shorten the code, but actually make it larger since they work in 2 different ways.  The elseif is actually the same as this:
Code: [Select]
If A=1
    .Do something
    Goto E
End
If A=2
    .Do something
    Goto E
End
...
If A=(some_number)
    .Do something
End
Lbl E

So you should ONLY use elseif's if you need to enforce that exactly one of the statements will execute.  In your example, the regular if statements are smaller because you're already guaranteed that A can only hold a single number.  However, its true that the elseif is faster since it only needs to check conditionals until it finds the true one instead of checking all of them.
« Last Edit: February 12, 2011, 03:00:46 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Axe Parser
« Reply #1739 on: February 12, 2011, 07:54:10 pm »
So double post I guess:

The next beta has arrived!  :) In case you were wondering, the new axiom is called "MemKit" can can be found in the "Tools" section of the zip file.   The developer information for developing your own axiom is in the "Developers" section.  Since the Axioms are new I expect bugs, so please report them if you feel that something is not working the way it should.  Haven't found any yet though.

Edit: Actually I did hehehe....
« Last Edit: February 12, 2011, 08:01:01 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!