[plt-scheme] Re: What to augment, how to highlight ?
I think someone more versed in the lexer would have to respond, but I
guess you should be able to adjust your lexer so that it recognizes
everything, but explicitly labels some things as errors. I believe
this is the strategy that DrScheme takes.
(And, fwiw, I don't think you were thoughtless ... I wasn't very clear.)
Robby
On Nov 23, 2007 1:50 PM, Laurent <Ouaibou at gmail.com> wrote:
> 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
>