[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding stuff to the core distro (was Re: Infix syntax)
From: |
Daniel Skarda |
Subject: |
Re: Adding stuff to the core distro (was Re: Infix syntax) |
Date: |
16 Oct 2002 23:35:15 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
> BTW, does (ice-9 infix) handle tricky whitespace like in `#[2+4* 8]'?
> If not, you could use a simple macro rather than a read hash
> extension: `(infix 2 + 4 * 8)' rather than `#[2 + 4 * 8]'. As a
> macro, `infix' would obey the usual module rules.
Wow, that's clever. It seems I played with read hash extension too much that I
have not noticed simpler (and schemish) way... (On the other hand, #[] is
shorter :-)
Current infix module is divided to tokenizer (an arbitrary function without
any
parameter, that returns new token) and parser (read-infix-expr tokenizer ....)
There is also function make-read-tokenizer, that can build tokenizer for
particular port. This tokenizer uses combination of read-char/read, it also
splits symbols, when there is #\[ #\] or #\, inside them.
No other tricky whitespace handling is performed (it would be dangerous, since
#\- and #\* are often used in scheme symbols).
infix.scm proposal, second edition:
-------------------------------------
(define-infix-macro NAME)
define macro `NAME' which transforms infix syntax to scheme expressions. It
also defines variables *NAME-infix*, *NAME-prefix* hash tables (or rather
alists?) and *NAME-split-list*.
NAME splits its arguments according characters in *NAME-split-list* list and
creates tokenizer, which successively feeds read-infix-expr with tokens.
(add-infix-operator NAME operator func paramers ...)
(add-prefix-operator NAME operator func paramers ...)
(add-infix-separator NAME character)
I think that "clever" whitespace handling would be sometimes very confusing.
It is possible to split 4*8, but #\- will cause nightmare (foo-bar). IMHO it
would not be wise to split using symbol lookup (defined?) since it could cause
mysterious bugs ...
I am going to rewrite infix.scm as soon as I get some spare time (first I
should stop spamming guile-devel with long emails, I guess :)
0.
ps: Sometimes I also use read-hash extension for shorter (sed|awk|perl|...)-like
regular expressions: #/foo.*bar/i, sometimes I also use srfi-10 #,(rx "foo.*bar"
icase). Do you think that other guilers would benefit from such hairy
extensions?
I try to clean up my regexps.scm and post it later.
- Re: Adding stuff to the core distro (was Re: Infix syntax), (continued)
- Re: Adding stuff to the core distro (was Re: Infix syntax), Bill Gribble, 2002/10/10
- Re: Adding stuff to the core distro (was Re: Infix syntax), Daniel Skarda, 2002/10/19
- Re: Adding stuff to the core distro (was Re: Infix syntax), Neil Jerram, 2002/10/13
- Re: Adding stuff to the core distro (was Re: Infix syntax), Daniel Skarda, 2002/10/18
- Re: Adding stuff to the core distro (was Re: Infix syntax), Neil Jerram, 2002/10/19
- Re: Adding stuff to the core distro (was Re: Infix syntax), Daniel Skarda, 2002/10/10
- Re: Adding stuff to the core distro (was Re: Infix syntax), Neil Jerram, 2002/10/13
- Re: Adding stuff to the core distro (was Re: Infix syntax),
Daniel Skarda <=
- Re: Adding stuff to the core distro (was Re: Infix syntax), tomas, 2002/10/19
- Re: Adding stuff to the core distro (was Re: Infix syntax), Daniel Skarda, 2002/10/20
- Re: Adding stuff to the core distro (was Re: Infix syntax), tomas, 2002/10/21
- Re: Adding stuff to the core distro (was Re: Infix syntax), Neil Jerram, 2002/10/21
- Re: Adding stuff to the core distro (was Re: Infix syntax), Christopher Cramer, 2002/10/19
- Re: Adding stuff to the core distro (was Re: Infix syntax), Daniel Skarda, 2002/10/20