Compiler for ValhallaScript. A completely ridiculous, unnecessary attempt at creating an esolang. I had my reasons.
Mjolnir is a command-line tool for parsing ValhallaScript files (.vh) and converting them into JavaScript files (.js). ValhallaScript is an esoteric programming language inspired by Norse mythology, and this parser aims to make it easier to work with Valhalla script code.
Before using the ValhallaScript Parser (Transpiler?), ensure you have the following dependencies installed:
- Node.js: You need Node.js installed on your system. You can download it from nodejs.org.
$ yarn add @iasd/mjolnir
# or
$ npm install @iasd/mjolnir
You can use the ValhallaScript Parser (Transpiler?) from the command line. Here's the basic usage:
yarn mjolnir --file=./index.vh --output=./build
# or
npm mjolnir --file=./index.vh --output=./build
-
--file=<input>
: Specifies the inputValhallaScript
file. -
--output=<output-dir>
: Specify the output directory for the generated JavaScript file. By default, no output is created. -
--temp=<temp-dir>
: Specify a temporary directory for intermediate files. Default is./.temp
. -
--quiet
: Suppress informational messages. -
--debug
: Enable debug mode, which includes additional logging. -
--defer
: Defer execution of the generated JavaScript code. The JavaScript file will be created, but it won't be executed. -
--pragma
: Add a pragma to the output
Here's an example of how to use the Valhalla Script Parser:
yarn mjolnir --file=index.vh --output=./build
In this example, index.vh
will be parsed, and the resulting JavaScript code will be saved in the ./build
directory. If the --defer
option is not used, the JavaScript code will also be executed.
Here is a Hello World
implementation.
carve rune navn † `Fynn`; // create the variable 'navn'
skæld∫inscribe<»Hej « + navn>; // logs `Hej Fynn`
ValhallaScript is a unique esoteric programming language. It includes the following key features:
<
and>
: Represent opening and closing parentheses.(*)
: Translates to=>
in JavaScript.†
: Translates to=
in JavaScript.carve rune
: Translates tolet
in JavaScript.carve saga
: Translates toconst
in JavaScript.«
and»
: Represent a string as a JavaScript backtick.∆∞
&∞∆
: Represents square brackets.∫
: Represents the property access.
<∂
&∂>
: Represents curly braces.ansuz
&hagalaz
: Representstrue
&false
respectively.∑
&!∑
: Representsif
&else
.mimir
&from
: Representsfor...of
to start a for...of loop
Preceding any of the provided tokens / keywords with an ø
will escape the character and stop the transpilation.
A certain set of functions are imported by default. No other imports are available (as of yet. Probably never.)
skæld
: Transpiles toconsole
in JavaScript.inscribe
: Transpiles tolog
in JavaScript.runestone
: Transpiles toObject
in JavaScript.runestone∫futhark
: Transpiles toObject.fromEntries
runestone∫glyphs
: Transpiles toObject.entries
runestone∫sigils
: Transpiles toObject.keys
runestone∫essence
: Transpiles toObject.values
freyasOath
: Transpiles tonew Promise
in JavaScriptscry
&woven
: Transpiles toasync
&await
destine
: Transpiles toreturn
choose
,path
&rest
: Transpiles toswitch
,case
andbreak
A certain set of fns are provided to handle files.
Type: `(handle: string, content: string) => Promise``
Description:
eddaEtch
is an asynchronous function that creates a file at the specified location with the specified content. It accepts two parameters:
handle (type: string
): The file path where you want to create the file.
content (type: string
): The content you want to write to the file.
Usage:
scry eddaEtch<»./file.txt«, »File Content«>
Returns:
A promise that resolves when the file has been successfully created with the provided content. If any errors occur during the process, it will reject with an error message.
Type: (handle: string
) => Promise
Description:
eddaSeek
is an asynchronous function that reads and retrieves the content of a file located at the specified path. It accepts one parameter:
handle (type: string
): The file path from which you want to read the content.
Usage:
scry eddaSeek<»./file.txt«>
Returns:
A promise that resolves with the content of the file as a string if the file exists and can be read. If the file does not exist or an error occurs during the process, it will reject with an error message.
Type: `(handle: string, content: string) => Promise``
Description:
eddaWeave is an asynchronous function that appends the specified content to a file located at the specified path. It accepts two parameters:
handle (type: string
): The file path to which you want to append the content.
content (type: string
): The content you want to append to the file.
Usage:
scry eddaWeave<»./file.txt«, »Additional Content«>
Returns:
A promise that resolves when the content has been successfully appended to the file. If any errors occur during the process, it will reject with an error message.
Type: `(handle: string) => Promise``
Description:
eddaExile is an asynchronous function that deletes a file or directory located at the specified path. It accepts one parameter:
handle (type: string
): The file or directory path you want to delete.
Usage:
scry eddaExile<»./file.txt«>
Returns:
A promise that resolves when the file or directory has been successfully deleted. If any errors occur during the deletion process, it will reject with an error message.
Set of functions to interact with paths
Type: `(...fragments: string[]) => Promise``
Description: function to create a absolute path from the root of the process.
Usage:
root<»./folder«, »file.txt«>
// results in ./path/to/process/folder/file.txt
If you would like to contribute, take a look at the Contribution Guide. Contributors of any skill level are appreciated, if you have any questions, feel free to reach out.
Mjolnir
is licensed under the MIT License
Valhalla Script Parser uses the following open-source libraries: