From: Pierre Weis <Pierre.Weis@inria.fr>
To: htiede@titan.iwu.edu (Hans-Joerg Tiede)
Cc: caml-list@inria.fr
Subject: Re: Genlex
Date: Fri, 9 Feb 2001 10:44:41 +0100 (MET) [thread overview]
Message-ID: <200102090944.KAA02025@pauillac.inria.fr> (raw)
In-Reply-To: <3A831147.E28E6DF8@titan.iwu.edu> from Hans-Joerg Tiede at "Feb 8, 101 03:36:07 pm"
> Hi,
> I was writing a simple Scheme parser in Ocaml and I set up a lexer using
> the Genlex library. It seems that the lexer doesn't support keywords
> with the # character in them, making it hard to recognize #t and #f
> (true and false in Scheme).
[...]
> --Joerg
> -----------------------------------------------------
> Hans-Joerg Tiede
[...]
> www: http://www.iwu.edu/~htiede
> -----------------------------------------------------
Right. This is because the # is a starter for ``special idents'' made
of symbols only (here symbols == non alphanumeric chars). You must
change the rule for ident2 to add the possibility to have
alpha-numeric chars after a non-alphanumeric char. For instance:
and ident2 = parser
| [< ' '!'|'%'|'&'|'$'|'#'|'+'|'-'|'/'|':'|'<'|'='|'>'|'?'|'@'|'\\'|
'~'|'^'|'|'|'*' as c; s >] ->
store c; ident2 s
| [< ' 'A'..'Z'|'a'..'z'|'\192'..'\255'|'0'..'9'|'_'|'\'' as c; s>] ->
store c; ident2 s
| [< >] ->
Some(ident_or_keyword(get_string()))
However, to built a lexical analyzer for Scheme, you should rewrite a
lot of the Genlex module, since the tokens recognized by genlex are
far too similar to those of Caml (or Pascal or C or Java) to
accomodate Scheme symbols (for instance int->real is naturally
considered as 3 tokens by Genlex, when it is a regular ident name in
Scheme).
Alternatively, you can consider using Ocamllex to write a conventional
lexer.
Hope this helps,
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
parent reply other threads:[~2001-02-09 9:50 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <3A831147.E28E6DF8@titan.iwu.edu>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200102090944.KAA02025@pauillac.inria.fr \
--to=pierre.weis@inria.fr \
--cc=caml-list@inria.fr \
--cc=htiede@titan.iwu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox