Since the last blog post, as3tohaxe converter now has expression parsing, “as” converted to “cast ()” calls, and a program, as3tohaxe.hs, to run through a directory recursively and convert!
So I gave the converter the AsWing codebase as its first big test and ran into a couple problems.
The parser was bombing on some unidentifiable characters which turned out to be the UTF8 header sequence “\239\187\191” or EF BB BF in hex. At first I just tried removing those characters but couldn’t with vim because the character is “zero width”. So I used a hex editor, 0xED, and the parser ran without issue. So I’ve updated the lexer to handle the header as whitespace.
The second problem I came across was one file taking a particularly long time converting. I think it has to do with one of the statements which has a nested expression.
((((((((("GridLayout[hgap=") + hgap) + ",vgap=") + vgap) + ",rows=") + rows) + ",cols=") + cols) + "]");
I still need to verify this.
Update: The nested expressions were causing the slowdown. I removed redundant work being done by the parser and got a huge speedup.