-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation
Like some custom languages, this one has a lexicon, but also a token parser in the form of the interpreter. Of course, keeping track of the syntax is tricky in the beginning (even I can't keep up with it!). Therefore, I felt as if it was necessary to create a short page detailing the syntax of the language.
Syntax | Effect |
---|---|
num | Represents the "int" primitive type |
word | Represents the "string" primitive/object type |
dec | Represents the "double" primitive type |
tf | Represents the "boolean" primitive type |
There doesn't exist object wrapper classes for the data types like Java, except in one case in the interpreter where declaring the object a List holds is necessary. There, the token is parsed to contain wrapper class as Java "<>" typed classes cannot take an input of primitives.
Syntax | Effect |
---|---|
plus | Equates to the "+" symbol, can be written for string concatenation |
subt | Equates to the "-" symbol |
divi | Equates to the "/" symbol |
mult | Equates to the "*" symbol |
imod | Equates to the "%" symbol, modulus effect of a mod b |
Since the language is compiled into Java, but also certain things are generally needed, I mapped most of the function keywords from Java to custom keys.
Syntax | Effect |
---|---|
open | Declares the function to be public |
closed | Declares the function to be private |
singular | Declares the function to be static |
noret | Shortened version of "no return", indicating a void function |
core | Defines Java execution entry point main; literal mapping "main(String[] args)" |
start | Starts a function or loop definition. Maps to "{" |
end | Ends a function or loop definition. Maps to "}" |
output | Standard print operation with mapping to Java's print line method |
give | Maps to the return keyword |
[ and ] | Represents parentheses |
>>> | Ends most lines, maps to the ";" character |
Arrays were planned and released in version 0.1.3. Since the normal syntax was used for other code structures, the syntax here is a bit iffy.
Lists were added in update version 0.1.4 alongside a rewrite of the batch operations. The problem came when Lists have a generic type that must be added when defining a new List object in Java; otherwise, there are flags for unsafe or deprecated actions by the JVM. Not that it fails most of the time, just that it is a remnant from an older version of Java.
> ARRAYS <
Syntax | Effect |
---|---|
array_build | Keyword to define an array. Maps to the combination "[]" |
arr_open | Left bracket when accessing from an array |
arr_close | Equates to the "/" symbol |
> LISTS <
Syntax | Effect |
---|---|
list_gen | Defines a new list. The list is an ArrayList and any object-based methods use Java syntax |
util_build | Equates the keyword new and is used when defining any data structure* |
-> | Equates to the ".", allows access to methods associated with the instance of the data structure |
type= | Keyword to interpreter to recognize the token as a generic type declaration to the utility. Maps primitives to object form, if needed. |
* Arrays do not require a util_build if their data is defined when creating the new array. For instance,
num array_build arr = start 1, 2, 3 end >>>
is equivalent to
int[] arr = {1, 2, 3};
(just without the nice style).
Syntax | Effect |
---|---|
\n | The line-break character. Not necessary, but used just for spacing since the interpreter ignores line-breaks. |
# | A singular white-space character. Necessary when making strings that contain spaces as the interpreter reads token by token (which means using white-space characters as separators) |
endfile | Since every file is translated to a similarly-named (the first letter is just capitalized) Java class, the program needs to know when to stop. Endfile defines the closing brace on a Java class (You can use "end" too, but this one is just for clarity for where the file stops) |