This project is a custom programming language designed to closely follow the AQA pseudocode specification, implemented in C. It is designed for those who are familiar with AQA pseudocode and want a practical way to execute their pseudocode programs.
- Syntax: Follows the AQA pseudocode structure closely, making it easy to transition from pseudocode to an executable format.
- Performance: Implemented in C for efficient execution.
- Educational Use: Ideal for students preparing for exams or educators demonstrating AQA pseudocode concepts.
- Error Handling: Provides meaningful error messages based on common pseudocode mistakes.
To install and run the language on your machine, follow these steps:
-
Ensure you have a C compiler (e.g.,
gcc
) installed. On most Linux distributions, you can installgcc
using:sudo apt-get install build-essential # For Ubuntu/Debian
Or for macOS:
xcode-select --install
-
Clone the repository:
git clone https://github.com/mxcury/pCubedLang.git
-
Navigate to the project directory:
cd pCubedLang
-
Compile the source code using
make
:make
-
Install the executable:
sudo make install
-
Run the
p3
executable:p3
-
(Optional) To uninstall the program:
sudo make uninstall
After following these steps, you'll have the p3
interpreter installed and ready to run your pseudocode programs.
Once the interpreter is compiled and installed, you can write your pseudocode programs in a .p3
file and run them using the p3
executable:
p3 <yourfile.p3>
Example:
p3 hello_world.p3
To see the Abstract Syntax Tree (AST) produced during execution and how long the program took to run, use the --debug
flag:
p3 --debug <yourfile.p3>
This will output additional information, including the AST structure and execution time.
p3 --debug hello_world.p3
This command will:
- Compile and run
hello_world.p3
. - Output the AST generated by the parser.
- Display how long it took to run the program.
The language follows AQA pseudocode conventions, which include the following key elements:
-
Variables: Declared using
DECLARE
followed by the variable name and type.count <- 0
-
Input/Output: Supports
OUTPUT
,USERINPUT
, etc.OUTPUT "Enter a number" number <- USERINPUT
-
Control Flow: Includes
IF
,ELSE
,WHILE
,FOR
, and other standard constructs.IF number > 0 THEN OUTPUT "Positive" ELSE OUTPUT "Negative" ENDIF
-
Loops: Supports
FOR
,WHILE
, andREPEAT...UNTIL
loops.FOR i <- 1 TO 10 OUTPUT i ENDFOR
Here are some examples to demonstrate the language in action:
-
Hello World
OUTPUT "Hello, World!"
-
Sum of Numbers
sum <- 0 FOR i <- 1 TO 10 sum <- sum + i ENDFOR OUTPUT sum
-
Simple IF Statement
OUTPUT "Enter a number:" num <- USERINPUT num <- STRING_TO_INT(num) IF num > 0 THEN OUTPUT "Positive" ELSE OUTPUT "Negative or Zero" ENDIF
If you'd like to contribute to this project, feel free to fork the repository and submit a pull request. Please ensure your contributions adhere to the existing coding style and structure of the project.
- Fork the repository
- Create a new branch for your feature or bug fix
- Submit a pull request
This project is licensed under the MIT License. See the LICENSE
file for more details.