ByteCode Parser (was YHC build finished successfully...)

<wondering out loud>I wonder if Visual J# is a reasonable choice (already installed on my system) or is this a dangerous place to go...</wondering> J# is Microsofts version of Java, stay well clear!
I think that's what I was thinking of. I will probably try Venkman/Firefox.
The API is going to be massively improved - the ultimate idea is to write a really good bytecode library, and then have the compiler use that one, so people can easily write utilities that operate on .hbc files. The library as it stands today has a pretty printer in it, tweaking that will probably give you the Javascript output you need without too much difficulty.
I got the code from (http://www.haskell.org//pipermail/yhc/2005-November/000004.html) and it compiles, but I get a runtime pattern match error on rChar (which is the character level parser), failing on [], which I take it means that it's hitting the end of the string and trying to read another character instead of halting. I don't quite understand all of the code well enough to try to track this down, but I imagine that maybe the parser from this API might need to be updated to the newest version of the bytecode spec? It looks like the loader does a bytecode version check, and it seems to be passing.... I imagine that this parser/pretty-printer worked at some point in time, right? Details (I added a line to print the binary file as a text string): "HSBC\NUL\SOH\NUL\t\NUL\NUL\NUL\SOH\NUL\f\NUL\EOTmain\NUL\aPrelude\NUL\ESCPrelude.Num.Prelude.Integer\NUL\vfromInteger\NUL\ETXYHC\NUL\bInternal\NUL\a_apply1\NUL\SOH+\NUL\a_apply2\NUL\CANPrelude.Num.Prelude.Show\NUL\ENQprint\NUL\EOTMain\SOH\NUL\v\SOH\NUL\NUL\NULWF\NUL\NUL\EOT\NUL\tA\SOH\NUL\SOH\SOH\NUL\STXl\SOH\ETXF\SOH\NUL\SOH\SOH\NUL\ETXF\STX\NUL\EOT\NUL\ENQ\SOH\NUL\ACKl\SOH\STXF\SOH\NUL\SOH\SOH\NUL\aF\STX\NUL\EOT\NUL\ENQ\SOH\NUL\bF\SOH\NUL\SOH\SOH\NUL\tF\SOH\NUL\SOH\SOH\NUL\n\NUL\DC4\SOH%&\b12)\ENQ\STX12\ENQ\STX45\f67[\NUL" -- Module: // name = Main a.out: ./Binary.hs:63:20-38: Non-exhaustive patterns in lambda which is at the place in the code where rChar is defined. rChar :: BinaryRead Char rChar = BinaryRead (\ (x:xs) -> (x, xs)) Jared. -- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:"

Hi Jared,
check, and it seems to be passing.... I imagine that this parser/pretty-printer worked at some point in time, right?
It never worked fully, which is the problem you're hitting. I only ever tested in on some simple .hbc files. I have attached updated versions of some files (there was a bug to do with reading signed bytes as the length of a negative integer which I want to chat about with Tom, but i've papered over for now). Hopefully this should get you further, but it still isn't complete. I'll work on writing a complete bytecode library in the next week. If this doesn't work with your particular file, then send me the source and the .hbc file you are working with. Thanks Neil

Hopefully this should get you further, but it still isn't complete. I'll work on writing a complete bytecode library in the next week.
This code seems to work great on my input HBC file. I should be able to play with the pretty-printer and try to get some simple JavaScripts to come out of it. I'll keep you posted on how things go. Thanks, Jared. -- jupdike@gmail.com http://www.updike.org/~jared/ reverse ")-:"
participants (2)
-
Jared Updike
-
Neil Mitchell