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

[REBOL] Re: Bug in the parse functionality ???

From: rotenca:telvia:it at: 22-May-2003 0:56

Hi Marc, I think that the script reaches the recursion limits of parse. Indeed the recursion is not a need, so you can change it. I made to the script some other small changes to make it faster. REBOL [ Title: "REBOL Script Cleaner" Author: "Carl Sassenrath" File: %clean-script.r Date: 22/05/03 Email: [carl--rebol--com] Purpose: { Cleans REBOL scripts by parsing the REBOL code and supplying standard indentation and spacing. } Note: { This script produces STANDARD script indentation and spacing. No doubt you will want to modify it to use your own rules. Send your enhancements and I will consider adding them to the distribution... but keep this header intact and keep the code clean. No hacks. } Category: [script util text 3] History: [ "Romano Paolo Tenca" 1.0.1 22/05/03 "removed recursion, changed append with insert tail, added value local word, others small changes" "Carl Sassenrath" 1.0.0 27-May-2000 "Original program." ] ] script-cleaner: make object! [ out: none ; output text spaced: off ; add extra bracket spacing indent: make string! 50 ; holds indentation tabs emit-line: func [] [insert tail out newline] emit-space: func [pos] [ insert tail out either newline = last out [indent] [ pick [#" " ""] found? any [ spaced not any [find "[(" last out find ")]" first pos] ] ] ] emit: func [from to] [emit-space from insert tail out copy/part from to] set 'clean-script func [ "Returns new script text with standard spacing." script "Original Script text" /spacey "Optional spaces near brackets and parens" /local str new value ] [ spaced: found? spacey insert out: make script length? script newline parse script [ some [ str: newline (emit-line) | #";" [thru newline | to end] new: (emit str new) | [#"[" | #"("] (emit str 1 insert tail indent tab) | [#"]" | #")"] (remove indent emit str 1) | skip ( set [value new] load/next str emit str new ) :new ] ] remove out ; remove first char ] ] --- Ciao Romano