This is a C-like interpreter project developed as a final project for the CS220H Programming Languages course at Chung Yuan Christian University (CYCU) in 2022. It operates via a command-line interface, allowing users to execute code using C-style syntax. The interpreter supports fundamental features such as variable declaration, arithmetic operations, conditional statements, loops, function calls, pass-by-reference, and recursion.
- Java : jdk 8 or higher
- OS : Windows / macOS / Linux
- Data Types: Support for
int,float,char,string, andboolvariable declarations. - Arrays: Support for one-dimensional array declarations.
- Arithmetic Operators:
+,-,*,/,% - Relational Operators:
==,!=,<,>,<=,>= - Logical Operators:
&&,||,! - Unary Operators:
+,-,++,--,! - Assignment Operators:
=,+=,-=,*=,/=,%= - Ternary Operator:
? : - Control Flow:
if-elseconditional statements. - Loops:
whileanddo-whileloops. - Functions: Function declaration and invocation (supports pass-by-value, pass-by-reference, and passing arrays).
- Recursion: Support for recursive function calls.
- I/O Operations: Input and output using
cinandcout. - Comments: Support for single-line comments (
//). - Error Handling: Detection of lexical, syntactic, and semantic errors.
- Built-in Commands:
ListAllVariables,ListAllFunctions,ListVariable,ListFunction,Done.
Please execute the following commands from the project root directory:
javac -d bin -cp lib/HsiaNB50Lib.jar src/our_c_interpreter/*.javajar cvfm our_c_interpreter.jar manifest.txt -C bin .To run the program, please ensure that the lib folder (containing HsiaNB50Lib.jar) is located in the same directory as our_c_interpreter.jar.
Execute the following command:
java -jar our_c_interpreter.jarOnce started, you will enter the Our-C interface:
Our-C running ...
>For more information regarding Our-C usage, please refer to Our-C Overview.