Stilo e-Publishing Solutions [画像:picture - clouds] [画像:picture - clouds]
dark blue bar dark blue bar dark blue bar
Stilo
Contact Us Stilo Home
OmniMark Developer Resources
Stilo
Public
Stilo
Stilo
Developer Home
Login
Defects Reporting
defects reporting

Literate Programming Using OmniMark

Contents

3.

Weaving

6. Main Loop

6. Main Loop

Having defined the tangling and weaving processes earlier, the main loop for our literate programming tool is particularly simple. Essentially, it defines all the necessary components

<2 global shelves> <34 generating output filenames> <1 template processing> <32 tangling> <23 weaving>

and then repeats over all the files specified on the command-line, tangling and weaving each of them in turn:

group #implied process repeat over #args put #error "%nProcessing %"" || #args || "%" ...%n" using group "tangle" do sgml-parse document scan file #args output "%c" done using group "weave" do sgml-parse document scan file #args output "%c" done again <33 handling a cross-reference>

Note that the process rule is explicitly placed into the #implied group: the tangling process makes no promises on where things will end up in the tangled output. By explicitly putting the process rule in group #implied, we ensure that it doesn't get hidden inside a group that happens to appear before in the tangled output. The same reasoning applies to <33 handling a cross-reference>.

In Knuth's original tool, tangling and weaving were handled by separate programs. However, our tools are so brief that it hardly seems to be worth the trouble splitting them apart. Instead, one execution does both tangling and weaving of its input.

Previous section: Handling Cross-References

Next section: Generating Output Filenames

blue bar
Copyright © Stilo International Ltd 2022. All information on this website is protected under Stilo's copyright.
OmniMark, the OmniMark swirl logo and Stilo are registered trademarks of Stilo International Ltd. All rights reserved.

AltStyle によって変換されたページ (->オリジナル) /