[plt-scheme] Re: What to augment, how to highlight ?

From: Cyprien Nicolas (c.nicolas at gmail.com)
Date: Sat Nov 24 07:28:12 EST 2007

Hello Laurent,

I don't think it is a good idea to make the third value equals to the
lexeme. The third value is used by the paren matcher, so if you return
a number there, you will have to cons it to the third argument of
start-colorer. You have to value #f here, except if the lexeme is a
kind of parenthesis (...), begin ... end, if ... fi, and so on.

Cyprien

2007/11/23, Laurent <Ouaibou at gmail.com>:
> Oh, sorry. I am thoughtless. I modified my code thanks to your
> comments and it is good.Thanks :)
>
> I still have a question :
>
> Now, with the "start-colorer" method my regular expressions are
> colored. However, if I write a character not recognized by the lexer,
> Drscheme send an exception like :
>
> exception in colorer thread: #4(struct:exn:fail:read "lexer: No match
> found in input starting with: é" #<continuation-mark-set>
> (#6(struct:srcloc #f 1 0 1)))
>
> How say to the lexer that it doesn't have to color caracters they are
> not recognize.
>
> Example of the lexer :
>
> (define get-word
>   (lexer
>    (int
>     (values lexeme 'number lexeme (position-offset start-pos)
> (position-offset end-pos)))
>    (float
>     (values lexeme 'number lexeme (position-offset start-pos)
> (position-offset end-pos)))
>    (statement
>     (values lexeme 'keyword lexeme (position-offset start-pos)
> (position-offset end-pos)))
>    (str
>     (values lexeme 'string lexeme (position-offset start-pos)
> (position-offset end-pos)))
>    (var
>     (values lexeme 'var lexeme (position-offset start-pos) (position-
> offset end-pos)))
>    (whitespace
>     (values lexeme 'whitespace lexeme (position-offset start-pos)
> (position-offset end-pos)))
>    ((eof)
>     (values lexeme 'eof #f #f #f))))
>
> Perhaps, i try to catch the exception like this :
>
> (with-handlers ([exn:fail:read?  (lambda (exn) (void))])
>     (send this start-colorer (lambda (s) (symbol->string s)) get-word
> `())))
>
> But this don't perform :(
>
> Thanks,
>
> Laurent
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>

Posted on the users mailing list.