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).
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.
There are two printing functions in Symbolang. One for basic print (print
) and another for printing with a new line (println
).
βοΈ "Hello, World!" π«·
// Equivalent C code:
printf("Hello, World!");
The implementation above 1 will print βHello, World!β without a new line.
ποΈ "Hello, World!" π«·
// Equivalent C code:
printf("Hello, World!\n");
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("!");
ποΈ "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.
π 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
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!
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
.