0 Members and 2 Guests are viewing this topic.
Quote from: Deep Thought on July 19, 2011, 07:28:28 pmIdea: 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?
Idea: What about one for Axe? I'm starting to work on it (it doesn't work yet).
It's a great tool. I already used it a few times when i posted asm source code.
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>
<?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>
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.
<?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<\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]√[/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]°[/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[#->#]]></f> <r><![CDATA[[b][color=black]→[/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>
.\G\A\M\E\O\F\L\FullDiagnosticOffClrDrawFor(A,33,62For(B,17,43If rand^2sub(ABEnd:End:EndWhile getKey!=15:DispGraphFor(A,33,62For(B,17,43pxl-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)→SIf S=3oror (S=2 and pxl-Test(A,BPxl-On(A-32,BPxl-On(A-32,BEndEnd:EndFor(A,33,62For(B,17,43Pxl-Off(A,BIf pxl-Test(A-32,Bsub(ABPxl-Off(A-32,BEndEnd:EndEndReturnLbl ABPxl-On(A,BReturnGenerated by the BBify'r (http://clrhome.org/resources/bbify/)
Wow! That looks great!