MasC is a high level programming language.  It is like a mix between
Pascal ,C++ and Assembly language. This release is alpha since the 
syntax anaylizer is still fairly basic. (dosent report all errors).
What this project contains

a Lexical Anaylizer
a very basic syntax anaylizer
Parser
Intermediate code genereator
Intermediate code executor
C source code translator

I would like to thank Ronald Mak. For writing a really good book 
I read to make this. Its called Writing Compilers and Intrepreters 
A Approach using C++ . I took the information I learned in this book
and implemented it in C.


calling masc from the command line:

to compile out a MasC source code file to intermediate code you would 
use the following command.

masc source.extension -o outfile.masc

or for verbose mode
masc source.extension -o outfile.masc -v


To compile the source to C

masc source.extension -c outfile.masc

to execute the intermediate code

masc outfile.masc

or to print out debug information

masc outfile.masc -d

debug information is outputed to a HTML file

A basic MasC program:


# this is a hello world in MasC

mas Hello {

var { }

begin {

print << "Hello World" << "\n";
}

end {
print << "Goodbye world" << "\n";

}

}

variables:

TODO add arrays.

variable declerations
var& for integer
var$ for string
var! for floating point

variable declerations are put in the var { } block and can be followed
by = sign to set the inital value.

Example

mas Object {

var {

var& x = 100; # variable integer x equals 100
var$ str;
var$ str2 = "test";
var! float = 0.0f;

}

begin { } end { } 

}  

look in the examples directory for more examples
if you want to compile out the examples with cygwin or linux
just go into the examples directory and type make
or if you wanna run it in the interpreter type make interp



keywords list:

ADD, AND, BEGIN,CALL,CMP,DEC, DIV, END,EXIT,IN, INC,JE,JG,JGE,JL,JLE,
JNE,JMP,LOOP,LOOPN0,MAS, MOV, MUL, NOT, OR,POP,PRINT,PROC,  PUSH,RESET,RET,
SCAT,SLOOP,SUB, VAR, VAR_INT, VAR_STR, VAR_FLOAT, XOR, OB, CB ,EQ, OSTREAM,ISTREAM

add op1,op2; #add variable op1 plus op2 put value in op1
and op1,op2; #logical and variable op1 to op2 put value in op1
begin {} # block of code were exeuction starts is followed by {}
call procedure_name; # Call a Procedure
cmp op1,op2; #compare operand 1 to operand 2 put outcome to the virtual flags register 
dec op1; # decrement the variable
div op1,op2; # divide the operands
end {} #block of code where execution ends at
exit; # exit the application
in var; #input variable from stdin
inc op1; #increment the variable
je label; # jump if compare operation was equal
jg label; # jump if compare operation was greater
jge label; # jump if compare operation was greater then or equal to
jl label; # jump is compare operation was less than
jle label; # jump if compare operation was less than or equal to
jne label; #jump if not equal
jmp label; # jump nomatter what
loop; # first you type sloop variable then loop will loop until its less then 1
loopn0; # first you type sloop variable then loopn0 will loop until its not equal 0
mas objectName { } # special keyword for beginin of the object
mov op1,op2; # move operand 2 into operand 1 
mul op1,op2; # multiply operand1 by operand2
not op; # logical not the variable
or op1,op2; # logical or the two operands 
pop var; # pop item off the stack and put output into var
print var << second_Var << etc; # stream data to stdout
proc procedure_name { } # procedure keyword use this to define a procedure
push var; # push var onto the stack
reset; # reset the application
ret; # return from a procedure
scat str << var << etc; # stream data into a string variable
sloop var; # set the loop variable for loop and loopn0
var { } # block to put variables in each variable decleration is seperated by a ;
xor op1,op2; # logical xor the two operands.

