From: Pierre Weis <Pierre.Weis@inria.fr>
To: laheadle@midway.uchicago.edu (Lyn A Headley)
Cc: caml-list@inria.fr
Subject: Re: lexing strings
Date: Mon, 2 Jun 1997 17:35:43 +0200 (MET DST) [thread overview]
Message-ID: <199706021535.RAA22238@pauillac.inria.fr> (raw)
In-Reply-To: <199706012353.SAA06495@kimbark.uchicago.edu> from Lyn A Headley at "Jun 1, 97 06:53:12 pm"
> [^'\n']*[^'\\']'\''
>
> which should match any sequence of non-newlines until it reaches a '
> not preceded by a backslash. slurp returns the token: STRING(!build)).
>
> My intent, when reading a string, is for the lexer to see the first ',
> jump into 'slurp,' eat up the string and return it as the STRING token,
> then have the parser read a newline and return EOL, thus matching the
> main grammar rule and printing the result. This almost works, but not
> until the user types _two_ newlines will the "interpreter" respond
> by printing the expression value! i.e., typing
>
> 'hi' [newline]
>
> at the prompt is not enough; two newlines are required. Other than
> that, the expected value is returned. Does this mean that the first
> newline is interpreted as part of the STRING? Why would my regex match
> the newline?
Yes, 'hi'\n' matches your regexp. I guess you want something along the
lines of
and slurp = parse
"'"
{ STRING(rev !build) }
| '\\' "'"
{ build := '\'' :: !build;
slurp lexbuf }
| eof
{ raise(Lexical_error "unterminated slurp") }
| c
{ build := c :: !build;
slurp lexbuf }
Hope this helps,
(Note: You should have defined the exception Lexical_error of string, in order
to signal the error "unterminated slurp".)
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
prev parent reply other threads:[~1997-06-02 15:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-01 23:53 Lyn A Headley
1997-06-02 15:35 ` Pierre Weis [this message]
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=199706021535.RAA22238@pauillac.inria.fr \
--to=pierre.weis@inria.fr \
--cc=caml-list@inria.fr \
--cc=laheadle@midway.uchicago.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