Menu:

Sponsor

Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

Follow Me

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


Alessandro Crugnola on December 10, 2006 in actionscript , general , python

ActionScript Parsing, the YACC revenge :)

After my first attempts with ANTLR scanners in python/java I decided to start back with Bison/Flex again to see the difference in performances.
So first I need to wrote from scratch the grammar/lexer files using only the ECMAScript 4 specifications and much patience (the elastic grammar file help me a lot too).

After finishing a first version of the parser I tested it on the same file (75Kb actionscript file) which both java and python parsed in more than 1 second.
The result was unbelievable: 0.02 seconds for that file!

Then I tested it on multiple files, and for about 320 files of the whole adobe corelib library it took 220ms

Ok, the parser it's not yet complete and doesn't care about regexp and xml syntax, but its performance convinced me enough...
Now, the next step is to finish and test the parser and finally create a python library using pyrex, then a benchmark test again.

If someone is interested in testing the parser, download it (use "parser --help" form the command line for usage help), but remember this is only a first test.. not really helpful right now (I just wanted to share my text/parsing experiences).

 

Bookmark and Share

 

 

5 comments
Have you done a performance test with ANTLR 3 vs Flex/Bison? I hear ANTLR 3 is suppose be just as fast.
No, it's just C. Anyway, now I'm building the AST for the parser then I will make another post for testing again :)
Dear Allessandro, I'd really love to try out your parser. Unfortunately I' ve only got a Mac. How did you programm your parser? Is it C/C++ or ActionScript itself (or anything else)? Best regards...
Antlr has always been a peice of crap for speed I think (I did a C# parser with it once, ugh). I think any parser generators create slower code that is hard to leverage for things like error detection etc. The worst thing is after finally writing a totally hand written lexer/parser, it is actually way easier than using the parser generators. I really wish intro books on parser/compilers would talk more about this kind of thing, it could save everyone a lot of time : ). Anyway, way to go on the parser, I will definatly be checking it out. Kudos to you once again : ).
This sounds very interested, for example using as preparser and code some kind of support for inline functions. Of course there is always "cpp -E" :)


Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Type the characters you see in the picture above.





 

TrackBacks

TrackBack URL for this entry: http://www.sephiroth.it/cgi-bin/mt/mt-tb.cgi/147