Symbolang

Design of Symbolang

These are all implemented (and some planned) features of Symbolang. Each example has a C code equivalent (if none exist, a Python may be provided).

Getting Started

All Symbolang source files have the .πŸ€“ extension.

To interpret your source file, simply

$ symbolang.exe <fileName>

Or, if you have the repository cloned:

go run main.go <fileName>

Interpreting Options:

-dp     : Show debug messages for the parsing stage of the interpreter.
-dt     : Show debug messages for the tokens produced by the tokenization stage.
-dall   : show all debug messages.

Printing Emojis

There are two printing functions in Symbolang. One for basic print (print) and another for printing with a new line (println).

Print

✏️ "Hello, World!" 🫷

// Equivalent C code:
printf("Hello, World!");

The implementation above 1 will print β€œHello, World!” without a new line.

Println

πŸ–ŠοΈ "Hello, World!" 🫷

// Equivalent C code:
printf("Hello, World!\n");

Multiple Print Statements

Let ⬜ denote the ✏️ or πŸ–ŠοΈ emoji, multiple print statements are of the form:

⬜ <literal_1> ⬜ <literal_2> ⬜ ... 🫷

// Equivalent C code:
printf(<literal_1>);
printf(<literal_2>);

Example:

πŸ–ŠοΈ "Hello" ✏️ "World" ✏️ "!" 🫷

// Equivalent C code:
printf("Hello\n");
printf("World");
printf("!");

Comments

πŸ–ŠοΈ "Hello, World!" 🫷 πŸ’­ This is a comment
πŸ’­ πŸ–ŠοΈ "This will not work" 🫷
πŸ–ŠοΈ "Okay, bye!" 🫷

// Equivalent C code:
printf("Hello, World!\n"); // This is a comment
// printf("This will not work\n");
printf("Okay, bye!\n");

Notice that the comment emoji is implicitly terminated β€œarea-of-effect” at the end of the row.

Variables and Constants

Variables

πŸ’­ Example: πŸ“ƒ <identifier> <literal> 🫷
πŸ“ƒ name "Matthew" 🫷

// Equivalent C code:
// Example: <data_type> <identifier> = <literal>
char name[7] = "Matthew";

We use the same syntax to redefine variables

πŸ“ƒ name "Matthew" 🫷
πŸ“ƒ name "Zhean" 🫷

// Equivalent C code:
char name[7] = "Matthew";
strcpy(name, "Zhean"); // assume string.h is included

⚠️ Data types are unimplemented. Data types are implicit and dynamic, hence we can redefine a variable to a value of a different data type.

πŸ“ƒ x "Matthew" 🫷
πŸ“ƒ x 100 🫷

// Equivalent Python code:
x = "Matthew"
x = 100

Constants

A constant is a variable whose value cannot be changed.

πŸ’­ Example: πŸͺ¨ <identifier> <literal> 🫷
πŸͺ¨ name "Matthew" 🫷

// Equivalent C code:
// Example: const <data_type> <identifier> = <literal>
const char name[7] = "Matthew";

Redefining a constant leads to an error:

πŸͺ¨ name "Matthew" 🫷
πŸͺ¨ name "Zhean" 🫷       πŸ’­ Error occurs here!

Deletion

A variable or constant can be deleted.

πŸ’­ Example: βœ‚οΈ <identifier> 🫷
πŸͺ¨ name "Matthew" 🫷
βœ‚οΈ name 🫷                 πŸ’­ Assuming name is defined
πŸ–ŠοΈ name 🫷                 πŸ’­ Error occurs here `name` is does not exist!
πŸͺ¨ name "Zhean" 🫷   πŸ’­ `name` can be defined again
πŸ–ŠοΈ name 🫷

The example above prints out Zhean.