help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Including mathematical symbols in STRING token


From: Hans-Bernhard Broeker
Subject: Re: Including mathematical symbols in STRING token
Date: Tue, 24 Jun 2003 09:51:29 +0200 (MET DST)

On Tue, 24 Jun 2003 address@hidden wrote:

>     I am working on a parser in which STRING token consists of all the
> possible characters, like =,/,+ etc.

That cannot ever work.  Not for strictly *all* characters, since that
would leave no way at all to tell the program where a string ends.
Having only a maximum of one string object per input file that
automatically extends from wherever it begins all the way to the end of
the file would be rather unhelpful, right?

Some special reserved character is needed to signal the end of the string
in the input.  Whether that be " or ' or something completely different is
your choice.  But sticking to the well-established usual ones will make
your syntax easier to remember, so best stick with " or '.  Next, you'll
have to devise a method to allow the string terminator itself to be part
of the string.  The classic choices being:

*) double "" is an actual " character, single " ends the string
*) the good old backslash-escape mechanism.

The former is marginally simpler, the latter is more powerful --- you
might well end up adding full C-style backslash-sequence handling, later.

> is the best method to get the desired result. Is it necessary to use
> only quoted strings (between " ") or we can do with usual unquoted
> strings ?

There is no such thing as "usual unquoted strings" --- not quoting strings
is quite completely unusual.

-- 
Hans-Bernhard Broeker (address@hidden)
Even if all the snow were burnt, ashes would remain.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]