Skip to content

paulwang19/our-c-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Our-C Interpreter

Introduction

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.

Prerequisites

  • Java : jdk 8 or higher
  • OS : Windows / macOS / Linux

Features

  • Data Types: Support for int, float, char, string, and bool variable declarations.
  • Arrays: Support for one-dimensional array declarations.
  • Arithmetic Operators: +, -, *, /, %
  • Relational Operators: ==, !=, <, >, <=, >=
  • Logical Operators: &&, ||, !
  • Unary Operators: +, -, ++, --, !
  • Assignment Operators: =, +=, -=, *=, /=, %=
  • Ternary Operator: ? :
  • Control Flow: if-else conditional statements.
  • Loops: while and do-while loops.
  • 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 cin and cout.
  • Comments: Support for single-line comments (//).
  • Error Handling: Detection of lexical, syntactic, and semantic errors.
  • Built-in Commands: ListAllVariables, ListAllFunctions, ListVariable, ListFunction, Done.

Build

Please execute the following commands from the project root directory:

Compile

javac -d bin -cp lib/HsiaNB50Lib.jar src/our_c_interpreter/*.java

Package

jar cvfm our_c_interpreter.jar manifest.txt -C bin .

Usage

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.jar

Once started, you will enter the Our-C interface:

Our-C running ...
>

For more information regarding Our-C usage, please refer to Our-C Overview.

About

A C-like interpreter developed for the CS220H Programming Languages course at CYCU in 2022.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages