diff options
| author | AidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com> | 2021-12-09 02:30:57 +0000 | 
|---|---|---|
| committer | AidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com> | 2021-12-09 02:30:57 +0000 | 
| commit | 13c44054b21d26782e98a52e9a114250ab8307ff (patch) | |
| tree | 8426476b4daeee01b85cc3f414d04335dbf0a87d | |
| parent | 560a48eebf4f74ae1a21d5cfbb3b55477d7c1356 (diff) | |
| download | esotericFORTRAN-13c44054b21d26782e98a52e9a114250ab8307ff.tar.gz esotericFORTRAN-13c44054b21d26782e98a52e9a114250ab8307ff.zip | |
Added example program of each main feature
| -rw-r--r-- | src/IDE/IDE/HelloApplication.java | 25 | ||||
| -rw-r--r-- | src/IDE/IDE/HelloController.java | 14 | ||||
| -rw-r--r-- | src/IDE/IDE/hello-view.fxml | 16 | ||||
| -rw-r--r-- | src/IDE/Makefile | 5 | ||||
| -rw-r--r-- | src/IDE/readme.md | 19 | ||||
| -rw-r--r-- | src/examples/array.ft | 13 | ||||
| -rw-r--r-- | src/examples/conditional.ft | 11 | ||||
| -rw-r--r-- | src/examples/doStatement.ft | 6 | ||||
| -rw-r--r-- | src/examples/doWhileStatement.ft | 8 | ||||
| -rw-r--r-- | src/examples/expression.ft | 5 | ||||
| -rw-r--r-- | src/examples/function.ft (renamed from src/examples/example.ft) | 2 | ||||
| -rw-r--r-- | src/examples/iteration.ft | 8 | ||||
| -rw-r--r-- | src/examples/selection.ft | 6 | ||||
| -rw-r--r-- | src/examples/sieve.ft | 48 | ||||
| -rw-r--r-- | src/examples/string.ft | 5 | ||||
| -rw-r--r-- | src/examples/subroutine.ft | 9 | 
16 files changed, 106 insertions, 94 deletions
| diff --git a/src/IDE/IDE/HelloApplication.java b/src/IDE/IDE/HelloApplication.java deleted file mode 100644 index aaa728f..0000000 --- a/src/IDE/IDE/HelloApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -package IDE; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Scene; -import javafx.stage.Stage; -import java.io.File; -import javafx.scene.Parent; - -import java.io.IOException; - -public class HelloApplication extends Application { -    @Override -    public void start(Stage stage) throws IOException { -        Parent root = FXMLLoader.load(getClass().getResource("hello-view.fxml")); -        Scene scene = new Scene(root, 320, 240); -        stage.setTitle("Hello!"); -        stage.setScene(scene); -        stage.show(); -    } - -    public static void main(String[] args) { -        launch(); -    } -}
\ No newline at end of file diff --git a/src/IDE/IDE/HelloController.java b/src/IDE/IDE/HelloController.java deleted file mode 100644 index 877e5ba..0000000 --- a/src/IDE/IDE/HelloController.java +++ /dev/null @@ -1,14 +0,0 @@ -package IDE; - -import javafx.fxml.FXML; -import javafx.scene.control.Label; - -public class HelloController { -    @FXML -    private Label welcomeText; - -    @FXML -    protected void onHelloButtonClick() { -        welcomeText.setText("Welcome to the FORTRAN compiler application!"); -    } -}
\ No newline at end of file diff --git a/src/IDE/IDE/hello-view.fxml b/src/IDE/IDE/hello-view.fxml deleted file mode 100644 index c31d9e2..0000000 --- a/src/IDE/IDE/hello-view.fxml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import javafx.geometry.Insets?> -<?import javafx.scene.control.Label?> -<?import javafx.scene.layout.VBox?> - -<?import javafx.scene.control.Button?> -<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml" -      fx:controller="IDE.HelloController"> -    <padding> -        <Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/> -    </padding> - -    <Label fx:id="welcomeText"/> -    <Button text="Hello!" onAction="#onHelloButtonClick"/> -</VBox> diff --git a/src/IDE/Makefile b/src/IDE/Makefile deleted file mode 100644 index 127db02..0000000 --- a/src/IDE/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: -	javac --module-path ../../../javafx-sdk-17.0.1/lib/ --add-modules javafx.controls,javafx.fxml ./IDE/*.java - -clean: -	rm -vf IDE/*.class diff --git a/src/IDE/readme.md b/src/IDE/readme.md deleted file mode 100644 index 0dc9faa..0000000 --- a/src/IDE/readme.md +++ /dev/null @@ -1,19 +0,0 @@ -# esotericFORTRAN IDE - -## Setting Up - -Install FXML from [here](https://gluonhq.com/products/javafx/) and extract it in the directory behind `EsotericProject` - -## Running - -To compile, simply run `make`. Then to run: - -`java --module-path ..\..\..\javafx-sdk-17.0.1\lib\ --add-modules javafx.controls,javafx.fxml IDE.HelloApplication` - -## Editors? - -If you got intellisense and stuff to work in vscodium, well done, coz I couldn't do that :3 - -### IntelliJ - -I hate IntelliJ but its the only way I could get a working intellisense. Right click on this folder and select 'Open Folder as an IntelliJ IDEA Community Edition Project', then follow [this](https://openjfx.io/openjfx-docs/#install-javafx) guide (select 'JavaFX and IntelliJ' in the website sidebar).
\ No newline at end of file diff --git a/src/examples/array.ft b/src/examples/array.ft new file mode 100644 index 0000000..6f62940 --- /dev/null +++ b/src/examples/array.ft @@ -0,0 +1,13 @@ +program array +int dimension(10)::a +int::i + +do i=0,9 +a(i)=i*2 +end do + +do i=0,9 +print*,a(i) +end do + +end program array
\ No newline at end of file diff --git a/src/examples/conditional.ft b/src/examples/conditional.ft new file mode 100644 index 0000000..6d3f79d --- /dev/null +++ b/src/examples/conditional.ft @@ -0,0 +1,11 @@ +program conditional +int::a +int::b +a=5 +b=7 +if a>=b then +print*,a," is greater than or equal to ",b +else +print*,a," is less than ",b +end if +end program conditional
\ No newline at end of file diff --git a/src/examples/doStatement.ft b/src/examples/doStatement.ft new file mode 100644 index 0000000..ddee000 --- /dev/null +++ b/src/examples/doStatement.ft @@ -0,0 +1,6 @@ +program doStatement +int::i +do i=0,10 +print*,i +end do +end program doStatement
\ No newline at end of file diff --git a/src/examples/doWhileStatement.ft b/src/examples/doWhileStatement.ft new file mode 100644 index 0000000..a8aa096 --- /dev/null +++ b/src/examples/doWhileStatement.ft @@ -0,0 +1,8 @@ +program doWhileStatement +int::i +i=0 +do while(i<=10) +print*,i +i=i+1 +end do +end program doWhileStatement
\ No newline at end of file diff --git a/src/examples/expression.ft b/src/examples/expression.ft new file mode 100644 index 0000000..c3420fe --- /dev/null +++ b/src/examples/expression.ft @@ -0,0 +1,5 @@ +program expression +int::a +a=(5+4)*(10/2)+5**2 +print*,a +end program expression
\ No newline at end of file diff --git a/src/examples/example.ft b/src/examples/function.ft index 571cace..2c6ed7d 100644 --- a/src/examples/example.ft +++ b/src/examples/function.ft @@ -2,7 +2,7 @@ program example  real::a  real::root  a=30 -root=sqrt(25+5) +root=sqrt(a)  print*,"The square root of ",a," is ",root  end program example diff --git a/src/examples/iteration.ft b/src/examples/iteration.ft deleted file mode 100644 index 22a2bfb..0000000 --- a/src/examples/iteration.ft +++ /dev/null @@ -1,8 +0,0 @@ -int dimension(5)::test -int::i -do i=0,4 -test(i)=i -end do -do i=0,4 -print*,test(i) -end do
\ No newline at end of file diff --git a/src/examples/selection.ft b/src/examples/selection.ft deleted file mode 100644 index 21100b2..0000000 --- a/src/examples/selection.ft +++ /dev/null @@ -1,6 +0,0 @@ -character (len=10)::hello -hello="hello" -if 4==5 then -hello="goodbye " -endif -print *,hello,6," world" endprint
\ No newline at end of file diff --git a/src/examples/sieve.ft b/src/examples/sieve.ft new file mode 100644 index 0000000..e771009 --- /dev/null +++ b/src/examples/sieve.ft @@ -0,0 +1,48 @@ +!Program to calculate all primes below a certain value +program sieveOfEratosthenes + +	!define variables +	int::n +	n=10000 +	int dimension(10000)::checks +	int::i +	int::j + +	!initialise array +	do i=2,n +		checks(i)=1 +	end do +	i=2 + +	!search for primes +	do while(i<root(n)) +		if checks(i)==1 then +			j=i**2 +			do while(j<n) +				checks(j)=0 +				j=j+i +			end do +		end if +		i=i+1 +	end do + +	!output primes found +	print*,"Primes below ",n +	do i=2,n +		if checks(i)==1 then +			print*,i +		end if +	end do +end program sieveOfEratosthenes + + +!Function to find the square root of a value +function real root(int value) +	real::result +	result=1 +	int::count +	do count=0,10 +		result =(result+value/result)/2 +	end do +	return result +end
\ No newline at end of file diff --git a/src/examples/string.ft b/src/examples/string.ft new file mode 100644 index 0000000..dc7ed08 --- /dev/null +++ b/src/examples/string.ft @@ -0,0 +1,5 @@ +program string +character(len=15)::a +a="Hello World!" +print*,a +end program string
\ No newline at end of file diff --git a/src/examples/subroutine.ft b/src/examples/subroutine.ft new file mode 100644 index 0000000..58171b8 --- /dev/null +++ b/src/examples/subroutine.ft @@ -0,0 +1,9 @@ +program subroutineExample +calc(3,4,5) +end program subroutineExample + +subroutine calc(int a,int b,int c) +int::total +total=a*b*c +print*,total +end
\ No newline at end of file | 
