Sunday, May 28, 2006

May 28th, 2006 -- MiniPerl6 Finished Again

Continue on yesterday's work, I finished converting MiniPerl6 module so that it now work happily with ratchet.

The problem is that I used \w+ to match variable names but I should use [<alpha>|_]\w* instead (since the variables named with numbers are numbered captures, a special category). Another problem was hidden, or bypassed, by changing the order of alternations after I fixed the rule-using problem. It happened to be that the named capture parsing code in Pugs::Emitter::Rule::Perl5::Ratchet used a reference of boolean value in an "if" statement. I have to add another pair of ${} around it, at least before switching to Perl 6.


Anonymous Austin Frank said...

scw++ # congrats on SoC!!

I came up with a token for variable names that I was pretty happy with.

I can't use the named character class syntax in this example because the angle braces are parsed as illegal html tags (pre and code aren't allowed either =\ ). I'll use [alpha], but I really mean the one that goes < and then alpha and then >.

It is

token name {
[ [alpha] | _ ]+ [ [alpha] | \d | _ ]+ }

Feel free to look at src/Pugs/Parser/[Signature|Capture].pg if you're curious about other matching strategies I used.

Good luck,

5/30/2006 10:51 PM  
Blogger Shu-Chun Weng said...


New rule committed!

5/30/2006 11:28 PM  
Anonymous spinclad said...

Why the two '+'s? The first is harmless, of course, since anything it ate after the first character could just as well be eaten by the second... But the second methinks should be a '*', or else a token like 'a' is too short.

5/31/2006 4:38 PM  
Anonymous spinclad said...


token name {
[ [alpha] | _ ] [ [alpha] | \d | _ ]+*}

would make sense to me)

5/31/2006 4:41 PM  
Blogger Shu-Chun Weng said...

Yes, that's exactly what I used.

5/31/2006 4:42 PM  
Anonymous Anonymous said...

i am covered in embarrassment. i could swear i'd taken out that second '+', and didn't bother to preview. now you all get the benefit of my second and third thoughts, hurrah!


token name {
[ [alpha] | _ ] [ [alpha] | \d | _ ]*}

would make sense to me)

5/31/2006 4:47 PM  
Anonymous spinclad said...

all right, that anonymous was me of course, i'm done, i should stop posting at quarter to five in the morning.

5/31/2006 4:50 PM  

Post a Comment

Links to this post:

Create a Link

<< Home