Implemented comments, finished program 4

This commit is contained in:
Mariano Uvalle 2019-05-04 23:22:13 -05:00
parent 41ff0ea77c
commit 98b720fdac
3 changed files with 88 additions and 1 deletions

View file

@ -170,7 +170,7 @@ t_plus = r'\+'
t_minus = r'-'
t_mul = r'\*'
t_string = r'\'[a-zA-Z0-9 \?\:\t\r\n\f()\[\]\&\!\@\#\$\%\^\-\=\+\/\,]*\''
t_comment = r'![a-zA-Z0-9 \?\:\t\r\n\f()\[\]\&\!\@\#\$\%\^\-\=\+\/\,]*!'
t_comment = r'![a-zA-Z0-9 \?\:\t\r\n\f()\[\]\&\!\@\#\$\%\^\-\=\+\/\,]*\n'
t_or = r'\.or\.'
t_and = r'\.and\.'
t_not = r'\.not\.'

View file

@ -0,0 +1,38 @@
program p4
integer :: number
subroutine readNumber
do then
!Asking the user for the number
print 'Enter your number: ', endline
read number
!Verifying that the number is withing the desired range
if (number >= 0 .and. number <= 7) then
exit
end if
print 'Number must be between 0 and 7', endline
end do
end subroutine
readNumber()
!Printing the adequate string for every number
print 'Your number is: '
if (number == 0) then
print 'zero'
elif (number == 1) then
print 'one'
elif (number == 2) then
print 'two'
elif (number == 3) then
print 'three'
elif (number == 4) then
print 'four'
elif (number == 5) then
print 'five'
elif (number == 6) then
print 'six'
elif (number == 7) then
print 'seven'
else
print 'unknown'
end if
print endline
end program

View file

@ -0,0 +1,49 @@
goto 14
print 'Enter your number: '
print endline
read $200
>= $200 0 $0
<= $200 7 $1
.and. $0 $1 $2
gotoF $2 10
goto 13
print 'Number must be between 0 and 7'
print endline
goto 2
goback
call 2
print 'Your number is: '
== $200 0 $2
gotoF $2 20
print 'zero'
goto 49
== $200 1 $2
gotoF $2 24
print 'one'
goto 49
== $200 2 $2
gotoF $2 28
print 'two'
goto 49
== $200 3 $2
gotoF $2 32
print 'three'
goto 49
== $200 4 $2
gotoF $2 36
print 'four'
goto 49
== $200 5 $2
gotoF $2 40
print 'five'
goto 49
== $200 6 $2
gotoF $2 44
print 'six'
goto 49
== $200 7 $2
gotoF $2 48
print 'seven'
goto 49
print 'unknown'
print endline