FluxSharp Syntax
Core syntax rules and language structure.
Comments
Single-line Comments
// This is a comment
int x = 10; // Comment at end of line
Multi-line Comments
/ This is a
multi-line
comment /
Identifiers
Valid identifiers must:
Start with letter (A-Z, a-z)
Contain letters, digits, or underscore
Be case-sensitive
int myVariable;
int private;
int MAXVALUE;
int value123;
Keywords
Reserved words: Types:
int
,
uint
,
long
,
float
,
double
,
ulong
,
byte
,
string
,
bool
,
void
Declarations:
const
,
struct
,
class
,
public
,
private
,
static
Control:
if
,
else
,
while
,
for
,
return
,
break
,
continue
Async:
async
,
await
Other:
true
,
false
Literals
Integer Literals
int decimal = 42;
int hexadecimal = 0xFF; // 255
int binary = 0b1010; // 10
int octal = 0o77; // 63
Floating Point Literals
float single = 3.14f;
double dbl = 3.14159;
double scientific = 1.5e-10;
String Literals
string text = "Hello World";
string empty = "";
string escaped = "Line1\nLine2";
Character Literals
char ch = 'A';
char newline = '\n';
Boolean Literals
bool yes = true;
bool no = false;
Type Declaration
Primitive Types
int number; // 64-bit integer
uint unsigned; // Unsigned integer
long large; // Large integer
float decimal; // 32-bit float
double precise; // 64-bit double
ulong unsignedlong; // Unsigned long
byte small; // 8-bit byte
string text; // Text string
bool flag; // Boolean
void nothing; // No value (functions only)
Custom Types
Point location; // Custom class/struct
CustomType instance; // Any defined type
Operators and Expressions
Arithmetic Operators
int a = 5 + 3; // Addition
int b = 5 - 3; // Subtraction
int c = 5 3; // Multiplication
int d = 5 / 3; // Division
int e = 5 % 3; // Modulo
Comparison Operators
a < b // Less than
a > b // Greater than
a <= b // Less or equal
a >= b // Greater or equal
a == b // Equal
a != b // Not equal
Logical Operators
a && b // AND
a || b // OR
!a // NOT
Bitwise Operators
a & b // AND
a | b // OR
a ^ b // XOR
~a // NOT
a << b // Left shift
a >> b // Right shift
Assignment Operators
x = 10; // Assign
x += 5; // Add and assign
x -= 5; // Subtract and assign
x++; // Increment
x--; // Decrement
Expressions
Basic expression syntax:
atom [ (arithop | bitwise_op) atom ]
Examples:
x + y 2
a & b | c
value + 10 - 5
Statements
Statements end with semicolon (
;
):
int x = 10;
x = 20;
print(x);
return;
Blocks
Blocks contain statements in braces:
{
int x = 10;
string name = "test";
return;
}
Functions
Basic function syntax:
public void FunctionName() {
// Body
}
public int Add(int a, int b) {
return a + b;
}
async public void AsyncFunction() {
// Async body
}
Classes
Class structure:
public class ClassName {
public int property;
private string field;
public void Method() {
// Implementation
}
}
Structs
Struct structure:
public struct StructName {
int field1;
string field2;
}
Arrays
Array declaration:
int[100] numbers; // Array of 100 ints
string[256] names; // Array of 256 strings
byte[80 25] screen; // Array with expression size
Access Modifiers
public int visible; // Accessible from outside
private int hidden; // Only within class
static int shared; // Class-level (not instance)
Variable Declaration
int x; // Declaration
int y = 10; // Declaration with initialization
const int MAX = 100; // Constant
Function Calls
Print("Hello"); // Simple call
int result = Add(5, 3); // Call with arguments
obj.Method(); // Method call
Async/Await Syntax
async public void FetchData() {
string data = await GetData("url");
return;
}
Naming Conventions
Functions:
PascalCase
-
GetName()
,
CalculateSum()
Variables:
camelCase
or
snake_case
-
myVariable
,
my_variable
Constants:
UPPER_CASE
-
MAX_SIZE
,
DEFAULT_VALUE
Classes:
PascalCase
-
Person
,
DataManager
Structs:
PascalCase
-
Point
,
Rectangle
Next: Read TYPES.md