#include <fortran.h>
real function f() code
return 0.0;
endfunction
program(main)
if 3 == 3 then
print(*) "Your PC is fine.";
elseif 3 == 4 then
print(*) "Your PC is broken.";
else
print(*) "Your PC is trash.";
endif
write(*, "(I)") 5);
end
I get the error expected unqualified-id before 'else'
in line number 10. I don't know why.
And in line number 16, the program should write '5' on the screen, but I get a runtime error.
Also, C++ is a case sensitive language, is there a way not to make C++ case sensitive?
FORTRAN.H is:
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
#define IF if(
#define THEN ){
#define ELSEIF } else if(
#define ELSE }else{
#define ENDIF }
#define if IF
#define then THEN
#define elseif ELSEIF
#define else ELSE
#define endif ENDIF
#define PROGRAM(x) main(){
#define program PROGRAM
#define END }
#define end END
#define STOP exit(0);
#define stop STOP
#define call
#define subroutine
#define recursive
#define function
#define FOR for(
#define for FOR
#define LOOP ){
#define loop LOOP
#define ENDFOR }
#define endfor ENDFOR
#define WHILE while(
#define DO ){
#define ENDDO }
#define enddo ENDDO
#define PRINT(t) std::cout<<
#define _ <<
#define READ std::cin>>
#define $ >>
#define Read READ
#define read READ
#define Print PRINT
#define print PRINT
#define selectcase(x) switch(x){
#define endselectcase }
#define endfunction }
#define code {
typedef char character;
typedef int integer;
typedef double doubleprecision;
typedef float real;
char* function __FORTRAN_WRITE_ARGS(const char* f) code
integer i;
std::__cxx11::string arg = "";
if f[0] != '(' || f[strlen(f)-1] != ')' then
return "";
endif
for i = 0; i < strlen(f); i++ loop
selectcase(f[i])
case ' ':
continue;
break;
case '(':
continue;
break;
case ')':
continue;
break;
case ',':
continue;
break;
case 'I':
if f[i+1] >= 48 && f[i+1] <= 57 then
arg += "%";
arg += f[i+1];
arg += "d";
else
arg += "%d";
endif
break;
default:
continue;
endselectcase
endfor
char retval[arg.length()] = "";
strcat(retval, arg.c_str());
return retval;
endfunction
#define write(t, f) printf(__FORTRAN_WRITE_ARGS(f),
#define endwrite )
#define WRITE write
#define precision
Is there any way to fix this issue or this error?