chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Parsing Simple Markup


From: Arthur Maciel
Subject: Re: [Chicken-users] Parsing Simple Markup
Date: Sun, 21 Sep 2014 17:34:51 -0300

Dear Yves, with SXML you could write transformation rules as Peter has shown in www.more-magic.net/docs/scheme/sxslt.pdf.

I'm not experienced with SXML, but AFAIK they would generate a similar effect as the procedures in your example below.

Best wishes,
Arthur

2014-09-21 17:06 GMT-03:00 Yves Cloutier <address@hidden>:
>
> Hello Oleg,
>
> Thank you for your recommendations too.  I actually just came back from the local library where I picked up "The Scheme Programming Language".
>
> You know, reading through your reply, it was the last part that made me think about something.
>
> If I can convert my input to the format:
>
> (bold "text")
> (indent 5 "text")
> (bold (smallcap (size 2 "text")))
>
> Could I not define each of these as functions (or procedures), and then just call an (eval '  ) procedure to do my output?
>
> For example (keeping in mind I'm only just getting familiar with Scheme syntax!):
>
> (define (bold (text)
>      (print the opening tag for the command 'bold')
>      (print the string 'text')
>      (print the closing tag for the command 'bold'))
>
> (define (indent (indent-value text)
>     (print the opening tag for the command 'indent' with value of 'indent-value')
>     (print the string 'text')
>     (print the closing tag for the command 'indent'))
>
> Actually due to the possible presence of nested commands, it should probably be something more generic, since in the last example:
>
> (bold (smallcap (size 2 "text")))
>
> what the procedure 'bold' would be taking in is not a string "text", but rather an _expression_...so this is where I guess things would need to be recursive.
>
> Once my document has been converted into one big "s-_expression_", and procedures defined accordingly, then I could just (eval ) it..couldn't I?
>
> (eval '(bold "text")
>     (indent 5 "text")
>     (bold (smallcap (size 2 "text"))))
>
> Or something along those lines?
>
> If this is the case....brilliant!
>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]