Compare commits
No commits in common. "befe8f93a2a0bca61d5474c6da4b508dc7f1782b" and "3f58bdfad901cc6a33adf01634cc09dcc43baddc" have entirely different histories.
befe8f93a2
...
3f58bdfad9
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
|
||||||
<classpathentry kind="output" path="bin/default"/>
|
|
||||||
</classpath>
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -63,6 +63,3 @@ local.properties
|
|||||||
|
|
||||||
# tam files
|
# tam files
|
||||||
*.tam
|
*.tam
|
||||||
|
|
||||||
# Build folder
|
|
||||||
/build/
|
|
||||||
|
6
.project
6
.project
@ -5,11 +5,6 @@
|
|||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
@ -17,7 +12,6 @@
|
|||||||
</buildCommand>
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
@ -20,11 +20,4 @@
|
|||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
<linkedResources>
|
|
||||||
<link>
|
|
||||||
<name>programs</name>
|
|
||||||
<type>2</type>
|
|
||||||
<location>/home/simon/Documents/Uni/CS/CSCU9A5/Triangle-Tools/programs</location>
|
|
||||||
</link>
|
|
||||||
</linkedResources>
|
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
@ -73,16 +73,6 @@ public final class Scanner {
|
|||||||
takeIt();
|
takeIt();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// new type of comment, the # comment, same as before when it comes to code
|
|
||||||
case '#':{
|
|
||||||
takeIt();
|
|
||||||
while((currentChar != SourceFile.EOL) && (currentChar != SourceFile.EOT))
|
|
||||||
takeIt();
|
|
||||||
if(currentChar == SourceFile.EOL)
|
|
||||||
takeIt();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// whitespace
|
// whitespace
|
||||||
case ' ':
|
case ' ':
|
||||||
@ -262,7 +252,7 @@ public final class Scanner {
|
|||||||
currentlyScanningToken = false;
|
currentlyScanningToken = false;
|
||||||
// skip any whitespace or comments
|
// skip any whitespace or comments
|
||||||
while (currentChar == '!' || currentChar == ' ' || currentChar == '\n' || currentChar == '\r'
|
while (currentChar == '!' || currentChar == ' ' || currentChar == '\n' || currentChar == '\r'
|
||||||
|| currentChar == '\t' || currentChar == '#')
|
|| currentChar == '\t')
|
||||||
scanSeparator();
|
scanSeparator();
|
||||||
|
|
||||||
currentlyScanningToken = true;
|
currentlyScanningToken = true;
|
||||||
|
@ -22,7 +22,7 @@ public class TestScanner {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHiNewComment() {
|
public void testHiNewComment() {
|
||||||
compileExpectSuccess("/hi-newcomment.tri");
|
compileExpectFailure("/hi-newcomment.tri");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -43,12 +43,6 @@ public class TestScanner {
|
|||||||
compileExpectFailure("/repeatuntil.tri");
|
compileExpectFailure("/repeatuntil.tri");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAdd() {
|
|
||||||
//compileExpectFailure("/addd.tri"); //fail here!
|
|
||||||
compileExpectFailure("/add.tri");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void compileExpectSuccess(String filename) {
|
private void compileExpectSuccess(String filename) {
|
||||||
|
Binary file not shown.
@ -1,46 +0,0 @@
|
|||||||
! Program that will: read two ints, print their sum and their product. If they are the same, print "Same"
|
|
||||||
|
|
||||||
! Global Consts, Funcs.
|
|
||||||
let
|
|
||||||
type String ~ array 6 of Char; ! String type implemented, not used yet
|
|
||||||
|
|
||||||
var num1 : Integer;
|
|
||||||
var num2 : Integer;
|
|
||||||
|
|
||||||
|
|
||||||
func sum(x : Integer, y : Integer) : Integer ~
|
|
||||||
x + y; ! Return x + y
|
|
||||||
|
|
||||||
func product(x : Integer, y : Integer) : Integer ~
|
|
||||||
x * y; ! Return x * y
|
|
||||||
|
|
||||||
func isSame(x : Integer, y : Integer) : Boolean ~
|
|
||||||
if x = y then true else false
|
|
||||||
|
|
||||||
! Main Loop
|
|
||||||
in
|
|
||||||
begin
|
|
||||||
num1 := 0;
|
|
||||||
num2 := 0; ! Init. values to 0
|
|
||||||
|
|
||||||
getint(var num1);
|
|
||||||
getint(var num2); ! Get user input
|
|
||||||
|
|
||||||
|
|
||||||
! Sum
|
|
||||||
putint(num1); put('+'); put(' '); putint(num2); put(' '); put('='); put(' ');
|
|
||||||
putint(sum(num1, num2)); puteol();
|
|
||||||
|
|
||||||
puteol();
|
|
||||||
|
|
||||||
! Product
|
|
||||||
putint(num1); put(' '); put('*'); put(' '); putint(num2); put(' '); put('='); put(' ');
|
|
||||||
putint(product(num1, num2)); puteol();
|
|
||||||
|
|
||||||
|
|
||||||
if isSame(num1, num2) = true then
|
|
||||||
put('S'); put('a'); put('m'); put('e'); puteol();
|
|
||||||
else
|
|
||||||
puteol();
|
|
||||||
|
|
||||||
end
|
|
@ -1,30 +0,0 @@
|
|||||||
! Program with a variety of contextual errors.
|
|
||||||
|
|
||||||
let
|
|
||||||
type String ~ array 4 of Char;
|
|
||||||
type Name ~ array 3 of String;
|
|
||||||
type Rec ~ record x: Integer, x: Integer end;
|
|
||||||
|
|
||||||
var me: Name;
|
|
||||||
var silly : maxint;
|
|
||||||
var silly: Rec;
|
|
||||||
|
|
||||||
proc putstr (s: String) ~
|
|
||||||
let var i: Integer
|
|
||||||
in
|
|
||||||
begin
|
|
||||||
s[4] := ' ';
|
|
||||||
i := 0;
|
|
||||||
while i do
|
|
||||||
begin i := i+true;
|
|
||||||
put (s[\i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
in
|
|
||||||
begin
|
|
||||||
me[true] := ['T','i','n','y'];
|
|
||||||
me[2][2] := 0;
|
|
||||||
put (me[1]); put (4); put ();
|
|
||||||
putstr (initials (me)); puteol ()
|
|
||||||
end
|
|
3
tam
3
tam
@ -16,8 +16,7 @@ fi
|
|||||||
|
|
||||||
printf "${GRN}Compiling file: $1.tri to $1.tam ...${NC}\n"
|
printf "${GRN}Compiling file: $1.tri to $1.tam ...${NC}\n"
|
||||||
# Compile to tam
|
# Compile to tam
|
||||||
#java -cp build/libs/Triangle-Tools.jar triangle.Compiler programs/$1.tri -o=$1.tam &> /dev/null #Quiet output, not handy!
|
java -cp build/libs/Triangle-Tools.jar triangle.Compiler programs/$1.tri -o=$1.tam &> /dev/null
|
||||||
java -cp build/libs/Triangle-Tools.jar triangle.Compiler programs/$1.tri -o=$1.tam
|
|
||||||
|
|
||||||
printf "${GRN}Running file: $1.tam ...${NC}\n"
|
printf "${GRN}Running file: $1.tam ...${NC}\n"
|
||||||
# Run the Program
|
# Run the Program
|
||||||
|
Reference in New Issue
Block a user