+3 is not a number

Anything that doesn't fit elsewhere.
Post Reply
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

+3 is not a number

Post by ted »

On 3/1/2005 Jose Ambros-Ingerson <jose@kiubo.net> wrote:
I just discovered that
oc> a = +3
gives you a parse error.
Isn't this kind of strange?
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

On 3/1/2005 Michael Hines <michael.hines@yale.edu> wrote:
Well, now that you mention it... What do you think of this:

Code: Select all

oc>---4
       -4
oc>----4
       4
All this is defined in the nrn/src/oc/parse.y where

Code: Select all

%left   '+' '-'      /* left associative, same precedence */
%left   '*' '/' '%'     /* left assoc., higher precedence */
%left   UNARYMINUS NOT
%right  '^'     /* exponentiation */
...
expr:   NUMBER
...
       | '-' expr %prec UNARYMINUS
               { TPD; $$ = $2; code(negate); PN;}
I suppose it would be possible to add a UNARYPLUS.
Then you could write things like

Code: Select all

---+-+++-4
I see from the above that

Code: Select all

!!!!4
also is valid.
Post Reply