Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EON Programming Language

Group Members: İsmail Temüroğlu, Can Dündar, Emre Topcu, Ömer Lütfi Duran

Language Overview

EON is a statically-typed programming language with a clean syntax that emphasizes readability and explicit type declarations. It features unique control flow keywords, specialized operators, and a distinctive statement termination approach using colons.

Syntax & Features

Variable Declaration and Types

Variables must be declared with explicit types using the :: operator:

variableName :: value:

Bare in mind that MAX_ID_LENGTH 64 is 64

Bare in mind that MAX_CALL_DEPTH is 100

Bare in mind that MAX_SYMBOLS is 1000

Supported primitive types:

  • int: Integer values
  • bool: Boolean values (True or False)

Examples:

  • numberVal :: 42:
  • boolVal :: True:

Bare in my that True and Falses are basically one and zero.

Comments

  • Single-line comments: Begin with ---

--- This is a single line comment

  • Multi-line comments: Enclosed between -* and *-

-_ This is a multi-line comment _-

Control Structures

Conditional Statements

  • when / otherwise: Similar to if/else:

    • when (condition) { // code } otherwise { // code }
  • unless: Opposite of when, executes if condition is false:

    • unless (condition) { // code }

Loops

  • ctloop (count loop): Similar to a for loop

    • ctloop (initialization: condition: update) { // code }
  • cnloop (continue loop): Similar to a while loop

    • cnloop (condition) { // code }

Functions

Functions are declared using the method keyword:

method name(param) { // function body return value: } ENDF

Operators

  • Arithmetic: +, -, *, /, ++, --

  • Assignment: =, +=, -=, *=, /=

  • Comparison: >, <, >=, <=, ==

  • Logical: && (AND), || (OR), ^^ (XOR)

  • Bitwise: & (AND), | (OR), ^ (XOR)

Input/Output

  • Output: write(expression)

  • Input: input()

Statement Termination

All statements end with a colon : rather than a semicolon.

Sample Code

when (k > 4) {
    write(5):
    write(6):
    write(7):
    write(8):
    write(9):
    write(10):

} otherwise {
    write(1):
    write(2):
    write(3):
}

BNF Grammer

<program> ::= <function>

<function> ::= <function> <stmt> | ε

<stmt> ::= COLON | <expr> COLON | PRINT <expr> COLON | IDENTIFIER ASSIGN <expr> COLON | WHILE LEFT_PARENTHESIS <expr> RIGHT_PARENTHESIS <stmt> | IF LEFT_PARENTHESIS <expr> RIGHT_PARENTHESIS <stmt> | IF LEFT_PARENTHESIS <expr> RIGHT_PARENTHESIS <stmt> ELSE <stmt> | LEFT_BRACE <stmt_list> RIGHT_BRACE | <comment> <stmt_list> | <try_catch_stmt> | <throw_stmt>

<try_catch_stmt> ::= TRY <stmt> <catch_clauses> | TRY <stmt> <catch_clauses> <finally_clause>

<catch_clauses> ::= <catch_clause> | <catch_clauses> <catch_clause>

<catch_clause> ::= CATCH LEFT_PARENTHESIS INTEGER RIGHT_PARENTHESIS <stmt> | CATCH LEFT_PARENTHESIS RIGHT_PARENTHESIS <stmt>

<finally_clause> ::= FINALLY <stmt>

<throw_stmt> ::= THROW <expr> COLON

<stmt_list> ::= <stmt> | <stmt_list> <stmt>

<comment> ::= COMMENTLINE | OPENCOMMENT

<expr> ::= INTEGER | IDENTIFIER | MINUS <expr> | <expr> PLUS <expr> | <expr> MINUS <expr> | <expr> MULTIPLE <expr> | <expr> DIVIDE <expr> | <expr> LESSTHAN <expr> | <expr> GREATERTHAN <expr> | <expr> EQUALORGREAT <expr> | <expr> EQUALORLESS <expr> | <expr> ISNOTEQUAL <expr> | <expr> EQUAL <expr> | LEFT_PARENTHESIS <expr> RIGHT_PARENTHESIS

Program Execution

To execute your program:

  1. Create a file with the .eon extension

  2. Use the provided Makefile to compile the program

  3. Run your program with:

   make

   ./eon_parser < example.eon

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages