| View script | License | Download documentation as: HTML or editable |
| Download script | History | Other scripts by: brett |
16-Apr 5:48 UTC
[0.053] 14.55k
[0.053] 14.55k
Documentation for: parse-analysis-view.rParse Analysis Toolset /View1. What is this for?Uses REBOL/View to visualise the results of Parse. Currently provides a View representation on the results from the Tokenise-parse (see parse-analysis.r script and documentation). 2. Why is it useful?
3. What is in the script?
4. How do you use it?
if not value? 'script-manager [
script-manager: func ['word /local needs][
if any [
:word <> 'do-needs
none? in system/script/header 'needs
none? needs: system/script/header/needs
][return]
if not parse needs: compose [(:needs)] [some file!][make error! {Expected a NEEDS block consisting of file!.}]
foreach [file] needs [do file]
]
]
4.1 ExampleHere we specify the parse rules and the text. mygrammar: context [
alpha: charset [#"A" - #"Z" #"a" - #"z"]
digit: charset {0123456789}
word: [some alpha]
number: [some digit]
main: [
some [word | number | skip]
]
]
text: {Word 123 +=+ 45 End}
visualise-parse/ignore text mygrammar [parse/all text mygrammar/main] [alpha digit]Another example. In this example we are going leverage the built-inxml rules of REBOL. That is why the BIND is used below. ; An old xml example
xml: {<movie>
<title>Star Trek: Insurrection</title>
<star>Patrick Stewart</star>
<star>Brent Spiner</star>
<theater>
<theater-name>MonoPlex 2000</theater-name>
<showtime>14:15</showtime>
<showtime>16:30</showtime>
<showtime>18:45</showtime>
<showtime>21:00</showtime>
<price adult="8.50" child="5.00" />
</theater>
<theater price="6.00">
<theater-name>Bigscreen 1</theater-name>
<showtime>19:30</showtime>
</theater>
</movie>}
rules: bind [
element name content attribute attr-value
] xml-language
visualise-parse xml rules [parse-xml xml]4.2 What should I do with these examples?
4.2.1 Thinking about what you are seeing
5. About the script authorBrett Handley started programming REBOL early 2000 and maintains a site of REBOL information and scripts at: http://www.codeconscious.com/rebol/ |