Mailing List Archive

NASL2 new operators & precedence
I add three new operators:
** is the integer power (Fortran syntax)
^ is the logical xor
>>> is the unsigned / logical right shift (Java syntax)
>> is now the signed right shift
(and by the way, there is no such thing as singed / unsigned left
shift :)
I also added %= which was missing

Here is the precedence I implemented now (from lower priority to
higher):
%right = += -= *= /= %= <<= >>= >>>=
%left ||
%left &&
%nonassoc < > == != >= <= ><
%left |
%left ^
%left &
%nonassoc >> >>> <<
%left + -
%left * / %
%left - (unary minus) ~
%right **
%nonassoc ++ --


I know that this precedence is not like
- C; but C precedence really sucks
- Java; but you cannot imagine how much I hate this language and the
marketing s** around it
- Perl; but so many Perl operators are missing (and, or, etc.)

%nonassoc means that those constructions are rejected:
x << y << z
++ x ++
x ++ ++
x > y > z
"a" >< str >< "b"

%right means that 2**3**2 is parsed as 2**(3**2) = 2**9 and not
(2**3)**2 = 8**2

--
mailto:arboi@alussinan.org
GPG Public keys: http://michel.arboi.free.fr/pubkey.txt
http://michel.arboi.free.fr/ http://arboi.da.ru/
FAQNOPI de fr.comp.securite : http://faqnopi.da.ru/
Re: NASL2 new operators & precedence [ In reply to ]
Is this change likely to affect the semantics of any of the
existing NASL scripts? I'm wondering if there are any that
rely on the old left-to-right ordering.

Cheers

Rich.

Michel Arboi wrote:
> I add three new operators:
> ** is the integer power (Fortran syntax)
> ^ is the logical xor
>
>>>>is the unsigned / logical right shift (Java syntax)
>>>
>>> is now the signed right shift
>>
> (and by the way, there is no such thing as singed / unsigned left
> shift :)
> I also added %= which was missing
>
> Here is the precedence I implemented now (from lower priority to
> higher):
> %right = += -= *= /= %= <<= >>= >>>=
> %left ||
> %left &&
> %nonassoc < > == != >= <= ><
> %left |
> %left ^
> %left &
> %nonassoc >> >>> <<
> %left + -
> %left * / %
> %left - (unary minus) ~
> %right **
> %nonassoc ++ --
>
>
> I know that this precedence is not like
> - C; but C precedence really sucks
> - Java; but you cannot imagine how much I hate this language and the
> marketing s** around it
> - Perl; but so many Perl operators are missing (and, or, etc.)
>
> %nonassoc means that those constructions are rejected:
> x << y << z
> ++ x ++
> x ++ ++
> x > y > z
> "a" >< str >< "b"
>
> %right means that 2**3**2 is parsed as 2**(3**2) = 2**9 and not
> (2**3)**2 = 8**2
>


--
Richard Moore, Principle Software Engineer
Westpoint Ltd.
Re: NASL2 new operators & precedence [ In reply to ]
On Fri, 2003-01-24 at 13:36, Richard Moore wrote:
> Is this change likely to affect the semantics of any of the
> existing NASL scripts?

No. Many NASL2 operators do not exist en NASL1. And NASL1 does not
accept complex expressions without parenthesis.
Re: NASL2 new operators & precedence [ In reply to ]
On Fri, Jan 24, 2003 at 01:54:37PM +0100, Michel Arboi wrote:
> On Fri, 2003-01-24 at 13:36, Richard Moore wrote:
> > Is this change likely to affect the semantics of any of the
> > existing NASL scripts?
>
> No. Many NASL2 operators do not exist en NASL1. And NASL1 does not
> accept complex expressions without parenthesis.

And even so, the result is so unpredictible that most expressions split
in several instructions.

-- Renaud
Re: NASL2 new operators & precedence [ In reply to ]
Renaud Deraison wrote:
> On Fri, Jan 24, 2003 at 01:54:37PM +0100, Michel Arboi wrote:
>
>>On Fri, 2003-01-24 at 13:36, Richard Moore wrote:
>>
>>>Is this change likely to affect the semantics of any of the
>>>existing NASL scripts?
>>
>>No. Many NASL2 operators do not exist en NASL1. And NASL1 does not
>>accept complex expressions without parenthesis.
>
>
> And even so, the result is so unpredictible that most expressions split
> in several instructions.

Great, thanks.

Rich.

>
> -- Renaud
>


--
Richard Moore, Principle Software Engineer
Westpoint Ltd.