My compiler & its forum

Programming, for all ages and all languages.
Post Reply
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

My compiler & its forum

Post 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
Last edited by blackoil on Sat May 12, 2012 10:10 am, edited 4 times in total.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: My compiler & its forum

Post 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?
My OS is Perception.
LindusSystem
Member
Member
Posts: 63
Joined: Sat Apr 28, 2012 9:41 am
Location: Earth -> Asia

Re: My compiler & its forum

Post by LindusSystem »

Try adding features that are not available in most of the compilers such as ??(I dont have any idea)
Anyone has a idea of making a ntfs bootsector?if yes PM me , plz.
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Re: My compiler & its forum

Post by Jezze »

You mean dereference right?
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Re: My compiler & its forum

Post 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]);
}
Post Reply