Enhanced C#
Language of your choice: library documentation
|
Contains Precedence objects that represent the precedence rules of EC#. More...
Contains Precedence objects that represent the precedence rules of EC#.
Summary:
100+: Primary: x.y x::y f(x) a[i] etc.
90+: Prefix: + - ! ~ ++x –x (T)x
80+: Power: x**y
70+: Mult: * / %
60+: Add: + - (Shift is 56 but ideally would be 70)
50+: Range: .. (custom operators
are 28 to 55)
40+: Compare: < > <= >= is as using == !=
30+: Bitwise &^| (Ideally would be 54..59)
20+: Conditional && || ^^
10+: Ternary
1: Assignment
-1: Lambda (only the right-hand side of '=>')
When printing an expression, we avoid emitting x & y == z
because the ranges of == and & overlap. Instead EcsNodePrinter prints #&(x, y == z)
. Admittedly this is rather ugly, but you can enable the EcsNodePrinter.AllowExtraParenthesis option, which allows parenthesis to be added so that a Loyc tree with the structure #&(x, y == z)
is emitted as x & (y == z)
, even though the latter is a slightly different tree.
Most of the operators use a range of two adjacent numbers, e.g. 10..11. This represents a couple of ideas for future use in a compiler that allows you to define new operators; one idea is, you could give new operators the "same" precedence as existing operators, but make them immiscible with those operators... yet still make them miscible with another new operator. For instance, suppose you define two new operators glob
and fup
with PrecedenceRange 41..41 and 40..40 respectively. Then neither can be mixed with + and -, but they can be mixed with each other and fup
has higher precedence. Maybe this is not very useful, but hey, why not? If simply incrementing a number opens up new extensibility features, I'm happy to do it. (I could have used a non-numeric partial ordering system to do the same thing, but it would have been more complex, and of questionable value.)
Public static fields | |
static readonly Precedence | TightAttr = Precedence.MaxValue |
static readonly Precedence | Substitute = new Precedence(103, 102, 102, 103) |
static readonly Precedence | Primary = new Precedence(100) |
static readonly Precedence | NullDot = new Precedence(99) |
static readonly Precedence | Prefix = new Precedence(91, 90, 90, 91) |
static readonly Precedence | Forward = new Precedence(88) |
static readonly Precedence | Power = new Precedence(80) |
static readonly Precedence | Multiply = new Precedence(70) |
static readonly Precedence | Add = new Precedence(60) |
static readonly Precedence | Shift = new Precedence(56, 56, 56, 70) |
static readonly Precedence | Range = new Precedence(50) |
static readonly Precedence | Backtick = new Precedence(46, 72, 45, 73) |
static readonly Precedence | Compare = new Precedence(40) |
static readonly Precedence | IsAsUsing = new Precedence(40, 99, 40, 40) |
static readonly new Precedence | Equals = new Precedence(38) |
static readonly Precedence | AndBits = new Precedence(32, 32, 32, 45) |
static readonly Precedence | XorBits = new Precedence(30, 30, 32, 45) |
static readonly Precedence | OrBits = new Precedence(28, 28, 32, 45) |
static readonly Precedence | And = new Precedence(22) |
static readonly Precedence | Or = new Precedence(20) |
static readonly Precedence | OrIfNull = new Precedence(16) |
static readonly Precedence | IfElse = new Precedence(11, 10, 10, 11) |
static readonly Precedence | Assign = new Precedence(35, 0, 0, 1) |
static readonly Precedence | Lambda = new Precedence(85, -1, -2, -1) |