My compiler & its forum
Posted: Tue May 08, 2012 7:33 am
Basic syntax of the language:
Keywords: void unsigned byte word dword int float vector typedef extern asm if else do while for switch case default break continue return stdcall
there is no struct keyword, use typedef to define custom type for structural operation instead
vector is keyword to declare a vector data type
typedef is keyword to declare a custom new type
stdcall is keyword of standard call convention for win32api
Directives: #include #define #code #data #rodata #if #ifdef #ifndef #endif
#include is directive to include file
#define is directive to define constant identifier
#code, #data, #rodata are directives to set respective segment alignment
#if, #ifdef, #ifndef, #endif are directives to do conditional compilation
Operators: () [] . - ~ & * * / % + - & | ^ << >> == != < > <= >= && || ^^ = += -= &= |= ^=
Declarations: type_expr id[,id_list];
Expressions:
Keywords: void unsigned byte word dword int float vector typedef extern asm if else do while for switch case default break continue return stdcall
there is no struct keyword, use typedef to define custom type for structural operation instead
vector is keyword to declare a vector data type
- vector type_expression id[, id_list];
- asm assembly_instruction
asm {assembly_instruction_list}
- extern declaration;
Code: Select all
extern float f;
extern void ExternalFunction(int value);
- typedef type_name {declaration, declaration_list}
typedef type_name type_expression
Code: Select all
typedef abc //abc is new type
{
int a;
int* b;
}
typedef xyz abc * //xyz is type alias of abc *
Code: Select all
extern void ExitProcess(stdcall UINT uExitCode);
#include is directive to include file
Code: Select all
#include "stdio.h"
Code: Select all
#define abc 1+2+3
#define pi 3.14
Code: Select all
#code 4 //code segment alignment is set to 4
#data 8 //data segment alignment is set to 8
#rodata 16 //readonly data segment alignment is set to 16
Code: Select all
#if abc > 100
//do something when abc > 100
#endif
#ifdef abc
//do something when abc was defined
#endif
#ifndef abc
//do something when abc was NOT defined
#endif
- priority is from left to right, leftmost is the highest
[] can be used to get string length / type size, its property is a constant value
Code: Select all
["This is a string"], [int] is equal to value 16, 4 respectively
Code: Select all
int a; //a is integer variable
int[4] b //b is an integer array, 4 elements
int[4]* c //c is a array pointer
int*[4]* d //d is a array pointer too, to whose elements are integer pointers
typedef abc //abc is new type
{
int a;
int* b;
}
typedef xyz abc * //xyz is type alias of abc *
abc e; //e is variable of type abc
abc* f; //f is pointer to type abc
vector int[4] g; //g is variable of vector int[4]
vector (int[4])* h; //h is pointer to vector int[4]
Code: Select all
(*c)[2]; //dereference pointer c, then access the third element
*(*d)[3]; //dereference pointer d, then dereference the last element
e.a; //member access of e
(*f).a; //dereference pointer f, then access member a
*(*f).b; //dereference pointer f, then dereference member b
g+g; //vector add
*h+*h; //dereference pointer h, then vector add