Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ChrisDolan (2855)

ChrisDolan
  (email not shown publicly)
http://www.chrisdolan.net/

Journal of ChrisDolan (2855)

Thursday July 02, 2009
09:24 PM

Coding Horror

Jeff Atwood is the best tech blogger in the world, in my opinion. And his most recent post contains my nominee for the quote of the year:

Open source software only comes in one edition: awesome.

Thursday February 12, 2009
11:04 PM

Rakudo improves!

I haven't really been working on features for my Perl 6 PDF grammar very much, but I have been using it as a tool to follow improvements in the Rakudo implementation of Perl 6.

This week, I went through all of the PDF code and looked for comments I wrote for myself about workarounds for incomplete parts of Rakudo. The exciting news is that I was able to remove about half of my workarounds this week. Considering that most of the rest of the annoyances are features that are on the near-term roadmap (mainly, PGE refactoring), I consider this to be superb progress.

Bravo, Perl 6 developers!

I made a contribution of my own, too, which has made me absurdly happy out of proportion to the size of the patch. I implemented 'make' from S05. This builtin function is shorthand for the following:

# Equivalent code:
  $/.result_object($value);
  make $value;

This, along with other simplifications allowed me to shave about half of the lines of PDF::Grammar::Actions while improving readability. Yay!

Wednesday February 11, 2009
12:47 AM

Perk moved to github

Today I moved Perk (a Java compiler targeting Parrot) to github. I do not intend to maintain the SVN repository at googlecode. Sorry for the churn, but better now than later...

I am working on converting the actions.pm to be real Perl 6 instead of NQP. I submitted a prerequisite patch to Rakudo to support that (implement the 'make' builtin). But I'm getting mysterious runtime failures with basic PIR.

If you want to try Perl 6, just edit one line of the Perk Makefile to change "ACTION_COMPILER=nqp.pbc" to "ACTION_COMPILER=perl6.pbc".

Once I get that to work, I'll probably port perk.pir to perk.pl. Then we'll see about implementing more of the actions.

Thursday February 05, 2009
10:57 PM

Frozen Perl talk: Perl 6 grammars

I'm headed to Frozen Perl tomorrow. My talk is titled Using Rakudo Grammars, but it ended up being more about Perl 6 than specifically the Parrot/Rakudo implementation.

I'm looking forward to the hackathon Sunday. I'm thinking that I'd like to work on enabling any language's PCT actions.pm to be implemented in Rakudo instead of NQP. Patrick Michaud mentioned a few blockers in IRC, so I'm hoping to work on those.

Wednesday January 14, 2009
10:40 PM

Perk: an implementation of Java language on Parrot

I moved my Java parsing experiment from my own SVN to the Squawk project. Squawk is intended to Parrot-based languages that are too small or immature to live on their own.

I chose the name "Perk" for my implementation to avoid any risk of Java trademarks. It's short, it reminds you of caffeine, and it's only one letter away from Perl.

If this project doesn't wither on the vine (a very real possibility, I admit) then I hope it will be source code compatible with basic Java. I have no intention of any interoperability with Java bytecode or the Java VM.

The source code is easily browsable. If anyone is interested in participating, I welcome the company. There's no way I'm going to make more than a dent in this project by myself.

Tuesday January 13, 2009
10:29 PM

Regex for floating hex

A couple days ago I wrote about Java syntax for hexadecimal representation of floating point numbers like this:

0x1.fffffeP+127f

Here are the Perl 6 grammar snippets I put together to parse this. Easy!

token HexLiteral {
  '0' ['x'|'X'] [
     | '.' <HexDigit>+ <HexExponent>? <FloatTypeSuffix>?
     | <HexDigit>+ [
         | '.' <HexDigit>* <HexExponent>? <FloatTypeSuffix>?
         | <IntegerTypeSuffix>?
     ]
  ]
}
token HexDigit { [\d|<[a..f]>|<[A..F]>] }
token HexExponent { ['p'|'P'] ['+'|'-']? \d+ }
token FloatTypeSuffix { 'f'|'F'|'d'|'D' }

Monday January 12, 2009
12:41 AM

PGE Java parser and floating hex notation

Last week I reported that I had a working parser for Java source code implemented as a Perl 6 grammar. Well, a dozen or so bugs later, it actually works now. Out of 7,000+ .java files in the OpenJDK, I fail to parse 3 of them (plus a handful that that are too large to fit in a gig of RAM -- I need to work on decreasing memory consumption). One of the three is a surely a bug, and the other two are unusual syntax that I've never seen before in java.lang.Double and java.lang.Float:

    public static final double MAX_VALUE = 0x1.fffffffffffffP+1023;
    public static final double MIN_NORMAL = 0x1.0p-1022;
    public static final double MIN_VALUE = 0x0.0000000000001P-1022;
    ...
    public static final float MAX_VALUE = 0x1.fffffeP+127f;
    public static final float MIN_NORMAL = 0x1.0p-126f;
    public static final float MIN_VALUE = 0x0.000002P-126f;

Hex notation for rational numbers -- what an interesting idea. I've never encountered that before. It appears that this notation first appeared in the 3rd edition of the Java language specification.

This seems to me like a notation worth adding to Perl 6, given its inherent precision advantages over decimal notation.

Friday January 09, 2009
12:02 AM

Java parser in Parrot/PGE

My favorite part of Perl 6 is the new grammar syntax. Over the last couple of days, I translated a Java source code grammar from antlr to PGE. After about 4-5 hours of work, I now have a Perl 6 grammar that can parse all of the .java files in the OpenJDK (the Java 7 source code). Well, that may be a lie. It's still crunching at about 5-10 seconds per file so it will be a while before I know if its really true.

Admittedly most of the credit goes to the authors of the antlr grammar I adapted, but this also says good things about the Perl 6 regex implementation in Parrot.

The things that bit me hardest were:

  1. negated classes (PGE doesn't understand "<-[abc]>" so I had to make the inner part a separate token)
  2. antlr allows character classes with outside of any character group syntax (antlr: "'0'..'9'", perl: "<[0..9]>")
  3. longest token on integer vs. float (I had to change the antlr grammar to put float ahead of integer)
  4. whitespace (I cribbed from the Pipp implementation)
Thursday December 04, 2008
10:31 PM

[non-perl] help, my favorite author is ransoming a book!

For the last 20+ years, my favorite sci-fi/fantasy author has been Lawrence Watt-Evans. His books are not always profound, but they just fit my brain. He's currently writing a sequel to his 1989 sci-fi mystery Nightside City.

The catch is that he's writing it one chapter at a time and holding future chapters hostage until he gets enough donations. His goal of $300 per chapter is both reasonable and steep, depending on your point of view. He justifies it thoroughly in his FAQ.

If you've ever read one of his books, or just enjoy sci-fi, or have ever used one of my modules and feel you owe me ;-) then please consider donating.

Friday November 28, 2008
03:43 PM

Padre on Mac install trick

I've been curious to peek at Padre, Gabor Szabo's new editor, but it's Test::NeedsDisplay prereq always failed for me with an obscure recommendation to install xvfb-run. It turns out all you really need is to run "wxPerl Makefile.PL" instead of "perl Makefile.PL". I added a note to that effect in the Makefile.PL (thanks to AdamK's open repository).

So, any Mac user who wants to try Padre can use this trick (I didn't actually test this exact technique since I got it installed via a much more convoluted trial-and-error process).

cpan install Wx
wxPerl -MCPAN -e install Padre

Now I'm off to report some bugs...