"leppie" wrote:

>> FWIW I  started repackaging SILex[1] by  Danny Dube' into
>> Nausicaa.
>
> How hard would it be for it to emit a nice library too?

Wrapping the  generated code into a library  is easy.  There
are  few interface  functions, with  known names.   But, the
state of  the generated  code must be  put into a  record or
something.

  I still  have to  really try both  the two levels  of API.
The lower one seems to  use already a non-global state.  The
init function of the higher  one in the generatED code looks
like this:

(define lexer #f)
(define lexer-get-line   #f)
(define lexer-get-column #f)
(define lexer-get-offset #f)
(define lexer-getc       #f)
(define lexer-ungetc     #f)

(define lexer-init
  (lambda (input-type input)
    (let ((IS (lexer-make-IS input-type input 'all)))
      (set! lexer (lexer-make-lexer lexer-default-table IS))
      (set! lexer-get-line   (lexer-get-func-line IS))
      (set! lexer-get-column (lexer-get-func-column IS))
      (set! lexer-get-offset (lexer-get-func-offset IS))
      (set! lexer-getc       (lexer-get-func-getc IS))
      (set! lexer-ungetc     (lexer-get-func-ungetc IS)))))

so  it seems that,  internally, the  simple LEXER-INIT/LEXER
API is already built around a non-global state variable.  If
this turns out  to be true, it should be  easy to change the
generatING code to use non-global state in both the levels.

  The generatING code is complex, of course...
-- 
Marco Maggi

Reply via email to