From: "Janne Hellsten" <jjhellst@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Matching start of input in lexer created with ocamllex
Date: Thu, 5 Apr 2007 23:58:00 +0300 [thread overview]
Message-ID: <700d600f0704051358g294d540ey96a546f7f57a08e7@mail.gmail.com> (raw)
In-Reply-To: <1175802901.5274.14.camel@rosella.wigram>
> let table = ["for", FOR; "while", WHILE]
> ..
> | space-not-newline + { WHITE }
> | newline { NEWLINE }
> | ident as id { try assoc id table with Not_found -> IDENT id }
>
> An alternative to the WHITE and NEWLINE tokens is a tail
> recursive call to the lexer:
>
> | space + { initial lexbuf }
>
> which just skips over the spaces.
I do have the latter construct in my lexer. How does the above help
me match the beginning of line in the rule
| '!' [' ' '\t']* "for" { FOR (current_loc ()) }
I'd like it to look like this:
| "^!for" { FOR }
where ^ would denote the start of input. To simplify my question, we
can assume there are no new line chars in my input. This regexp:
'!' [' ' '\t']* "for"
could actually be simplified to
| "!for"
and I would still need to match the "beginning of input" somehow.
I must've missed your point.
Janne
next prev parent reply other threads:[~2007-04-05 20:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-05 14:37 Janne Hellsten
2007-04-05 19:55 ` [Caml-list] " skaller
2007-04-05 20:58 ` Janne Hellsten [this message]
2007-04-06 5:52 ` skaller
[not found] <20070405205804.90509BC76@yquem.inria.fr>
2007-04-06 7:40 ` David Allsopp
2007-04-06 20:14 ` Janne Hellsten
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=700d600f0704051358g294d540ey96a546f7f57a08e7@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