summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>2021-12-06 01:32:25 +0000
committerAidenRushbrooke <72034940+AidenRushbrooke@users.noreply.github.com>2021-12-06 01:32:25 +0000
commit4b05cca1920cc10aec16028c96c2899fe45f45c7 (patch)
tree45f00b67bf801018f4249c964be73e9312b5ed35 /src
parentd45507823215cb3e56ac4af181093fad999644aa (diff)
downloadesotericFORTRAN-4b05cca1920cc10aec16028c96c2899fe45f45c7.tar.gz
esotericFORTRAN-4b05cca1920cc10aec16028c96c2899fe45f45c7.zip
Added comment support
Diffstat (limited to 'src')
-rw-r--r--src/Compiler/TokenScanner.java7
-rw-r--r--src/examples/example.ft29
2 files changed, 20 insertions, 16 deletions
diff --git a/src/Compiler/TokenScanner.java b/src/Compiler/TokenScanner.java
index e1f5fff..7933aa1 100644
--- a/src/Compiler/TokenScanner.java
+++ b/src/Compiler/TokenScanner.java
@@ -58,6 +58,7 @@ public class TokenScanner {
//Some tokens are multiple characters long
//so need to check next char as well
+
case '*':
if (checkNextChar('*')){
createTokenNull(TokenType.EXPONENT);
@@ -124,6 +125,12 @@ public class TokenScanner {
createToken(TokenType.STRING, sourceCode.substring(tokenStart, currentLoc+1));
break;
+ case '!':
+ while(lookAhead()!='\n' && !checkEOF()){
+ currentLoc++;
+ }
+ break;
+
case '.':
if(checkIsAlpha(lookAhead()))
while (checkIsAlpha(lookAhead())){
diff --git a/src/examples/example.ft b/src/examples/example.ft
index 3d6f5f2..1d41963 100644
--- a/src/examples/example.ft
+++ b/src/examples/example.ft
@@ -1,21 +1,18 @@
program example
-int::a
-int::b
-int::c
-a=2+3
-b=3
-c=a**b
-print*,c
-
+real::a
+real::root
+a=25
+root=sqrt(a)
+print*,"The square root of ",a," is ",root
end program example
-
-function int power(int value,int power)
-int::i
-int::final
-final=1
-do i=0,power-1
-final=final*value
+!Function to calculate the square root of a value
+function real sqrt(real value)
+real::result
+result=1
+int::count
+do count=0,10
+result =(result+value/result)/2
end do
-return final
+return result
end \ No newline at end of file