Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: coding the closing parentheses correctly

From: moliad::gmail::com at: 30-Apr-2008 20:27

here you go Doug, I did a little recursive parse algorythm. ;----------------------------------------------------------------------------------------------- digits: charset "0123456789" item: complement digits load-container: func [ str /local entity cursor output count itm ][ output: copy "" ; recursive parse rule entity: [ [ "a" copy count some digits cursor: ; where do we start parsing next depth ( count: to-integer count append output "(" parse cursor reduce [count entity] append output ")" ) :cursor ;continue where recursive parses left-off ] | [ copy itm item cursor: ; where do we continue parsing after these items ( append output itm ) ] ] parse str entity return output ] ;--------------------------------------------------------------------- probe load-container "a2a3defa4pqrs" == "((def)(pqrs))" probe load-container "a4a4pqrsdef" == "((pqrs)def)" -MAx On Wed, Apr 30, 2008 at 7:10 PM, DougEdmunds <dougedmunds-gmail.com> wrote: