Giter Site home page Giter Site logo

kool814 / gls Goto Github PK

View Code? Open in Web Editor NEW

This project forked from budgielang/budgie

0.0 2.0 0.0 851 KB

A unified syntax that compiles into your favorite OOP languages.

Home Page: https://aka.ms/gls-demo

License: MIT License

JavaScript 2.75% TypeScript 90.93% C# 1.64% Java 1.85% Python 1.31% Ruby 1.29% Smalltalk 0.23%

gls's Introduction

GLS - General Language Syntax

Build Status NPM version

A unified syntax that compiles into a number of OOP languages. Try it at aka.ms/gls-demo.

Usage

GLS can be used as a command-line app or via import/require.

CLI

To convert file.gls to file.py:

npm install gls-cli --global

gls --language Python file.gls

See gls-cli.

Code

npm install general-language-syntax

const Gls = require("general-language-syntax").Gls;

const gls = new Gls();
gls.setLanguage("CSharp");

// System.Console.WriteLine("Hello world!");
console.log(gls.convert([`print : ("Hello world!")`]));

Theory

Most object-oriented programming languages today are "pretty much" the same. Declaring variables, PEMDAS operations, calling functions, and so on rarely change; the base concept of a compiled or scripting language with managed memory is very common.

GLS provides a common syntax to describe programming functionality in these common managed languages. .gls files can be compiled into any of the supported languages, and will work approximately the same in all of them.

Syntax

Each line in GLS consists of a function, a colon, and any number of arguments, all separated by spaces.

print : "GLS!"
  • Function: print
  • Argument: "GLS!"

print : GLS will compile to System.Console.WriteLine("GLS!"); in C#, console.log("GLS!"); in TypeScript, and so on.

Parenthesis

You can keep spaces inside your arguments by wrapping characters in parenthesis. This tells the compiler to treat the space as part of the argument instead of a separator.

print : ("Hello world!")
  • Function: print
  • Argument: "Hello world!"

Recursion

To pipe the output of one command into another, wrap the inner command with {} brackets.

print : { operation : 1 plus 2 }

Tidbits

  • Each GLS command is independent - it doesn't know or care about any preceding or following commands.

Status

GLS is halfway between 0.3 and 0.4.

Deliverable Version Description
C++ Compiler 0.1 Command-line GLS prototype, written in C++.
TypeScript Compiler draft 0.2 GLS compiler as a website, written in TypeScript.
TypeScript Compiler + C# Output 0.3 GLS compiler re-written in TypeScript, with correct TypeScript and C# output.
Dogfood Feature Complete 0.4 All features expected to be required for dogfooding implemented. Java, JavaScript, Python, and Ruby support.
Dogfood 0.5 Compiler written in GLS code, working in C#, Java, JavaScript, Ruby, Python, and TypeScript.
Powershell, PHP, Objective-C, Misc. 0.6 Dogfood or reject those languages and other possibilities.
Language Specification Finalized 0.7 Finalized language spec & cleaned internals of code.
General Release 1.0 Public announcement, glory to everyone.

Intentionally Missing Items

No language is perfect. The following are some seemingly obvious omissions in GLS that are due to languages not supporting them:

Feature C# Java Python Ruby (Java|Type)Script
`async`/`await`! Missing Missing
Default Member Variable Values Missing
Do/While Loops Missing
Enums Without Values Missing
Multiline Lambdas Missing
Optional Parameters Missing
Overloaded Functions Missing Missing Missing
String.Replace Abnormal
Switch Statements Missing

This list will grow as features are requested.

Intentionally Unsupported Languages

Not all languages work similarly to the supported ones. These will likely never receive GLS support, for the following common reasons (among others):

Language Manual Pointers Unusual Classes
C
C++ ✓ (#190)
Go
Rust

This list will grow as languages are requested.

Development

GLS uses Gulp to automate building, which requires Node.js.

To build from scratch, install Node.js and run the following commands:

npm install -g gulp
npm install
gulp

To build, run gulp. You can build+lint the souce without running tests using gulp src, or just build+lint+run tests using gulp test. The full list of tasks is in gulpfile.js.

Alternately, use tsc to build source files under /src to /lib, and tsc -w to build upon file changes.

Tests

Integration and end-to-end tests are done using BDD. Folders under /test/integration and /test/end-to-end will contain a .gls file with GLS source code along with text files of the expected output in supported languages. These are verified during gulp test.

You can run specific tests using their gulp task (gulp test:integration or gulp test:end-to-end). Specify --command(s) to only run tests within groups that case-insensitive minimatch them (e.g. gulp test:end-to-end --command *array* *list*).

gls's People

Contributors

chrisatang avatar gleasonc4 avatar ben-wolf avatar faulda avatar kool814 avatar disi33 avatar

Watchers

James Cloos avatar  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.