Page 1 of 1

My compiler & its forum

Posted: Tue May 08, 2012 7:33 am
by blackoil
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
  • vector type_expression id[, id_list];
asm is keyword to inline assembly instruction
  • asm assembly_instruction
    asm {assembly_instruction_list}
extern is keyword to import external symbol
  • extern declaration;

Code: Select all

extern float f;
extern void ExternalFunction(int value);
typedef is keyword to declare a custom new type
  • 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 *
stdcall is keyword of standard call convention for win32api

Code: Select all

extern void ExitProcess(stdcall UINT uExitCode);
Directives: #include #define #code #data #rodata #if #ifdef #ifndef #endif

#include is directive to include file

Code: Select all

#include "stdio.h"
#define is directive to define constant identifier

Code: Select all

#define abc 1+2+3
#define pi  3.14
#code, #data, #rodata are directives to set respective segment alignment

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
#if, #ifdef, #ifndef, #endif are directives to do conditional compilation

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
Operators: () [] . - ~ & * * / % + - & | ^ << >> == != < > <= >= && || ^^ = += -= &= |= ^=
  • 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
Declarations: type_expr id[,id_list];

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]
Expressions:

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

Re: My compiler & its forum

Posted: Tue May 08, 2012 12:38 pm
by AndrewAPrice
I see you put a lot of effort into this - well done!

What is the name of your language?

Can you show us a couple of example programs so that we can see its syntax and libraries in use?

Re: My compiler & its forum

Posted: Wed May 09, 2012 4:22 am
by LindusSystem
Try adding features that are not available in most of the compilers such as ??(I dont have any idea)

Re: My compiler & its forum

Posted: Wed May 09, 2012 9:28 am
by Jezze
You mean dereference right?

Re: My compiler & its forum

Posted: Thu May 10, 2012 2:31 am
by blackoil
I don't have nice name for it yet, and need time to write some documents for it.
use nasm, pelles libraries & linker.
to traditional C, the most difference is the declaration & pointer dereference.

Code: Select all

int	main(int argc,byte*[128]* argv)
{
	int i;

	for(i=1;i<argc;i+=1)
		puts((*argv)[i]);
}