Author Topic: BBify: syntax-color your Z80, TI-BASIC, Axe, and Lua  (Read 38970 times)

0 Members and 1 Guest are viewing this topic.

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: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #30 on: August 04, 2011, 06:27:19 pm »
AWESOME UPDATE:

Idea: What about one for Axe? I'm starting to work on it (it doesn't work yet).
Can you make it in a way it uses XML files or something like that, so it's easy to make it for all languages?

Guess what? Done!

I don't have time to post the specs right now, but here's the z80.xml (default) set. See if you can understand it, and I'll post more info tomorrow.

Enjoy!

EDIT: Hint: it uses my regex parser that uses <#> for backreferences.
« Last Edit: December 18, 2011, 10:16:34 pm by Deep Thought »




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #31 on: August 04, 2011, 06:46:40 pm »
Nice update Deep Thought :)

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #32 on: August 04, 2011, 07:29:46 pm »
It's a great tool. I already used it a few times when i posted asm source code.

BTW: those terms and conditions, I don't really know how you can agree with them :p
And nobody has said anything abouth this. I think nobody here checks them.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

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: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #33 on: August 05, 2011, 01:34:57 pm »
It's a great tool. I already used it a few times when i posted asm source code.
w00t, its actually being used \o/

Don't forget to post any bugs you come across! :)

EDIT: Update: made it a dozen times faster and accepting multi-line comments!
« Last Edit: August 05, 2011, 03:26:53 pm by Deep Thought »




Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #34 on: August 05, 2011, 03:49:24 pm »
Nice Deep :)

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: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #35 on: August 05, 2011, 04:52:44 pm »
If anyone's interested, some info on the XML:
The XML file should be wrapped in a single <scheme> tag, containing one or more <rule> elements that defines a replacement rule. Each <rule> is parsed one by one, so order is important.

Each <rule> tag has one <f> element and one <r> element, both containing one CDATA section with a preg regex inside. <f> defines the pattern to search for, and should be wrapped in the appropriate delimiters. (Remember that all &, <, and > chars are HTML-escaped.) <r> contains the replacement text, using <#> for backreferences (no escaping since it's in a CDATA).

Here's an example (the default z80.xml):
Code: [Select]
<?xml version='1.0' encoding='UTF-8'?>
<scheme name="Z80 Assembly">
<rule>
<f><![CDATA[#\['"]#]]></f>
<r><![CDATA[<0>]]></r>
</rule>
<rule>
<f><![CDATA[#['"].*?['"]#i]]></f>
<r><![CDATA[[color=$num]<0>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#&[lg]t;|[+\-*/%~=!&|^]#]]></f>
<r><![CDATA[[b]<0>[/b]]]></r>
</rule>
<rule>
<f><![CDATA[#;.*#]]></f>
<r><![CDATA[[i][color=$com]<0>[/color][/i]]]></r>
</rule>
<rule>
<f><![CDATA[#\$[\dA-F]+\b|\b[\dA-F]+h\b|%[01]+\b|\b[01]+b\b|(?<!\<)\b\d+\b(?!\>)|\$|\*#i]]></f>
<r><![CDATA[[color=$num]<0>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#\.\w+|\bEND\b|^\s*\#(define|defcont|if(n?def)?|else|endif|include)\b#i]]></f>
<r><![CDATA[[color=$pre]<0>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#^\s+(exx?|ld([di]r?)?|pop|push|ad[cd]|cp([di]r?|l)?|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr](a|ca?|)?|sla|sr[al]|call|djnz|j[pr]|nop|ret[in]?|rst|[de]i|halt|im|in([di]r?)?|ot[di]r|out[di]?|b_?(call|jump))\b#i]]></f>
<r><![CDATA[[b][color=$ins]<0>[/color][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#\b([hl][xy]|i[xy][hl]|slia|sll)\b#i]]></f>
<r><![CDATA[[b][s][color=$err]<0>[/color][/s][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#\b(a(f'?)?|b(c'?)?|d(e'?)?|h(l'?)?|[celr]|i[xy]?)\b#i]]></f>
<r><![CDATA[[b][color=$reg]<0>[/color][/b]]]></r>
</rule>
</scheme>




Offline Spyro543

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1189
  • Rating: +74/-3
    • View Profile
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #36 on: August 05, 2011, 06:31:34 pm »
Here's what I learned of assembly by looking at other's code (really this is all I know how to do in assembly):

; I'm using what I learned by looking at other's codes.
; I know how to make comments in z80 now!

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #37 on: August 05, 2011, 06:50:34 pm »
Here's what I learned of assembly by looking at other's code (really this is all I know how to do in assembly):

; I'm using what I learned by looking at other's codes.
; I know how to make comments in z80 now!

Next lesson: Nop = do nothing.  :)
ld a, 0
ld a, a

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: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #38 on: August 05, 2011, 11:07:24 pm »
Here's what I learned of assembly by looking at other's code (really this is all I know how to do in assembly):

; I'm using what I learned by looking at other's codes.
; I know how to make comments in z80 now!
Why is that ! bolded ???




Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #39 on: August 08, 2011, 05:19:35 am »
Next lesson: Nop = do nothing.  :)
Actually Nop just uses up a few cycles, so it actually does something, that something is just sitting and waiting though :P
/e

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: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #40 on: August 10, 2011, 04:12:07 pm »
whoo hoo fixed a few bugs with HTML encoding and jim's pastebin and added permalinking
EDIT: What the heck. Made it work with any page with a textarea on it!
« Last Edit: December 15, 2011, 08:32:25 pm by Deep Thought »




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: BBify: a BBCode syntax highlighter for Z80 ASM
« Reply #41 on: August 23, 2011, 06:24:56 pm »
Update (as always, located at http://clrhome.org/resources/bbify/


EDIT: Whoops, forgot to turn off ?ie in the normal BBify...
« Last Edit: December 15, 2011, 08:34:00 pm by Deep Thought »




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: BBify your Axe and Z80 code!
« Reply #42 on: August 29, 2011, 01:52:44 pm »
Sorry for the triple-post, but the BBify'r now works for Axe! :w00t:

Finished making the rules sheet for Axe syntax. Turns out it's even more complicated than ASM:
Spoiler For Code:
<?xml version='1.0' encoding='UTF-8'?>
<scheme name="Axe">
<rule>
<f><![CDATA[# |'"'#]]></f>
<r><![CDATA[<0>]]></r>
</rule>
<rule>
<f><![CDATA[#\^\^T(\w+?\(?|.)#]]></f>
<r><![CDATA[[sup]T[/sup]<1>]]></r>
</rule>
<rule>
<f><![CDATA[#".*?"?#]]></f>
<r><![CDATA[[color=$num]<0>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#^\.\.\..*?^\.\.\.|\..*?$#s]]></f>
<r><![CDATA[[i][color=$com]<0>[/color][/i]]]></r>
</rule>
<rule>
<f><![CDATA[#Asm\([\dABCDEF]{2}+\)?|(\#Axiom\(|prgm)([ABCDEFGHIJKLMNOPQRSTUBWXYZ]|theta)([\dABCDEFGHIJKLMNOPQRSTUBWXYZ]|theta){0,7}\)?|\#Icon\([\dABCDEF]{64}\)?|\#Realloc\(.*?\)?#]]></f>
<r><![CDATA[[color=$pre]<0>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#\[i\]#]]></f>
<r><![CDATA[[b][i][color=$ins]i[/color][/i][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#\[[\dABCDEF]*?\]?|Data\(.*?\)?#]]></f>
<r><![CDATA[[color=$num]<0>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#If|Else|While|Repeat|For\b|DS&lt;\b|End|Return#]]></f>
<r><![CDATA[[b][color=$reg]<0>[/color][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#(Lbl|Goto)(<\d+>[ABCDEFGHIJKLMNOPQRSTUBWXYZ]+)#]]></f>
<r><![CDATA[[b][color=$reg]<1>[/color][/b][color=black]<2>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#sub\(([ABCDEFGHIJKLMNOPQRSTUBWXYZ]+)(\)?)#]]></f>
<r><![CDATA[[b][color=$reg]sub[/color][/b][color=black][b]([/b]<1>[b])[/b][/color]]]></r>
</rule>
<rule>
<f><![CDATA[#(Pause|Disp|Store(GDB|Pic)|RecallPic|DrawInv|Horizontal|Vertical|<\d+>(and|x?or)|Text|Fix|(Un)?Archive|DelVar|FnO(n|ff)\b|LnReg|Port)<\d+>|Diagnostic(On|Off)|Full|Normal|getKey|Clr(Home|Draw)|DispGraph|Shade\b|rand|abs\b|sin\b|cos\b|e\^\b|ln\b|min\b|max\b|not\b|P(t|xl)-(On|Off|Change)\b|pxl-Test\b|Line\b|RectI?\b|Circle\b|Pt-Mask\b|Bitmap\b|rotCC?\b|flip[VH]\b|Output\b|Text\b|sign\b|nib\b|Fill\b|Copy\b|Exch\b|length\b|inData\b|Equ>String\b|SortD\b|Ans|GetCalc\b|input|float\b|FnInt\b|Stop|Port|Freq\b|Send\b|Get#]]></f>
<r><![CDATA[[color=$ins]<0>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#sqrt\(#]]></f>
<r><![CDATA[[color=$ins]&radic;[/color][b][color=black]([/color][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#\[i\]#]]></f>
<r><![CDATA[[b][color=$ins]i[/color][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#\|E([\dABCDEF]{1,4})#]]></f>
<r><![CDATA[[color=black][sub]E[/sub]<1>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#\^\^o([ABCDEFGHIJKLMNOPQRSTUBWXYZ]|theta|r[1-6])#]]></f>
<r><![CDATA[[color=black][b]&deg;[/b]<1>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#'.'|(GDB|Pic|Str)\d|L[1-6]|(?<!\<)\d+(?!\>)|b[01]{1,16}#]]></f>
<r><![CDATA[[color=black]<0>[/color]]]></r>
</rule>
<rule>
<f><![CDATA[#-&gt;#]]></f>
<r><![CDATA[[b][color=black]&rarr;[/color][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#\^\^([2r]|-1)#]]></f>
<r><![CDATA[[b][color=black][sup]<1>[/sup][/color][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#\[e\]#]]></f>
<r><![CDATA[[b][color=black]e[/color][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#&[lg]t;|[+\-*/~=!\^(),:]#]]></f>
<r><![CDATA[[b][color=black]<0>[/color][/b]]]></r>
</rule>
<rule>
<f><![CDATA[#\A.*\Z#s]]></f>
<r><![CDATA[[color=$con]<0>[/color]]]></r>
</rule>
</scheme>
For Axe, it does more than just highlight certain strings of text, like with the Z80 rules. It actually recognizes every command you're allowed to use in Axe, so it's a great way to check your syntax. It's lenient on closing parentheses and braces (since Axe Parser does that too).

Axe code should be in TokenIDE format. (I may create a new rule sheet for SourceCoder later on.) The easiest way to grab valid code to put into BBify'r:
  • Download TokenIDE from http://myserverathome.com/Tokens.zip, extract the zip, and open it
  • Under the File menu, click Change Token File and choose the AxeTokens.xml packaged with Tokens.zip
  • Open your Axe source
  • Copy and paste the code into the BBify'r, or save as a .txt file and upload
Remember to choose Axe (Tokens) as your engine. And don't worry about those weird ^^r things -- the BBify'r will automagically do replacements for you, such as ^^r to r and -> to →!

Here she is parsing the AXEGOL example program:
Quote from: Axe
.\G\A\M\E\O\F\L\
Full
DiagnosticOff
ClrDraw
For(A,33,62
For(B,17,43
If rand^2
sub(AB
End:End:End
While getKey!=15:DispGraph
For(A,33,62
For(B,17,43
pxl-Test(A-1,B-1)+pxl-Test(A-1,B)+pxl-Test(A-1,B+1)+pxl-Test(A,B-1)+pxl-Test(A,B+1)+pxl-Test(A+1,B-1)+pxl-Test(A+1,B)+pxl-Test(A+1,B+1)S
If S=3oror (S=2 and pxl-Test(A,B
Pxl-On(A-32,B
Pxl-On(A-32,B
End
End:End
For(A,33,62
For(B,17,43
Pxl-Off(A,B
If pxl-Test(A-32,B
sub(AB
Pxl-Off(A-32,B
End
End:End
End
Return

Lbl AB
Pxl-On(A,B
Return


Generated by the BBify'r (http://clrhome.org/resources/bbify/)
http://clrhome.org/resources/bbify/?t=.GAMEOFL%0AFull%0ADiagnosticOff%0AClrDraw%0AFor(A%2C33%2C62%0AFor(B%2C17%2C43%0AIf%20rand^2%0Asub(AB%0AEnd%3AEnd%3AEnd%0AWhile%20getKey!%3D15%3ADispGraph%0AFor(A%2C33%2C62%0AFor(B%2C17%2C43%0Apxl-Test(A-1%2CB-1)%2Bpxl-Test(A-1%2CB)%2Bpxl-Test(A-1%2CB%2B1)%2Bpxl-Test(A%2CB-1)%2Bpxl-Test(A%2CB%2B1)%2Bpxl-Test(A%2B1%2CB-1)%2Bpxl-Test(A%2B1%2CB)%2Bpxl-Test(A%2B1%2CB%2B1)-%3ES%0AIf%20S%3D3%20or%20(S%3D2%20and%20pxl-Test(A%2CB%0APxl-On(A-32%2CB%0APxl-On(A-32%2CB%0AEnd%0AEnd%3AEnd%0AFor(A%2C33%2C62%0AFor(B%2C17%2C43%0APxl-Off(A%2CB%0AIf%20pxl-Test(A-32%2CB%0Asub(AB%0APxl-Off(A-32%2CB%0AEnd%0AEnd%3AEnd%0AEnd%0AReturn%0A%0ALbl%20AB%0APxl-On(A%2CB%0AReturn&l=axe

EDIT: By the way, I've noticed hardly anyone uses the [pre] tag. It's an awesome tag, something like [tt] and [code] combined.
« Last Edit: December 15, 2011, 08:34:15 pm by Deep Thought »




Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: BBify your Axe and Z80 code!
« Reply #43 on: August 29, 2011, 02:03:50 pm »
Wow!  That looks great!  :D
Bieber would be so proud.  :P
« Last Edit: August 29, 2011, 02:04:32 pm by ralphdspam »
ld a, 0
ld a, a

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: BBify your Axe and Z80 code!
« Reply #44 on: August 29, 2011, 07:06:19 pm »
Wow!  That looks great!  :D
Thanks! And this is a bit of a late tip, but in case you haven't figured it out yet, put [pre] tags inside the [quote] to make it nice and monospaced. The reason I don't include it automatically is because only SMF supports it.