spacecase123 / Kipper

The Kipper programming language! 🦊 - By Luna Klatzer @ Higher Technical College Leonding

Home Page:https://wmc-ahif-2021.github.io/Kipper-Web/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Kipper programming language - kipper

Version Issues License FOSSA Status

The full module for Kipper, which contains the core language, compiler and command line interface (CLI).

Kipper is a simple strongly and statically typed programming language, which is designed to allow for straightforward, simple, secure and type-safe coding similar to TypeScript, Rust and Python! 🦊

Goals

  • Full type safety to ensure errors occur on compile time, not runtime.
  • Runtime types and type checking, which allow variable types to be checked during runtime, if their type can not be evaluated during compile time. For example when using JSON.parse().
  • Runtime errors for invalid operations. No hidden errors like in JavaScript.
  • Null safety, by enforcing non-null types unless explicitly allowed.
  • Full translation and integration with TypeScript.

Example Code Snippet

Kipper is still in an early development phase, as such not all features shown in the snippet are implemented yet.

Child Packages

These are the child packages that are shipped with this bundle of Kipper:

  • @kipper/core: The Kipper compiler for the browser and Node.js! 🦊
  • @kipper/cli: The Kipper command line interface (CLI) to interact with the Kipper compiler! 🦊

Kipper Docs

Proper documentation for the Kipper language is available here!

How to use Kipper?

To use Kipper you have three options:

In a browser

For running Kipper in the browser, you will have to include the kipper-standalone.min.js file, which provides the kipper compiler for the browser.

As a dependency you will also have to include babel.min.js, which is needed to allow for a compilation from TS to JS in your browser, as Kipper compiles only to TypeScript.

Simple example of running your code in your browser using Kipper and Babel:

<!-- Babel dependency -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Kipper dependency -->
<script src="https://cdn.jsdelivr.net/npm/@kipper/core@latest/kipper-standalone.min.js"></script>

<!-- You won't have to define Kipper or anything after including the previous file. It will be defined per default  -->
<!-- with the global 'Kipper' -->
<script type="module">
	// Define your own logger and compiler, which will handle the compilation
	const logger = new Kipper.KipperLogger((level, msg) => {
		console.log(`[${Kipper.getLogLevelString(level)}] ${msg}`);
	});
	// Define your own compiler with your wanted configuration
	const compiler = new Kipper.KipperCompiler(logger);

	// Compile the code to Typescript
	// Top-level await ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await
	const result = (await compiler.compile(`call print("Hello world!");`)).write();

	// Transpile the TS code into JS
	const jsCode = Babel.transform(result, { filename: "kipper-web-script.ts", presets: ["env", "typescript"] });

	// Finally, run your program
	eval(jsCode.code);
</script>

Locally using Node.js and the CLI

This is to recommend way to use Kipper if you want to dive deeper into Kipper, as it allows you to locally use and run kipper, without depending on a browser.

For example:

  • Compiling a Kipper program:
    kipper compile file.kip
  • Executing a Kipper program using Node.js:
    kipper run file.kip

This also enables the usage of Kipper files with the .kip extension, which can be read and compiled to TypeScript, without having to configure anything yourself. This also allows the input of data over the console and file-interactions, which are not supported inside a browser.

For more info go to the @kipper/cli README.

Locally in your own code as a package

This is the recommended way if you intend to use kipper in a workflow or write code yourself to manage the compiler. This also allows for special handling of logging and customising the compilation process.

Simple example of using kipper using Node.js:

import * as ts from "typescript";
import { promises as fs } from "fs";
import * as Kipper from "@kipper/core";

const path = "INSERT_PATH";
fs.readFile(path, "utf8" as BufferEncoding).then(async (fileContent: string) => {
	// Define your own logger and compiler, which will handle the compilation
	const logger = new Kipper.KipperLogger((level, msg) => {
		console.log(`[${level}] ${msg}`);
	});
	const compiler = new Kipper.KipperCompiler(logger);

	// Compile the code string or stream
	let result = await compiler.compile(fileContent, {
		/* Config */
	});
	let tsCode = result.write();

	// Compiling down to JS using the typescript node module
	let jsCode = ts.transpile(tsCode);

	// Running the Kipper program
	eval(jsCode);
});

Contributing to Kipper

If you want to contribute to Kipper, we have a full guide explaining the structure of Kipper and how to use GitHub issues and pull requests. Check it out here!

If you have any questions or concerns, you can open up a discussion page here!

Copyright and License

License FOSSA Status

Copyright (C) 2021-2022 Luna Klatzer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

See the LICENSE for information on terms & conditions for usage.

FOSSA License Report

FOSSA Status

About

The Kipper programming language! 🦊 - By Luna Klatzer @ Higher Technical College Leonding

https://wmc-ahif-2021.github.io/Kipper-Web/docs

License:GNU General Public License v3.0


Languages

Language:TypeScript 98.0%Language:ANTLR 1.3%Language:PowerShell 0.3%Language:HTML 0.2%Language:Shell 0.2%Language:JavaScript 0.0%Language:Batchfile 0.0%