Author Topic: Axe Parser  (Read 546813 times)

0 Members and 1 Guest are viewing this topic.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Parser
« Reply #2055 on: December 10, 2011, 08:43:21 pm »
Awesome!! NEW AXE

I was the first person to download the new version :D

Now...
Is absorbing appvars like
[pic1]->pic1
but for appvars?

And what are preprocessor conditionals?

Also, what does single argument for loops can now take any expression as an argument mean?
EDIT: Oh, you mean single argument like "executes the block of code exactly a set number of times."

Also, yet another question, what is
"Now able to use Return in a single argument for loop."
:P

Edit:
Yet another yet another question is:
What does select() do? I don't get what the commands list is saying
:P
« Last Edit: December 10, 2011, 08:58:38 pm by epic7 »

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: Axe Parser
« Reply #2056 on: December 10, 2011, 08:58:51 pm »
Awesome!! NEW AXE

I was the first person to download the new version :D
And I was the second!

Now...
Is absorbing appvars like
[pic1]->pic1
but for appvars?
I believe so.

And what are preprocessor conditionals?
Instead of commenting out code like this:
...
.Code
...

You can do something like this:
...If condition
.Code
...

And it will only comment out the code if the condition is true (condition must be a constant).

Also, what does Single argument for loops can now take any expression as an argument mean?
For(A) .loop A times
used to not work (because it wasn't implemented)... now it is!

Also, yet another question, what is
"Now able to use Return in a single argument for loop."
:P
This used to be an error (because it wouldn't work):
For(10)
If A+1→A=B
Return
End
End
Now, Quigibo has found some amazing way to make it work, so it is allowed ;D.

btw, most of this info is probably in the command list ;)

Edit:
Edit:
Yet another yet another question is:
What does select() do? I don't get what the commands list is saying
:P
Select(EXP1,EXP2) finds the value of EXP1, stores it into some secret place, then it evaluates EXP2, and lastly, it looks in that secret place and returns the original value of EXP1.
For example:
Select(A,B→A)→B swaps A and B.
A is stored to a secret place, B is stored to A, then the value of that secret place (the original value of A) is stored to B.
« Last Edit: December 10, 2011, 09:06:04 pm by jacobly »

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 #2057 on: December 10, 2011, 09:02:37 pm »
Here are some cool things you can do with the new version:

Code: [Select]
prgmAA
:.A
:ClrHome
:[prgmAA]->A
:While {A}
:Disp >Tok
:A+1->A
:End
This one prints out its own source code.  Try it :P

And now 3 examples of places the Select() command can be useful.

Code: [Select]
Select(A,B->A)->BSwaps the values of A and B faster and without needing any extra temporaries.

Code: [Select]
Select(A,+1->A)This is the C style "A++" meaning it increments A but returns the value of A before you actually incremented it.
Note: A+1->A-1 is more efficient in this case, but if it was A+8 for instance, the above is better.

Code: [Select]
:Lbl FOO
:Select(r1,Select(r2,MYLBL()->A)->r2)->r1
:Return A
:Lbl MYLBL
:<stuff including more calls to FOO>
You have now created a recursive subroutine that doesn't need to be called in any special format.  Just call FOO(1,2) or whatever.  Something similar to this will eventually replace the current "recursive subroutine" because it has way more advantages:
 - You only need to save values you know are going to change.
 - Optimizes better when used more than one place.
 - Compatible with non sub() form calling.
 - You don't have to remember or get confused that a certain subroutine requires being called a special way.

EDIT:
Quote
This used to be an error (because it wouldn't work):
For(10)
If A+1→A=B
Return
End
End
Now, Quigibo has found some amazing way to make it work, so it is allowed ;D.
That was super easy.  I was already keeping track of how large the stack was.  All I had to do was pop N times for every N nested for loops (the single argument variety) prior to returning.  ;D
« Last Edit: December 10, 2011, 10:46:11 pm by calcdude84se »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: Axe Parser
« Reply #2058 on: December 10, 2011, 09:59:25 pm »
Quick question: do ...'s nest? They obviously can't normally (start and end are indistinguishable) but with preprocessor conditionals they theoretically could.  Not that I need it yet, but it would be a good thing to know.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Parser
« Reply #2059 on: December 10, 2011, 10:17:16 pm »
Jacobly did
Select(A,B->A)->B
Instead of what Quiggs did,
Select(A,B->A)->A
To swap a and b

Which one works?
If you did
Select(A,B->A)->A
Wouldn't it store B to A, and then restore A's old value back to A, making it do nothing?

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 #2060 on: December 10, 2011, 10:41:48 pm »
Select(A,B->A)->B is the correct one.

Quigibo, is there a "...End"?  (There isn't one on the commands list, though it looks like there should be one.)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Parser
« Reply #2061 on: December 10, 2011, 10:42:46 pm »
No need for ...End, because ... already ends the comment block whether or not it's a conditional.
« Last Edit: December 10, 2011, 10:42:58 pm by Runer112 »

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Parser
« Reply #2062 on: December 10, 2011, 10:44:21 pm »
I believe he said it wouldn't need one.  (ninja'd)

And for the select() part, Thats what I thought. (-Use ->B)
Quigibo, you should fix that post :P
« Last Edit: December 10, 2011, 10:45:42 pm by epic7 »

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Axe Parser
« Reply #2063 on: December 10, 2011, 10:48:21 pm »
Or have someone else fix it for you! (I just fixed it)
I take it that "constant" means any expression that lacks variables? So I could, say, do "...If °A>L6"?
« Last Edit: December 10, 2011, 10:48:33 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Axe Parser
« Reply #2064 on: December 17, 2011, 11:03:02 pm »
* Freyaday saw the new Z-Select command and giggled with glee
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Parser
« Reply #2065 on: December 17, 2011, 11:04:55 pm »
Z-Select, is that the new command? Now that I have the new axe, I'll se what that does.

I love the new awesome progress bar! I compiled multiple times so I could watch it :P

* epic7 was the first downloader for this version, too :P

Wait there's a Z-select, Frey?
I just saw Z-Test.
I don't fully understand, but does this work?
Z-Test(A=1,Lbl 1, Lbl 2)
Does that mean
If A=1
Goto 1
Else
Goto 2
End
Or something like that?
« Last Edit: December 17, 2011, 11:15:03 pm by epic7 »

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 #2066 on: December 17, 2011, 11:19:20 pm »
So surprise surprise, I added a switch statement last minute, it took me under an hour to have it fully functional.  Its also probably the only new feature this version that needs a tiny bit of explaining.

So basically, Z-Test() is a command to built what's called a "jump-table", or if you prefer, a "goto-table".  It basically creates an array of places to "jump" to and then jumps to the Nth item in that list.  That's about it.  The reason this is useful is that otherwise, you have to do something like:

Code: [Select]
:If A=0:
:<code>
:ElseIf A=1:
:<code>
:ElseIf A=2:
:...and so on...

So when you have a lot of consecutive comparisons, it saves a lot of space in the program.  But the best part is the speed savings.  Normally, you would have to make N comparisons (or log(N) if you're smart :P) in order to figure out which of N pieces of code to execute.  This method however, makes a single comparison!  So no matter how large your jump table is, it always takes the same amount of time to get to the code you want to run.

All of this fun is overhead though, and I will say you should only switch over to a Z-Test() if you have 4 or more cases to check against, otherwise it could be larger and slower.

If you want this to be a call table instead of a jump table, simply put it in a subroutine and call it:

Code: [Select]
:MyTbl(A)
:
:Lbl MyTbl
:  Z-Test(r1,A,B,C,...)
:  <handle errors>

The error handling is for when the number you're testing is outside the range of the table.  This isn't necessarily an error if you're going to use that  to your advantage, but its a good sanity check to have if you're expecting the number to be in the range of your labels.  If you are absolutely positively sure your number is in this range (like you just read a nibble which is always in the 0-15 range and you have 16 labels) then you don't need any code there.

Also as I was typing this, I just realized I forgot to show an error when you try to use this in a For(expr) loop.  DO NOT USE Z-TEST HERE!  You will get a memory leak and eventually a ram clear.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Parser
« Reply #2067 on: December 17, 2011, 11:21:33 pm »
Cool! I did those repeating else if's 17 times in 2 places for RoboGun O.O

So
Z-Test(A,1,2,3
Would go to Lbl 1 if A=0, Lbl 2 if A=1, and so on?
« Last Edit: December 17, 2011, 11:29:38 pm by epic7 »

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 #2068 on: December 17, 2011, 11:26:26 pm »
Exactly :)
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: Axe Parser
« Reply #2069 on: December 17, 2011, 11:28:32 pm »
I think the big thing to note about this feature is that values start from zero.
That is, when A is 0, the first label is jumped to; when A is 1, the second label is jumped to, and so on. :)

I'm still slightly confused myself - is this a Lbl within a Lbl?
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)