Show/Hide Toolbars

XSharp

Expressions are an important element of the language. There are many types of expressions. The expression rule in the compiler is the biggest rule

The table below lists the various expression types in the order they are recognized by the compiler. Some expression types are covered in a separate topic.

As you can see most expression types are recursive. They contain one or more references to sub expressions

 

Expressions

 

Expression type

Syntax

Member Access

expression? (.|:) identifier

Member Access with Ampersand (resolved at runtime)

expression? (.|:) &identifier
expression? (.|:) &(expr)

Method Call

expression ( argumentlist? )

Arrayelement Access

expression [ argumentlist ]

Conditional Access

expression ? boundexpression

Typecast

( datatype )

Postfix

expression (++ | --)

Await

AWAIT expression

StackAlloc

STACKALLOC expression

Prefix

(+|-|~|@|++|--|^) expression

Typecheck

expression IS datatype VAR newVariable

As Typecheck

expresion ASTYPE datatype

Powerof

expression (^|**) expression

MulDiv

expression (*|/|%) expression

PlusMinus

expression (+|-) expression

LShift

expression << expression

RShift

expression >> expression

Comparison

expression OPERATOR expression,
where OPERATOR is
<,<=, >, >=, =, ==, $, !=, <>, #

Bitwise And

expression & expression

Bitwise XOR

expression ~ expression

Bitwise OR

expression | expression

Not Expression

(.NOT. | !) expression

Logical AND expression

expression (.AND.|&&) expression

Logical OR expression

expression (.OR. | ||) expression

Default expression

expression DEFAULT expression

Assignment expression

expression ASSIGN_OP expression
where ASSIGN_OP is
:=, +=, -=, *=, ^=, /=, %=, &=, |=, <<=, >>=, ~=, ??=

Primary expression

See other rule