Enhanced C#
Language of your choice: library documentation
Public static fields | List of all members
Loyc.Syntax.CodeSymbols Class Reference

A list of common symbols that, by convention, have special meaning: operators, built-in data types, keywords, trivia, etc. More...


Source file:
Inheritance diagram for Loyc.Syntax.CodeSymbols:
Loyc.Ecs.EcsCodeSymbols

Remarks

A list of common symbols that, by convention, have special meaning: operators, built-in data types, keywords, trivia, etc.

Code that can use symbol forms directly, such as "'!=", tends to be very compact. The symbols in this class tend to be abbreviated in order to make usages of this class more compact (e.g. NotEq is short like its corresponding symbol "'!="). In C# one can access these symbols more easily with using static Loyc.Syntax.CodeSymbols or with using S = Loyc.Syntax.CodeSymbols as the Loyc codebase does.

Some symbols have an alternate name that starts with an underscore. For example, _Negate represents the unary minus operator, but in fact it is the same symbol as the subtraction operator Sub, '-.

Public static fields

static readonly Symbol Mul = GSymbol.Get("'*")
 "*" Multiplication (or dereference)
 
static readonly Symbol Div = GSymbol.Get("'/")
 "/" Division
 
static readonly Symbol Add = GSymbol.Get("'+")
 "+" Addition or unary +
 
static readonly Symbol Sub = GSymbol.Get("'-")
 "-" Subtraction or unary -
 
static readonly Symbol _Dereference = GSymbol.Get("'*")
 Alias for Mul.
 
static readonly Symbol _Pointer = GSymbol.Get("'*")
 Alias for Mul.
 
static readonly Symbol _UnaryPlus = GSymbol.Get("'+")
 Alias for Add.
 
static readonly Symbol _Negate = GSymbol.Get("'-")
 Alias for Sub. Infix and prefix operators use same symbol.
 
static readonly Symbol PreInc = GSymbol.Get("'++")
 "++" Unary prefix increment
 
static readonly Symbol PreDec = GSymbol.Get("'--")
 "--" Unary prefix decrement
 
static readonly Symbol PostInc = GSymbol.Get("'suf++")
 "suf++" Unary suffix increment
 
static readonly Symbol PostDec = GSymbol.Get("'suf--")
 "suf--" Unary suffix decrement
 
static readonly Symbol Mod = GSymbol.Get("'%")
 "%" Remainder operator
 
static readonly Symbol And = GSymbol.Get("'&&")
 "&&" Logical short-circuit 'and' operator
 
static readonly Symbol Or = GSymbol.Get("'||")
 "||" Logical short-circuit 'or' operator
 
static readonly Symbol Xor = GSymbol.Get("'^^")
 "^^" Logical 'xor' operator (tentative–this operator is redundant, "!=" is equivalent)
 
static readonly Symbol Eq = GSymbol.Get("'==")
 "==" Equality test operator
 
static readonly Symbol NotEq = GSymbol.Get("'!=")
 "!=" Inequality test operator
 
static readonly Symbol Neq = GSymbol.Get("'!=")
 "!=" Inequality test operator
 
static readonly Symbol GT = GSymbol.Get("'>")
 ">" Greater-than operator
 
static readonly Symbol GE = GSymbol.Get("'>=")
 ">=" Greater-than-or-equal-to operator
 
static readonly Symbol LT = GSymbol.Get("'<")
 "<" Less-than operator
 
static readonly Symbol LE = GSymbol.Get("'<=")
 "<=" Less-than-or-equal-to operator
 
static readonly Symbol Matches = GSymbol.Get("'=~")
 "=~" Pattern match test operator
 
static readonly Symbol Compare = GSymbol.Get("'<=>")
 "<=>" Three-way comparison a.k.a. shaceship operator
 
static readonly Symbol Shr = GSymbol.Get("'>>")
 ">>" Right-shift operator
 
static readonly Symbol Shl = GSymbol.Get("'<<")
 "<<" Left-shift operator
 
static readonly Symbol Not = GSymbol.Get("'!")
 "!" Logical 'not' operator
 
static readonly Symbol Assign = GSymbol.Get("'=")
 "=" Assignment operator
 
static readonly Symbol ForwardAssign = GSymbol.Get("'|=>")
 Assignment operator with reversed argument order (designed to resemble the pipe operator |>)
 
static readonly Symbol ForwardNullCoalesceAssign = GSymbol.Get("'?|=>")
 Null-coalescing assignment with reversed argument order.
 
static readonly Symbol OrBits = GSymbol.Get("'|")
 "|" Bitwise or operator
 
static readonly Symbol AndBits = GSymbol.Get("'&")
 "&" Bitwise and operator. Also, address-of (unary &)
 
static readonly Symbol _AddressOf = GSymbol.Get("'&")
 Alias for AndBits.
 
static readonly Symbol NotBits = GSymbol.Get("'~")
 Unary bitwise inversion operator.
 
static readonly Symbol _Concat = GSymbol.Get("'~")
 Alias for NotBits. Concat operator in D.
 
static readonly Symbol _Destruct = GSymbol.Get("'~")
 Alias for NotBits.
 
static readonly Symbol XorBits = GSymbol.Get("'^")
 "^" Bitwise exclusive-or operator
 
static readonly Symbol Braces = GSymbol.Get("'{}")
 "{}" Creates a scope.
 
static readonly Symbol IndexBracks = GSymbol.Get("'suf[]")
 
static readonly Symbol Array = GSymbol.Get("'[]")
 Used for list/array literals. Not used for attributes.
 
static readonly Symbol _Bracks = Array
 Synonym for Array (‘’[]`)
 
static readonly Symbol TwoDimensionalArray = GSymbol.Get("'[,]")
 int[,] <=> @'of(&lsquo;’[,]`, int)
 
static readonly Symbol Async = GSymbol.Get("#async")
 [#async] Task Foo(); <=> async Task Foo();
 
static readonly Symbol Await = GSymbol.Get("await")
 await(x); <=> await x; (TENTATIVE: should this be changed to #await?)
 
static readonly Symbol NullIndexBracks = GSymbol.Get("'?[]")
 <tt>?[](foo, #(1, A)) <=> foo?[1, A] (TENTATIVE, may be changed later) More...
 
static readonly Symbol InitializerAssignment = GSymbol.Get("'[]=")
 &lsquo;’[]=`(0, 1, x) <=> [0,1]=x
 
static readonly Symbol AltList = GSymbol.Get("#")
 # is used for lists of things in definition constructs, e.g. #class(Derived, #(Base, IEnumerable), {...}). For a time, 'tuple was used for this purpose; the problem is that a find-and-replace operation intended to find run-time tuples could accidentally match one of these lists. So I decided to dedicate # for use inside special constructs; its meaning depends on context. More...
 
static readonly Symbol _HashMark = GSymbol.Get("#")
 
static readonly Symbol QuestionMark = GSymbol.Get("'?")
 "'?" Conditional operator. (a?b:c) <=> &lsquo;’?(a,b,c) and int? <=> @'of(@'?`, int)
 
static readonly Symbol Of = GSymbol.Get("'of")
 "'of" for giving generic arguments. @'of(List,int) <=> List<int>
 
static readonly Symbol Dot = GSymbol.Get("'.")
 "'." binary dot operator, e.g. string.Join
 
static readonly Symbol NamedArg = GSymbol.Get("'::=")
 "'::=" Named argument e.g. ‘’::=`(x, 0) <=> x: 0
 
static readonly Symbol New = GSymbol.Get("'new")
 "'new": new Foo(x) { a } <=> <tt>'new(Foo(x), a); new[] { ... } <=> <tt>'new(<tt>[](), ...)
 
static readonly Symbol NewAttribute = GSymbol.Get("#new")
 "#new": public new void Foo() {} <=> [#public, #new] #fn(#void, Foo, #(), {})
 
static readonly Symbol Out = GSymbol.Get("#out")
 "#out": out x <=> [#out] x
 
static readonly Symbol Ref = GSymbol.Get("#ref")
 "#ref": ref int x <=> [#ref] #var(#int, x)
 
static readonly Symbol Sizeof = GSymbol.Get("'sizeof")
 "'sizeof" sizeof(int) <=> @'sizeof(int)
 
static readonly Symbol Typeof = GSymbol.Get("'typeof")
 
static readonly Symbol As = GSymbol.Get("'as")
 "'as": @'as(x,string) <=> x as string <=> x(as string)
 
static readonly Symbol Is = GSymbol.Get("'is")
 "'is": @'is(x,string) <=> x is string, @'is(x,#var(Foo,v),#(y,z)) <=> x is Foo v(y, z)
 
static readonly Symbol Cast = GSymbol.Get("'cast")
 "'cast": @'cast(x,int) <=> (int)x <=> x(-> int)
 
static readonly Symbol NullCoalesce = GSymbol.Get("'??")
 "'??": a ?? b <=> &lsquo;’??`(a, b)
 
static readonly Symbol PtrArrow = GSymbol.Get("'->")
 
static readonly Symbol ColonColon = GSymbol.Get("'::")
 "'::" Scope resolution operator in many languages
 
static readonly Symbol Lambda = GSymbol.Get("'=>")
 "'=>" used to define an anonymous function
 
static readonly Symbol Default = GSymbol.Get("'default")
 "'default" for the default(T) pseudofunction in C#
 
static readonly Symbol IS = GSymbol.Get("'IS")
 Backquoted suffixes in LES3 use this: xbytes <=> 'IS(x, bytes)
 
static readonly Symbol NullCoalesceAssign = GSymbol.Get("'??=")
 "'??=": a ??= b means a = a ?? b
 
static readonly Symbol MulAssign = GSymbol.Get("'*=")
 "'*=" multiply-and-set operator
 
static readonly Symbol DivAssign = GSymbol.Get("'/=")
 "'/=" divide-and-set operator
 
static readonly Symbol ModAssign = GSymbol.Get("'%=")
 "'%=" set-to-remainder operator
 
static readonly Symbol SubAssign = GSymbol.Get("'-=")
 "'-=" subtract-and-set operator
 
static readonly Symbol AddAssign = GSymbol.Get("'+=")
 "'+=" add-and-set operator
 
static readonly Symbol ConcatAssign = GSymbol.Get("'~=")
 "'~=" concatenate-and-set operator
 
static readonly Symbol ShrAssign = GSymbol.Get("'>>=")
 "'>>=" shift-right-by operator
 
static readonly Symbol ShlAssign = GSymbol.Get("'<<=")
 "'<<=" shift-left-by operator
 
static readonly Symbol ExpAssign = GSymbol.Get("'**=")
 "'**=" raise-to-exponent-and-set operator
 
static readonly Symbol XorBitsAssign = GSymbol.Get("'^=")
 "'^=" bitwise-xor-by operator
 
static readonly Symbol AndBitsAssign = GSymbol.Get("'&=")
 "'&=" bitwise-and-with operator
 
static readonly Symbol OrBitsAssign = GSymbol.Get("'|=")
 "'|=" set-bits operator
 
static readonly Symbol If = GSymbol.Get("#if")
 e.g. #if(c,x,y) and #if(c,x); I wanted it to be the conditional operator too, but the semantics are a bit different
 
static readonly Symbol DoWhile = GSymbol.Get("#doWhile")
 e.g. #doWhile(x++, condition); <=> do x++; while(condition);
 
static readonly Symbol While = GSymbol.Get("#while")
 e.g. #while(condition,{...}); <=> while(condition) {...}
 
static readonly Symbol UsingStmt = GSymbol.Get("#using")
 e.g. #using(expr, {...}); <=> using(expr) {...} (note: use #import or CodeSymbols.Import for a using directive)
 
static readonly Symbol For = GSymbol.Get("#for")
 e.g. #for(int i = 0, i < Count, i++, {...}); <=> for(int i = 0; i < Count; i++) {...}
 
static readonly Symbol ForEach = GSymbol.Get("#foreach")
 e.g. #foreach(#var(@``, n), list, {...}); <=> foreach(var n in list) {...}
 
static readonly Symbol Label = GSymbol.Get("#label")
 e.g. #label(success) <=> success:
 
static readonly Symbol Case = GSymbol.Get("#case")
 e.g. #case(10, 20) <=> case 10, 20:
 
static readonly Symbol Return = GSymbol.Get("#return")
 e.g. #return(x); <=> return x; [#yield] #return(x) <=> yield return x;
 
static readonly Symbol Continue = GSymbol.Get("#continue")
 e.g. #continue(); <=> continue;
 
static readonly Symbol Break = GSymbol.Get("#break")
 e.g. #break(); <=> break;
 
static readonly Symbol Goto = GSymbol.Get("#goto")
 e.g. #goto(label) <=> goto label;
 
static readonly Symbol GotoCase = GSymbol.Get("#gotoCase")
 e.g. #gotoCase(expr) <=> goto case expr;
 
static readonly Symbol Throw = GSymbol.Get("#throw")
 e.g. #throw(expr); <=> throw expr;
 
static readonly Symbol Checked = GSymbol.Get("#checked")
 e.g. #checked({ stmt; }); <=> checked { stmt; }
 
static readonly Symbol Unchecked = GSymbol.Get("#unchecked")
 e.g. #unchecked({ stmt; }); <=> unchecked { stmt; }
 
static readonly Symbol Fixed = GSymbol.Get("#fixed")
 e.g. #fixed(#var(@'of(&lsquo;’*`, #int32), x = &y), stmt); <=> fixed(int* x = &y) stmt;
 
static readonly Symbol Lock = GSymbol.Get("#lock")
 e.g. #lock(obj, stmt); <=> lock(obj) stmt;
 
static readonly Symbol Switch = GSymbol.Get("#switch")
 
static readonly Symbol SwitchStmt = GSymbol.Get("#switch")
 e.g. #switch(n, { ... }); <=> switch(n) { ... }
 
static readonly Symbol SwitchExpr = GSymbol.Get("'switch")
 e.g. @'switch(x, { ... }); <=> x switch { ... }
 
static readonly Symbol Try = GSymbol.Get("#try")
 e.g. #try({...}, #catch(<tt>, @, {...})); <=> try {...} catch {...}
 
static readonly Symbol Catch = GSymbol.Get("#catch")
 "#catch" catch clause of #try statement: #catch(#var(Exception,e), whenExpr, {...})
 
static readonly Symbol Finally = GSymbol.Get("#finally")
 "#finally" finally clause of #try statement: #finally({...})
 
static readonly Symbol Class = GSymbol.Get("#class")
 e.g. #class(Foo, #(IFoo), { }); <=> class Foo : IFoo { }
 
static readonly Symbol Struct = GSymbol.Get("#struct")
 e.g. #struct(Foo, #(IFoo), { }); <=> struct Foo : IFoo { }
 
static readonly Symbol Trait = GSymbol.Get("#trait")
 e.g. #trait(Foo, #(IFoo), { }); <=> trait Foo : IFoo { }
 
static readonly Symbol Enum = GSymbol.Get("#enum")
 e.g. #enum(Foo, #(byte), { }); <=> enum Foo : byte { }
 
static readonly Symbol Alias = GSymbol.Get("#alias")
 
static readonly Symbol Interface = GSymbol.Get("#interface")
 e.g. #interface(IB, #(IA), { }); <=> interface IB : IA { }
 
static readonly Symbol Namespace = GSymbol.Get("#namespace")
 e.g. #namespace(NS, @``, { }); <=> namespace NS { }
 
static readonly Symbol Var = GSymbol.Get("#var")
 e.g. #var(#int32, x = 0, y = 1, z); #var(@``, x = 0) <=> var x = 0;
 
static readonly Symbol Event = GSymbol.Get("#event")
 e.g. #event(EventHandler, Click, { }) <=> event EventHandler Click { }
 
static readonly Symbol Delegate = GSymbol.Get("#delegate")
 e.g. #delegate(#int32, Foo, @'tuple()); <=> delegate int Foo();
 
static readonly Symbol Property = GSymbol.Get("#property")
 e.g. #property(#int32, Foo, @``, { get; }) <=> int Foo { get; }
 
static readonly Symbol Where = GSymbol.Get("#where")
 "#where" e.g. class Foo<T> where T:class, Foo {} <=> #class(@'of(Foo, [#where(#class, Foo)] T), #(), {});
 
static readonly Symbol This = GSymbol.Get("#this")
 "#this" e.g. this.X <=> #this.X; this(arg) <=> #this(arg).
 
static readonly Symbol Base = GSymbol.Get("#base")
 "#base" e.g. base.X <=> #base.X; base(arg) <=> #base(arg).
 
static readonly Symbol Operator = GSymbol.Get("#operator")
 e.g. #fn(#bool, [#operator] &lsquo;’==`, #(Foo a, Foo b))
 
static readonly Symbol Implicit = GSymbol.Get("#implicit")
 e.g. [#implicit] #fn(#int32, [#operator] #cast, (Foo a,))
 
static readonly Symbol Explicit = GSymbol.Get("#explicit")
 e.g. [#explicit] #fn(#int32, [#operator] #cast, (Foo a,))
 
static readonly Symbol Missing = GSymbol.Empty
 Indicates that a syntax element was omitted, e.g. Foo(, y) => Foo(@``, y)
 
static readonly Symbol Splice = GSymbol.Get("#splice")
 When a macro returns #splice(a, b, c), the argument list (a, b, c) is spliced into the surrounding code.
 
static readonly Symbol Assembly = GSymbol.Get("#assembly")
 e.g. [assembly: Foo] <=> #assembly(Foo);
 
static readonly Symbol Module = GSymbol.Get("#module")
 e.g. [module: Foo] <=> [Foo] #module;
 
static readonly Symbol Import = GSymbol.Get("#import")
 #import is used instead of #using because the using(...) {...} statement already uses #using More...
 
static readonly Symbol Partial = GSymbol.Get("#partial")
 
static readonly Symbol Yield = GSymbol.Get("#yield")
 e.g. #return(x); <=> return x; [#yield] #return(x) <=> yield return x;
 
static readonly Symbol ArrayInit = GSymbol.Get("#arrayInit")
 C# e.g. int[] x = {1,2} <=> int[] x = #arrayInit(1, 2)
 
static readonly Symbol StackAlloc = GSymbol.Get("#stackalloc")
 #stackalloc for C# stackalloc (TODO)
 

Member Data Documentation

◆ Alias

readonly Symbol Loyc.Syntax.CodeSymbols.Alias = GSymbol.Get("#alias")
static

e.g. #alias(Int = int, #(IMath), { }); <=> alias Int = int : IMath { } also, [#filePrivate] #alias(I = System.Int32) <=> using I = System.Int32;

Referenced by Loyc.Ecs.EcsValidators.SpaceDefinitionKind(), and Loyc.LLParserGenerator.CodeGenHelperBase.VisitInput().

◆ AltList

readonly Symbol Loyc.Syntax.CodeSymbols.AltList = GSymbol.Get("#")
static

# is used for lists of things in definition constructs, e.g. #class(Derived, #(Base, IEnumerable), {...}). For a time, 'tuple was used for this purpose; the problem is that a find-and-replace operation intended to find run-time tuples could accidentally match one of these lists. So I decided to dedicate # for use inside special constructs; its meaning depends on context.

Referenced by Loyc.LLParserGenerator.CodeGenHelperBase.CreateTryWrapperForRecognizer(), Loyc.Ecs.EcsValidators.IsIsTest(), Loyc.Ecs.EcsValidators.IsPropertyDefinition(), Loyc.Ecs.EcsValidators.MethodDefinitionKind(), and Loyc.Ecs.EcsValidators.SpaceDefinitionKind().

◆ Import

readonly Symbol Loyc.Syntax.CodeSymbols.Import = GSymbol.Get("#import")
static

#import is used instead of #using because the using(...) {...} statement already uses #using

e.g. using System; <=> #import(System);

◆ IndexBracks

readonly Symbol Loyc.Syntax.CodeSymbols.IndexBracks = GSymbol.Get("'suf[]")
static

"'suf[]" indexing operator foo[1, A] <=> <tt>'suf[](foo, 1, A), but in a type context, Foo[] <=> @'of(&lsquo;’[]`, Foo)

◆ NullIndexBracks

readonly Symbol Loyc.Syntax.CodeSymbols.NullIndexBracks = GSymbol.Get("'?[]")
static

<tt>?[](foo, #(1, A)) <=> foo?[1, A] (TENTATIVE, may be changed later)

"?[]" indexing operator of C# 6

◆ Typeof

readonly Symbol Loyc.Syntax.CodeSymbols.Typeof = GSymbol.Get("'typeof")
static

"'typeof" typeof(Foo) <=> @'typeof(Foo), typeof<foo> <=> @'of(@'typeof, foo)