Skip to content

Commit

Permalink
Initial compiler version
Browse files Browse the repository at this point in the history
  • Loading branch information
markflorisson committed Jun 24, 2011
0 parents commit 9c93709
Show file tree
Hide file tree
Showing 19 changed files with 1,404 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="antlr-3.3-complete.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions .project
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SELMA</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Binary file added antlr-3.3-complete.jar
Binary file not shown.
31 changes: 31 additions & 0 deletions comm_dec_ass_print.SELMA
@@ -0,0 +1,31 @@
//Comment Testen
/* dit is
een comment
met meerdere
regels
*/
begin //start program
2*3;
//compound expression
var i: integer; //single var int decaration

5*8;
2*3*4;
5*i;
5>=6;
if true; then 5; fi;
if false; then 8; else 3; fi;
i := i := 5; //single assignment
print(i); //single print
var x,y: boolean; //double var bool declaration
var j: integer; //single var int declaration
j := i := j := 7; //double int assignment
print(i,j); //double print
const a: character = 'g'; //single const declaration
//const b: integer = 'l'; //single const declaration
const c: integer = 1; //single const declaration
j := i := 5*c; //double assignment & arith
j := i := 5;//true;
j := j := i;
print(i,j,c); //triple print
end. //end program
68 changes: 68 additions & 0 deletions g-files/Copy of SELMACode.stg
@@ -0,0 +1,68 @@
//SELMA string template

group SELMA;

program(instructions) ::= <<
; TAM assembler code generated by SELMACompiler
; comments at 50 whitespaces
; start of program
<instructions>
HALT ; end of program
>>

compound(instructions) ::= <<
; start compound
<instructions; separator="\n">
; end compound
>>


//Calculations
Expr(e1,op)::=<<
<e1> ; e1 for operation <op>
CALL <op> ; operation <op>
>>

biExpr(e1,e2,op)::=<<
<e1> ; e1 for operation <op>
<e2> ; e2 for operation <op>
CALL <op> ; operation <op>
>>

//Declare
declareConst(id,val,type,addr)::=<<
LOADL <val> ; declare var <id>: <type> = <val> @ <addr>[SB]
>>

declareVar(id,type,addr)::=<<
PUSH 1 ; declare var <id>: <type> @ <addr>[SB]
>>

//Load
loadNum(val)::=<<
LOADL <val> ; loadNum <val>
>>

loadVal(id,addr)::=<<
LOAD(1) <addr>[SB] ; loadVal <id> from <addr>[SB]
>>

//Assign
assign(id,type,addr,e1)::=<<
<e1> ; e1 right hand for assignment
STORE(1) <addr>[SB] ; assign e1 to <id>: <type> @ <addr>[SB]
>>

//conditionals
if(ec1,ec2,ec3)::=<<
<ec1> ; e1 right hand for assignment
<ec2> ; e2 right hand for assignment
<ec3> ; e3 right hand for assignment
hier hoort een if
>>

while(ec1,ec2)::=<<
//<ec1> ; e1 right hand for assignment
//<ec2> ; e2 right hand for assignment
//hier hoort een while
>>

0 comments on commit 9c93709

Please sign in to comment.