From: "Janne Hellsten" <jjhellst@gmail.com>
To: caml-list@inria.fr
Subject: Matching start of input in lexer created with ocamllex
Date: Thu, 5 Apr 2007 17:37:47 +0300 [thread overview]
Message-ID: <700d600f0704050737r3ea45a16gb318ac7acf8e3178@mail.gmail.com> (raw)
Hi,
I'd like to match the beginning of input (or beginning of line) in my
lexer. Is there an easy way to do that?
I have a lexer that looks something like this (simplified):
rule initial = parse
| '!' [' ' '\t']* "for" { FOR (current_loc ()) }
| ident as id { IDENT (id, current_loc ()) }
| '!' { BANG (current_loc ()) }
The !for token should only be matched at the beginning of a
line/input. However, in the above lexer, there's nothing that
prevents !for from being matched in the middle of an input string.
This causes a problem: An input string containing !forbidXyz will be
lexed FOR, IDENT "bidXyz". I'd like to lex it as BANG, IDENT
"forbidXyz".
Thank you for your help!
Janne
next reply other threads:[~2007-04-05 14:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-05 14:37 Janne Hellsten [this message]
2007-04-05 19:55 ` [Caml-list] " skaller
2007-04-05 20:58 ` Janne Hellsten
2007-04-06 5:52 ` skaller
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=700d600f0704050737r3ea45a16gb318ac7acf8e3178@mail.gmail.com \
--to=jjhellst@gmail.com \
--cc=caml-list@inria.fr \
/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