A Python-based interpreter for CIE A-Level Computer Science pseudocode, designed to parse and execute pseudocode programs following the Cambridge International Examinations 9618 specification. Built with Lark parser generator and an AST tree-walking interpreter.
This is a demonstration project that implements only a subset of the full CIE 9618 pseudocode specification. It supports basic language constructs like variable declarations, assignments, arithmetic operations, and input/output, but does not implement advanced features such as:
- Arrays and complex data structures
- Procedures and functions
- Control flow statements (IF/THEN/ELSE, loops)
- File handling operations
- Advanced string operations
- Error handling constructs
For the complete official specification, refer to the CIE 9618 Pseudocode Guide for Teachers.
Disclaimer: This project is not affiliated with, endorsed by, or connected to Cambridge International Education. It is an independent educational tool created for learning purposes.
Currently supported pseudocode features:
- Data Types:
INTEGER
,REAL
,STRING
,BOOLEAN
- Variable Declarations:
DECLARE variable : TYPE
- Constants:
CONSTANT name = value
- Assignments:
variable <- expression
- Arithmetic Operations:
+
,-
,*
,/
,DIV
(integer division),MOD
- Logical Operations:
AND
,OR
,NOT
- Comparison Operations:
>
,<
,>=
,<=
,=
,<>
- Input/Output:
INPUT variable
,OUTPUT expression[, expression, ...]
- Comments:
// comment text
- Clone this repository:
git clone github.com/Steven-Gzc/pseudocie.git
cd pseudocie
- Install dependencies (requires Python 3.8+):
pip install lark
Run a pseudocode file:
python cli.py path\to\file.cie
Additional options:
python cli.py path\to\file.cie -t # Print parse tree
python cli.py path\to\file.cie -e # Show environment after execution
python cli.py path\to\file.cie -d # Dump parse tree to file
python cli.py tests\hello.cie
pseudocie/
├── cli.py # Command-line interface
├── grammar.lark # Lark grammar definition for CIE pseudocode
├── parse_utils.py # Parsing utilities
├── cie_runtime/ # Runtime execution engine
│ ├── __init__.py
│ ├── environment.py # Variable environment management
│ └── evaluator.py # Expression evaluation and program execution
├── tests/ # Example pseudocode programs
│ ├── hello.cie
│ ├── expressions.cie
│ ├── div_mod.cie
│ └── constants_and_reals.cie
└── README.md
This interpreter is a demonstration/educational tool and implements only basic pseudocode constructs. Missing features include:
- Uncommon Types:
DATE
,CHAR
- Control Structures:
IF...THEN...ELSE
,WHILE
,FOR
,REPEAT...UNTIL
- Subprograms:
PROCEDURE
,FUNCTION
- Data Structures: Arrays (
ARRAY[1:10] OF INTEGER
), records - Advanced I/O: File operations, formatted output
- String Manipulation: Advanced string functions
- Type Checking: Runtime type validation
- Error Handling:
TRY...EXCEPT
blocks
This project is intended as an educational demonstration. If you're working on extending CIE pseudocode support, consider:
- Adding control flow statements (IF/WHILE/FOR)
- Implementing procedures and functions
- Adding array and record support
- Improving error messages and debugging features
- Editor support (VS Code extension, syntax highlighting)
- Auto-completion for CIE pseudocode keywords and constructs
- Integration with popular IDEs
- Hand-written paper OCR for digitizing pseudocode from exam papers
- AI-generated exam-style questions and solutions for practice
This project is provided for educational purposes. Please refer to the official CIE documentation for complete pseudocode specifications.