Giter VIP home page Giter VIP logo

00-00-00-11 / kipper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kipper-lang/kipper

0.0 1.0 0.0 3.64 MB

The Kipper programming language! ๐ŸฆŠ - By Luna Klatzer @ Higher Technical College Leonding

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

License: GNU General Public License v3.0

Shell 0.15% JavaScript 0.02% PowerShell 0.24% TypeScript 98.02% ANTLR 1.36% HTML 0.22% Batchfile 0.01%

kipper's Introduction

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

kipper's People

Contributors

cip43r avatar dependabot[bot] avatar fossabot avatar github-actions[bot] avatar luna-klatzer avatar renovate-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.