Schaftenstein
Schaftenstein is a programming language designed by PSTF. The goal of this language is to be completely OOP and be Turing-complete.
Overview
As the author stated, this language is designed to be quite like Java but different(mix with Python).
Basic Syntax
Program Structure
import XXX; import YYY.abc; // Importing libraries, optional class Main { private static ftype fname(*args, **kwargs) { // Function body } private static void Main() { // Entrance of program // Things to do } }
Comments
// Hello, I'm a single-line comment. /* Hi, I'm a comment block. */ /* /* This is illegal. */ */
Variable and Data Structure
The variable are defined like this:
var variable_name := value
If the variable is already exist, this will give the variable a new value. Also, you needs to remove the label "var". This language has the same mechanism to Python on variables.
The types are all types in Python, except we support decimal with infinite long.
Conditions
If-elif-else branch
if (1) { // Do sth } elif (2) { // Do more things } else { // Remaining }
Switch-case-default branch
switch(expression) { case 1: // do something case 2: // do something case 3: // do something default: // do something }
Looping Structure
Iterative loop
for (iterator in container) { // Do something }
Conditional loop
while (condition) { // Do something }
User Defining Functions
ftype fname(*args, **kwargs) { // Do something }
Inside the class, the format will turn into define a static for class:
[public|private|protected] static ftype fname(*args, **kwargs) { // Do something }
I/O
To output to the stdout, you write this:
write(content);
To input from the stdin, you write this:
x = read(__prompt, eof = "\n");
The normal EOF is newline, that is, if read a newline then input ends. You can also change it into space or other something.
Definition of Class
Every programs are classes like in Java. Here is the definition of Class:
class YourClassName { // Attributes private static __init__(self) { // Initialization } // Statics }
About the class "Main"
The main class is the main part of the program, and the static "main" in it is the entrance of program.
Import a Package
To import a package, you write this:
import package_name;
This will enable the package you imported in the program.
More Syntax
To be continued...
Example
Currently no.