[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] Lisp macro fun...
From: |
Waldek Hebisch |
Subject: |
Re: [Axiom-developer] Lisp macro fun... |
Date: |
Thu, 19 Apr 2007 13:55:41 +0200 (CEST) |
> I have been attempting to generalize Waldek's finite state machine
> using macros, and have essentially run up against the limits of my tiny
> Lisp skills. Can anybody tell me how to get this thing to expand into
> something like Waldek's code? (I can provide the whole file if it is
> needed.)
>
I must admit that I do not understand what you are tring to do now
-- what you posted looks like macro definition, but it contains
(hardcodes) most of had written version.
Have you looked at <http://ll1.ai.mit.edu/shriram-talk.pdf> (it
contains Scheme example of macro-generating finite state
machine)?
Low level macro version of finite state machine may look like:
(automaton
(setup_code)
(state normal-start
(normal_start_setup)
(-> start-tag-code-1 chunk-start-tag-1)
(-> newline-code normal-start)
(default normal))
(state normal
(-> newline-code normal-start)
(default normal))
(state chunk-start-tag-1
(-> start-tag-code-2 in-chunk-start-tag
;;; Action
(setf start-pos (+ pos 1)))
....
To generate our code from the above one has to define macros
automaton, state, defalut and ->. state, defalut and -> may
be local to automaton. In the above I assumend that we use
chacter codes, but we could also use characters and write:
(-> #\< chunk-start-tag-1)
A higher level version may do transitions on strings, so you
could write:
(-> "<<" in-chunk-start-tag
;;; Action
(setf start-pos (+ pos 1)))
and the macros would automatically generate intermediate states.
--
Waldek Hebisch
address@hidden