Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nemerle Custom Operator Problem

Tags:

macros

nemerle

What would like to able to write in my code is the following.

c² = a² + b²

To begin with I tried creating a macro for ² first. I have tried the following.

  macro @² (x)
syntax (x,"²")
{
 <[ 
($x * $x)

  ]>
}

But I get expecting an identifier errors at the (x) So I tried

  macro @s (x)
syntax (x,"²")
{
 <[ 
($x * $x)

  ]>
}

Now I get Unsupported Syntax Token error at the "²".

So I ask 1. is possible to write the Operator ² ? 2. What are the supported Syntax Tokens?

like image 359
Adam Speight Avatar asked May 27 '26 05:05

Adam Speight


1 Answers

Currently, any character with an ASCII code lower than 255 and the following characters are valid for an operator: '=', '<', '>', '@', '^', '&', '-', '+', '|', '*','/', '$', '%', '!', '?', '~', '.', ':', '#', '\', '`', '(' , ')' , ';' , '[' , ']'.

We can add "²" too, but maybe a more generic approach would be better.

like image 91
user67754 Avatar answered May 31 '26 23:05

user67754



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!