Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648

George Neuner <gneuner2@comcast.net>
31 Jan 2006 21:20:51 -0500

          From comp.compilers

Related articles
1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 devriese@cs.tcd.ie (Edsko de Vries) (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 torbenm@app-0.diku.dk (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 rsc@swtch.com (Russ Cox) (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 jm@bourguet.org (Jean-Marc Bourguet) (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 gneuner2@comcast.net (George Neuner) (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 rivers@dignus.com (Thomas David Rivers) (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 david@tribble.com (David R Tribble) (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 henry@spsystems.net (2006-01-31)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-02-02)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-02-02)
Re: 1 - 1, 1 -1, 1-1, 1 - -1 and -2147483648 david@tribble.com (David R Tribble) (2006-02-03)
| List of all articles for this month |
From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: 31 Jan 2006 21:20:51 -0500
Organization: Compilers Central
References: 06-01-131
Keywords: arithmetic, lex
Posted-Date: 31 Jan 2006 21:20:51 EST

On 31 Jan 2006 09:57:37 -0500, "Edsko de Vries" <devriese@cs.tcd.ie>
wrote:


>-2147483648 is a valid negative number (assuming 32-bit numbers),
>but the integer 2147483648 is _not_ a valid positive number.


>Even requiring a space before the operator
>does not help, because "1 -1" will be recognised as INT(1), INT(-1)
>instead of INT(1), OP(-), INT(1).
>
>Is there a good solution that solves both problems?


You can solve it two ways: require that white space or another
operator (such as parentheses) follow the binary operator, or restrict
the range of integer constants so that unary negation is always
possible.


Or you could try a suitably condescending error message ... it's
obvious that "1-1" is a misspelling of "H" 8-)




George


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.