[Haskell-cafe] Re: Unary Minus
Benjamin L.Russell
DekuDekuplex at Yahoo.com
Mon Apr 6 06:33:31 EDT 2009
On Mon, 6 Apr 2009 12:13:09 +0200, Roel van Dijk
<vandijk.roel at gmail.com> wrote:
>On Mon, Apr 6, 2009 at 12:04 PM, Benjamin L.Russell
><DekuDekuplex at yahoo.com> wrote:
>> Interesting. ?How is this hack implemented?
>
>This seems to be the relevant grammar:
> lexp6 -> - exp7
> lpat6 -> - (integer | float) (negative literal)
>
>The '6's and the '7' are superscripts.
>Perhaps the hack is in the precedence of the expression in which an
>unary minus is allowed.
Yes, I see it now. It's under "9.5 Context-Free Syntax," instead of
being under "9.2 Lexical Syntax," so it's a syntactic rule, rather
than a lexical rule.
According to the rule, "a left-expression of precedence level 6"
consists of "'-' followed by an expression of precedence level 7", and
"a left-pattern of precedence level 6" consists of "'-' followed by
(an integer or a float)", and by definition, this is a "negative
literal." Integers and floats, in turn, are part of the lexical
syntax.
-- Benjamin L. Russell
--
Benjamin L. Russell / DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile: +011 81 80-3603-6725
"Furuike ya, kawazu tobikomu mizu no oto."
-- Matsuo Basho^
More information about the Haskell-Cafe
mailing list