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

[REBOL] makespec.r Specification Expander and Parse Questions

From: mike:myers:cybarite at: 9-Oct-2000 9:16

makespec.r Specification Expander and Parse Questions I am trying to create a recursive spec expanded and have some parse master questions Here is the base with the questions listed in the code. My plan is to submit it to the script library if: a. there is not a better way b. it has some value for the rebol users aside from me. I have used makespec.r extensively since it was postponed. But have wanted to get more re-use of specification fragments in large documents. P.S. I sent this earlier out of the rebol send and had an unbalanced bracket. Regrets for posting twice poorly. REBOL [ Title: "Specs File Exploder" File: %explode.r Date: 06-October-2000 Author: [mike--myers--cybarite--com] Purpose: { Expands text files which "include" other files which can include other files which can ... Allows re-use of specification fragments by "including" them into a work file that can be used by makespec.r } Category: [text markup 3] History: [ 06-Oct-2000 orig ] Example: { (This would be flush left in text editor) A REBOL makespec specification file ===Section Title ---Subsection Title This is a subsection paragraph. ===This is a section that will be copied in from an include file. #include %test.txt The above #include will cause the contents of %test.txt to be copied in place into the specification. } usage-comments: { do %explode.r ; to create the function definition #include - must start at position 1 of a newline The file name can include "/" to use the REBOL convention. The following line will explode the example string then convert it to html using the function convert provided in %makespec.r write %output-html-file.html text-to-html/convert explode example copy "" } parse-master-questions: { 1. is there a better or easier way that has been already published? 2. instead of parsing the file name xxxx.xxx via some file-name-characters "." some file-name-characters to newline I want to parse to the [newline | space] but I get an error message when I try to do that. If I can parse to space then I can allow a comment at the end of the #include statement e.g. #include %my-old-specification.txt ; use spec file from the August 2000 project 3. the makespec.r fragment that I copied for the text-line definition uses thru newline. This means that a line what does not end in a newline is ignored since it is not identified as a text-line. I think this is the same as #2 where I want to advance to newline if I find one else advance to end. But then [newline | end ] returns an error message. } ] explode: func [input-data [string!] accumulator-buffer [string!]] [ file-name-characters: charset [#"A" - #"Z" #"a" - #"z" #"0" - #"9" #"/" #"-"] parts: [[newline "#include %" aFileName] | text-line] text-line: [copy text thru newline (append accumulator-buffer text)] aFileName: [copy included-file-name [some file-name-characters "." some file-name-characters to newline] (append accumulator-buffer explode read to-file included-file-name copy "") ] parse/all input-data [some parts] return accumulator-buffer ]