直接来自编译器源代码:
namespace Nemerle.English
{
[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.English", "and", false, 160, 161)]
[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.English", "or", false, 150, 151)]
[assembly: Nemerle.Internal.OperatorAttribute ("Nemerle.English", "not", true, 181, 180)]
macro @and (e1, e2) {
<[ $e1 && $e2 ]>
}
macro @or (e1, e2) {
<[ $e1 || $e2 ]>
}
macro @not (e) {
<[ ! $e ]>
}
您需要在周围撒上 OperatorAttributes,它会起作用。顺便说一句,OperatorAttribute 定义如下:
public class OperatorAttribute : NemerleAttribute
{
public mutable env : string;
public mutable name : string;
public mutable IsUnary : bool;
public mutable left : int;
public mutable right : int;
}