[REBOL] Re: Big parse rules
From: AJMartin:orcon at: 19-Jul-2003 22:02
> would like pathes in parserules.
So would I! :)
> without it, you could put everything in a context and export only 'Table^
with 'set. or do
> table^: ctx-table/table^
> parse string [..]
> Table_Printable^: exclude Printable charset #"|"
> set 'Table^[
> ; ..
Thanks, Volker! That would work, except that I wanted it to eventually be
recursive. With an object, I can't yet see how this could be done (perhaps
copying to a stack/block?).
Here's what I eventually ended up with:
set 'Table^ function [
Markup [block!] eText [string!]
] [Printable^ Cell! Cell^ Cell Row^ Row Header Rows Index] [
Printable^: exclude Printable charset #"|"
#"|" copy Cell any Printable^
(Cell: reduce [Cell! any [Cell #" "]])
(Row: copy )
some [Cell^ (insert tail Row Cell)] opt #"|" LWS? Line_End
(Row: reduce ['tr Row])
parse/all eText [
Rows: copy 
some [Row^ (insert tail Rows Row)] (
insert tail Markup compose/deep [
) Index: to end
And in a separate function:
Fail^: [to end skip] ; Always fails rule.
Succeed^:  ; Always succeeds rule.
parse/all Dialect [
if Result: Table^ Markup Mark [
) Switch^ :Mark
Though it's still only about 90% I feel.
Andrew J Martin
ICQ: 26227169 http://www.rebol.it/Valley/ http://Valley.150m.com/