This is a translator written in Haskell that translate a pseudocode source file into a Python script.
The adopted pseudocode language is from GCSE and Advanced Level's computer science textbook and 9618 syllabus.
- Install Glasgow Haskell Compiler.
- Run
compile.sh
on UNIX orcompile.cmd
on Windows. - An executable
campseudo-to-py
will be generated.
./campseudo-to-py file_path
.\campseudo-to-py.exe file_path
e.g. If the source file is hello.whatever
,
then hello.whatever.py
will be generated.
./run.sh file_path
.\run.cmd file_path
-
INTEGER
(by value) -
REAL
(by value) -
STRING
(by value) -
CHAR
(by value) -
BOOLEAN
(by value) -
ARRAY
(by reference, multi-dimensional) -
TYPE
(by value, enumerated) -
TYPE
(by reference, composite)
- Assignment
-
DECLARE
-
INPUT
/READ
-
OUTPUT
/PRINT
-
RETURN
-
CALL
-
IF THEN ENDIF
-
IF THEN ELSE ENDIF
-
WHILE DO ENDWHILE
/WHILE ENDWHILE
-
REPEAT UNTIL
-
FOR TO NEXT
/FOR TO ENDFOR
-
FOR TO STEP NEXT
/FOR TO STEP ENDFOR
-
CASE OF OTHERWISE ENDCASE
- Predicate
TO
inCASE
Due to the severe side effect caused by BYREF
, BYREF
will not be
implemented. See Data Type for default passing method.
-
PROCEDURE ENDPROCEDURE
-
FUNCTION ENDFUNCTION
Too many side effect! No pointers allowed!
-
OPEN FOR
/OPENFILE FOR
-
READFILE
-
WRITEFILE
-
EOF
-
CLOSEFILE
INT
CHR
ASC
LCASE
UCASE
TO_UPPER
TO_LOWER
LENGTH
LEFT
RIGHT
MID
NUM_TO_STRING
RAND