The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
When Rageling, Bring a Bird Beak

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
When Rageling, Bring a Bird Beak Posted: Feb 1, 2007 11:40 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: When Rageling, Bring a Bird Beak
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

While bunking inside Ragel, I’m starting to see the handiness of its lookahead operator. The bird beak :>, which gives a high priority to the next token in the machine.

In SuperRedCloth, this rule here was a flimsy way of matching a bit of text in parens:

 title = ( '(' [^)]+ ')' );

It turns out I was able to cut down the generated grammer by something like fifty K by using this instead:

 title = ( '(' chars+ :> ')' ) ;

The beak is great for any rule that’s getting too greedy and concludes with an exact character. Be warned, it may increase the complexity of the machine depending on how ambiguous your other rules are.

If I could offer one other bit of advice: stay away from the question mark, if you can. It seems like anything which uses the empty token can be expensive.

Read: When Rageling, Bring a Bird Beak

Topic: tinderbox version 1.0.0 has been released! Previous Topic   Next Topic Topic: firebrigade_api version 1.0.0 has been released!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use