Coder Social home page Coder Social logo

cambridge-pseudocode-to-python's Introduction

Cambridge Pseudocode to Python

Intro

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.

How to Use?

Compile

  1. Install Glasgow Haskell Compiler.
  2. Run compile.sh on UNIX or compile.cmd on Windows.
  3. An executable campseudo-to-py will be generated.

Translate Pseudocode

UNIX

./campseudo-to-py file_path

Windows

.\campseudo-to-py.exe file_path

e.g. If the source file is hello.whatever, then hello.whatever.py will be generated.

Run Pseudocode

UNIX

./run.sh file_path

Windows

.\run.cmd file_path

Language Feature Supported

Data Type

  • 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)

Statement

  • Assignment
  • DECLARE
  • INPUT / READ
  • OUTPUT / PRINT
  • RETURN
  • CALL

Control Flow

  • 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 in CASE

Subroutine

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

Pointer

Too many side effect! No pointers allowed!

File

  • OPEN FOR / OPENFILE FOR
  • READFILE
  • WRITEFILE
  • EOF
  • CLOSEFILE

Built-in Functions

  • INT
  • CHR
  • ASC
  • LCASE
  • UCASE
  • TO_UPPER
  • TO_LOWER
  • LENGTH
  • LEFT
  • RIGHT
  • MID
  • NUM_TO_STRING
  • RAND

cambridge-pseudocode-to-python's People

Contributors

speedyorc-c avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.