From: Hal Fulton Date: 2003-09-09T04:00:32+09:00 Subject: Re: ANN: MetaTags 1.0 why the lucky stiff wrote: > On Monday 08 September 2003 12:08 pm, dblack@superlink.net wrote: > >>Namely, the idea of an extensible %_{} syntax, so that one could >>define the behavior of %y{}, %x{}, and so on from within a Ruby >>program or extension. >> >>Perhaps someone steeped in the ways of the parser could comment on >>how hard this would be (up to and including impossible). >> > > > this wouldn't be much of a problem. right now there's a 'default' case on a > switch in parse.y: > > default: > yyerror("unknown type of %string"); > return 0; > > establish a USERSTR set of tokens and node types. (you can follow XSTR or > DXSTR around to see how.) Then, in rb_eval, add a case for NODE_MISCSTR, > which could check for the character in a global hash, passing the string > contents into a proc associated with that character. return the result of > the proc call from rb_eval. > > the %y{...} hack could become: > > add_delimited_prefix( 'y' ) do |str| > YAML::load( str ) > end Much easier than I thought. I'll bet there are some gotchas, though. Matz?? Hal