[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Parsing Simple Markup
From: |
Oleg Kolosov |
Subject: |
Re: [Chicken-users] Parsing Simple Markup |
Date: |
Sun, 21 Sep 2014 09:45:12 +0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 |
On 09/20/14 19:19, Yves Cloutier wrote:
> Hello,
>
> I am a new user to Scheme in general and to Chicken in particular, nice
> to meet you all.
Welcome!
>
> Scheme is a totally different paradigm that I'm used to, so while I wait
> for my books to arrive I will need some hand-holding...hope that's ok.
I was in a similar situation few months ago, with the experience in
"classic" languages - Scheme looked completely foreign. But it's
actually very simple once you get the basic concepts.
For learning I personally recommend "The Scheme
Programming Language" (http://www.scheme.com/tspl4/) - it contains very
nice exercises. The book is somewhat tied to Chez Scheme but many
extensions are available in Chicken as well.
Also, not often recommended but my favourite is: "An Introduction to
Scheme and its Implementation"
(ftp://ftp.cs.utexas.edu/pub/garbage/cs345/schintro-v14/schintro_toc.html)
- although it's unfinished there are some gems scattered around,
especially useful if you are familiar with the C language.
> 1) Is the Chicken Scheme manual available for purchase? Online docs are
> great but I like to have a hardcopy so that I can read offline.
There are http://wiki.call-cc.org/eggref/4/chicken-doc - you can install
it for offline use. It will look like http://api.call-cc.org/doc/chicken.
> For the most part, a lot of what I want to do is "search and replace",
> except for special cases where additioanl processing would be required
> to extract command:value pairs.
> ....
> The idea is to make typesetting with Groff very simple and intuitive for
> any user - not just programmers and hackers. The markup we are working
> on is called Typesetting Markup Language (TML). So it would convert
> html-like commands and generate a Groff document from it.
See also http://en.wikipedia.org/wiki/SXML,
http://wiki.call-cc.org/man/4/Unit%20irregex and
http://wiki.call-cc.org/eggref/4/fmt for ideas.
> In Perl I am able to do most of this with regular expressions, but I'm
> hitting my head against the wall when it comes to multiple formatting
> commands within a group <...,...,...<
> My idea was that I could read a line of text from a file at a time. My
> understanding is that the input would be read into an "s-expression"
> ....
> And then do something based on what token that is encountered.
You can try to first convert this to simple s-expressions like:
(bold "text")
(indent 5 "text")
(bold (smallcap (size 2 "text")))
and then use http://wiki.call-cc.org/eggref/4/matchable egg to generate
output. See
http://ceaude.twoticketsplease.de/articles/an-introduction-to-lispy-pattern-matching.html
for an introduction.
I've written very simple recursive s-exp parser using matchable some
time ago. I will clean it up and post the link here in a few days for
reference.
--
Regards, Oleg