A Rust-based compiler for the Olive programming language, which offers a blend of simplicity and intuitive syntax inspired by languages like C, Java, and Python.
3. Symbol Table
4. Scanner
6. LL(1) Parser
7. Flex
8. Bison
Olive is fundamentally built upon the following lexical specification:
- Uppercase (A-Z) and lowercase (a-z) letters of the English alphabet
- Decimal digits (0-9)
- ASCII symbols (32-126)
- Arithmetic operators:
+,-,*,/,% - Assignment operator:
= - Comparison operators:
==,!=,<,>,<=,>= - Logical operators:
&&,|| - Separators: whitespace,
(,),[,],{,},<,>,:,; - Comments:
-- - Character constant:
' - String constant:
" - Reserved words:
number,char,string,array,input,output,if,else,while
- Formed by any combination of uppercase and lowercase letters.
- Integer: Formed by an optional sign (
+or-), followed by digits. Example:123,-456 - Character: Enclosed in single quotes. Example:
'a' - String: Enclosed in double quotes. Example:
"Hello, World!"
-
Variable Declarations and Types: Like C and Java, Olive supports explicit variable declarations with basic types (number, char, string) and arrays.
-
Control Flow: The language incorporates control flow constructs similar to those in C-like languages, including if, else, and while loops.
-
Expressions and Operators: Olive's expression syntax and operators (arithmetic, logical) are reminiscent of languages like Python and JavaScript, allowing for familiar arithmetic and logical operations.
-
Input/Output Operations: The input and output statements in Olive are straightforward, much like the I/O operations in Python and Java.
-
Comments: Olive uses -- for single-line comments, a style common in SQL and Lua.
-
C/Java-like Syntax: Olive's variable declarations, data types, and control structures have a syntax and behavior similar to C and Java.
-
Python/JavaScript Expressiveness: The ease of writing expressions and the simplified I/O operations in Olive are akin to scripting languages like Python and JavaScript.
-
Structured Programming: Olive encourages structured programming practices, making it easy for developers familiar with traditional programming paradigms to adapt.
- Rust (latest stable version)
- Cargo (Rust's package manager)
-
Clone the repository.
-
Navigate to the
compiler/olivedirectory. -
Build the project using Cargo:
cargo buildTo compile an Olive program, run the following command:
cargo run <path-to-olive-file>For example:
cargo run programs/p1.oliThis project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.