Skip to content
Gerassimos Moutafis edited this page Apr 27, 2024 · 2 revisions

Welcome to the GLP wiki!

What us GLP GLANG

GLP GLANG is a programming language created by Gerassimos Moutafis. It is hyper-functional, all actions are function calls of some sort following a simple yet consistent syntax among all commands:

(functionToBeCalled firstArg secondArg ... lastArg)

Even creating a function or a variable is a function call in GLANG. The appropriate functions are:

(makeFunction function-name (body) (return) (arg) ... (arg));

which defines a function named function-name of process returning (return) with args (arg) ... (arg))

Also (create variableName); which creates a variable named variableName (create variableName (arg)); which creates and initializes variable named variableName with (arg) value and (set variableName (arg)); which initializes variable variableName with (arg)) value

Of course you can access the full list of functional commands on the Official Documentation here: https://itsgerassimos.github.io/GLP/documentation.html

Technologies Used

The language is created in vanilla node Javascript. The console engine uses pkg for compiling the binaries. To learn about compilation visit https://github.com/itsgerassimos/GLP/tree/main/build

Intended Usage

For simple testing one can download the GLP-CMD binaries from: https://github.com/itsgerassimos/GLP/tags I always suggest downloading the latest version because at the starting stage more and more features will be added until a complete maturing of what constitutes the standard features.

One can also use the GLP-CMD to transpile GLP files to JS or export files to JS. (The appropriate commands are called Special non-GLP Commands on the documentation https://itsgerassimos.github.io/GLP/documentation.html)

On the other hand downloading the repo would be more useful if one is interested in the expansion-customization of GLP:

Customization

There are only a few changes that need to be made on the interpreter/parser/code-generator codes. The important thing for expansion is to customize the standard JS library which provides the native-JS functions that will be used in the language.

For example the (print Hello World); command, which calls the function print passing in "Hello" & "World" utilizes the print function from the standard library: https://github.com/itsgerassimos/GLP/blob/main/modules/libraries/std-raw.js and transpiles to print("Hello", "World");

The standard library utilizes natively made print:

function print(...args) { args.forEach(arg => console.log(arg)); }

What does GLP GLANG generate

The GLP GLANG generates JS files.

Before that, it (the GLP-CMD) shows the TOKENS, the SPLITTED ACTIONS (split is ";" based), the AST (Abstract Syntax Tree), the GENERATED CODE (only the part that transpiles from user-generated commands without any libraries in order to show how the code generator is working under the hood clearly), the GENERATED CODE WITH LIBRARY (which includes whatever needed in order for one to run the code in a javascript environment) and finally the I/O (Input/Output) which includes the output of the code. Adding an input system is the next step.

Current Features include

Function Calls & Definitions Variable Creation & Accessing Recursion If Statements / Comparisons / Coercion For / While Loops Deleting Posts JS - Library Integration

Current Goals

Add input function of intended behaviour of:

(input Write your name)

prompting the user with "Write your name" and returning the input to parent function like:

(print (input Write your name))

I am thinking of achieving this in the parser rather than the standard library for two reasons: Problems with asynchronous function calling from the standard library rather than the call instead (Maybe I should add an async function option/function that calls functions asynchronously or even a special keyword if that doesn't 1) go against the GLANG philosophy 2) is friendly to the parser and doesn't produce more issues with types and strings) Separation of GLP engine - native functions like makeFunction, if, ifelse, while, for, create, set founded in https://github.com/itsgerassimos/GLP/blob/main/modules/processes/generator/generator.js that are essential as the core of the language, from JS library - native library functions found in https://github.com/itsgerassimos/GLP/blob/main/modules/libraries/std-raw.js

Current Philosophy-Wise Goals

The only step against only-through the standard-library expandability of the language are certain features that need to be implemented on the parser (for separation of concepts OR technological reasons). For example it would not make sense not to implement the makeFunction function on the parser and make a library handle it. So, what needs to be done? Collect all the native features that need to be made beyond the scope of any library and work on them on the parser. (not implemented) examples could include asynchronous functions / imports.

Turing Completeness

As GLP transplies to native-JS, the steps for achieving Turing-Completeness would involve writing each JS line on GLP until encountering what cannot be done and add it to the engine. It is planned to be completed.

When all necessary parsing features are implemented, integration of external libraries will be the next step.

How I made GLP GLANG

The core of GLP GLANG was made in the span of 1-3 days at night hours, including the writing of the documentation. The only language used was node-JS and the pkg package for compiling the binaries. I created the language without following any strict guidelines the way I thought features should be implemented, the first build for it to just work and adjusting the next ones for a more clear workflow.