Skip to content

Commit

Permalink
Merge pull request #76 from budgielang/budgie-rename
Browse files Browse the repository at this point in the history
Renamed to ts-budgie
  • Loading branch information
Josh Goldberg authored Oct 26, 2019
2 parents 2344836 + 6c1e772 commit 41e615d
Show file tree
Hide file tree
Showing 113 changed files with 525 additions and 544 deletions.
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.md
.travis.yml
test/end-to-end/**
test/integration/**
test/integration/**
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ before_install: npm i -g greenkeeper-lockfile npm@latest

before_script: greenkeeper-lockfile-update

install: npm i && npm i general-language-syntax
install: npm i && npm i budgie

language: node_js

Expand Down
12 changes: 6 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
{
"type": "node",
"request": "launch",
"name": "Convert GLS with CLI",
"program": "${workspaceRoot}/../GLS-CLI/bin/gls",
"name": "Convert Budgie with CLI",
"program": "${workspaceRoot}/../budgie-cli/bin/budgie",
"args": [
"--language",
"C#",
"--base-directory",
"src",
"--namespace",
"Gls",
"Budgie",
"--tsconfig",
"${workspaceRoot}/../GLS/tsconfig.json",
"${workspaceRoot}/../budgie/tsconfig.json",
"--exclude",
"${workspaceRoot}/../GLS/src/index.ts",
"${workspaceRoot}/../GLS/src/Rendering/Commands/VariableCommand.ts"
"${workspaceRoot}/../budgie/src/index.ts",
"${workspaceRoot}/../budgie/src/Rendering/Commands/VariableCommand.ts"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 HighSchoolHacking
Copyright (c) 2019 budgielang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
39 changes: 19 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# TS-GLS - TypeScript to GLS compiler
# ts-budgie 🦜

[![Build Status](https://travis-ci.org/general-language-syntax/TS-GLS.svg?)](https://travis-ci.org/general-language-syntax/TS-GLS)
[![NPM version](https://badge.fury.io/js/ts-gls.svg)](http://badge.fury.io/js/ts-gls)
[![Greenkeeper badge](https://badges.greenkeeper.io/general-language-syntax/TS-GLS.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/budgielang/ts-budgie.svg?)](https://travis-ci.org/budgielang/ts-budgie)
[![NPM version](https://badge.fury.io/js/ts-budgie.svg)](http://badge.fury.io/js/ts-budgie)
[![Greenkeeper badge](https://badges.greenkeeper.io/budgielang/ts-budgie.svg)](https://greenkeeper.io/)

Compiles TypeScript code to General Language Syntax (GLS).
Compiles TypeScript code to Budgie.

GLS is an abstract way to describe lines of code in real languages.
TypeScript is a gradually typed language, so a subset of well-typed TS code can generally be converted to GLS.
Budgie is an abstract way to describe lines of code in real languages.
TypeScript is a gradually typed language, so a subset of well-typed TS code can generally be converted to Budgie.

## Caveats

It's impossible to _accurately_ convert TS code to GLS.
It's impossible to _accurately_ convert TS code to Budgie.
Although large constructs such as classes and interfaces can be, there are edge cases around primitive literals not representable in TypeScript.

For example, TS-GLS has no way of knowing whether `age: number` is a GLS `float` or `int`:
For example, ts-budgie has no way of knowing whether `age: number` is a Budgie `float` or `int`:

```typescript
export class AgePrinter {
Expand All @@ -24,32 +24,32 @@ export class AgePrinter {
}
```

The TS `string` type also can't be statically determined to be a GLS `char` or `string`.
The TS `string` type also can't be statically determined to be a Budgie `char` or `string`.

Thus, TS-GLS will never be more than an experiment.
Only a completely strongly typed language with `int`s and `char`s, such as C# or Java, can truly be compiled to GLS.
TS-GLS can only get code most of the way there.
Thus, ts-budgie will never be more than an experiment.
Only a completely strongly typed language with `int`s and `char`s, such as C# or Java, can truly be compiled to Budgie.
ts-budgie can only get code most of the way there.

## Usage

You can use TS-GLS on the command-line with `gls-cli` or in code.
You can use ts-budgie on the command-line with `budgie-cli` or in code.

### CLI

```shell
gls --language Java --tsconfig ./tsconfig *.ts
budgie --language Java --tsconfig ./tsconfig *.ts
```

See [`gls-cli`](https://github.com/general-language-syntax/gls-cli)
See [`budgie-cli`](https://github.com/budgielang/budgie-cli)

### Code

`createTransformer` creates a `Transformer` object that can transform source files to GLS.
`createTransformer` creates a `Transformer` object that can transform source files to Budgie.
It requires all files at construction so it can create a TypeScript program.

```typescript
import * as ts from "typescript";
import { createTransformer } from "ts-gls";
import { createTransformer } from "ts-budgie";

const sourceFile = ts.createSourceFile("_.ts", "let x = true;", ScriptTarget.Latest);
const transformer = createTransformer({
Expand All @@ -66,7 +66,6 @@ To build from scratch, install Node.js and run the following commands:

```
npm install
npm install general-language-syntax --no-save
npm run verify
```

Expand All @@ -76,7 +75,7 @@ To set up source file compiling in watch mode, use `tsc -p . -w`.
### Tests

Integration and end-to-end tests are done using BDD.
Folders under `/test/integration` and `/test/end-to-end` will contain a `.ts` file with TypeScript source code along with an equivalent `.gls` file with the expected GLS compilation result.
Folders under `/test/integration` and `/test/end-to-end` will contain a `.ts` file with TypeScript source code along with an equivalent `.bg` file with the expected Budgie compilation result.
These are verified during `npm run test test`.

You can run specific tests using their run task (`npm run test:run:integration` or `npm run test:run:end-to-end`).
Expand Down
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ts-gls",
"name": "ts-budgie",
"version": "0.3.1",
"description": "Converts TypeScript code to General Language Syntax (GLS).",
"description": "Converts TypeScript code to Budgie.",
"main": "src/index.js",
"typings": "src/index.d.ts",
"scripts": {
Expand All @@ -24,15 +24,15 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/highschoolhacking/TS-GLS.git"
"url": "git+https://github.com/budgielang/ts-budgie.git"
},
"keywords": ["typescript", "general", "language", "syntax", "gls", "metalanguage", "metaprogramming", "yippee"],
"keywords": ["typescript", "budgie", "metalanguage", "metaprogramming", "yippee"],
"author": "Josh Goldberg <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/highschoolhacking/TS-GLS/issues"
"url": "https://github.com/budgielang/ts-budgie/issues"
},
"homepage": "https://github.com/highschoolhacking/TS-GLS#readme",
"homepage": "https://github.com/budgielang/ts-budgie#readme",
"devDependencies": {
"@types/chai": "^4.2.4",
"@types/minimatch": "^3.0.3",
Expand All @@ -49,11 +49,8 @@
"tslint": "5.20.0",
"tslint-config-prettier": "^1.18.0"
},
"peerDependencies": {
"general-language-syntax": "^0.3.25"
},
"dependencies": {
"general-language-syntax": "^0.3.25",
"budgie": "^0.3.27",
"mz": "^2.7.0",
"tsutils": "^3.17.1",
"typescript": "^3.6.4"
Expand Down
10 changes: 5 additions & 5 deletions src/comments/visitMultiLineCommentTrivia.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CommandNames } from "general-language-syntax";
import { CommandNames } from "budgie";
import * as ts from "typescript";

import { GlsLine } from "../output/glsLine";
import { BudgieLine } from "../output/budgieLine";
import { Transformation } from "../output/transformation";

const parseCommentLines = (commentText: string) => {
Expand All @@ -15,9 +15,9 @@ export const visitMultiLineCommentTrivia = (fullText: string, comment: ts.Commen

return [
Transformation.fromCommentRange(comment, [
new GlsLine(CommandNames.CommentBlockStart),
...commentLines.map((line) => new GlsLine(CommandNames.CommentBlock, line)),
new GlsLine(CommandNames.CommentBlockEnd),
new BudgieLine(CommandNames.CommentBlockStart),
...commentLines.map((line) => new BudgieLine(CommandNames.CommentBlock, line)),
new BudgieLine(CommandNames.CommentBlockEnd),
]),
];
};
6 changes: 3 additions & 3 deletions src/comments/visitSingleLineCommentTrivia.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CommandNames } from "general-language-syntax";
import { CommandNames } from "budgie";
import * as ts from "typescript";

import { GlsLine } from "../output/glsLine";
import { BudgieLine } from "../output/budgieLine";
import { Transformation } from "../output/transformation";

const parseCommentText = (commentText: string): string => {
Expand All @@ -14,6 +14,6 @@ const parseCommentText = (commentText: string): string => {

export const visitSingleLineCommentTrivia = (fullText: string, comment: ts.CommentRange) => [
Transformation.fromCommentRange(comment, [
new GlsLine(CommandNames.CommentLine, parseCommentText(fullText.substring(comment.pos, comment.end))),
new BudgieLine(CommandNames.CommentLine, parseCommentText(fullText.substring(comment.pos, comment.end))),
]),
];
Loading

0 comments on commit 41e615d

Please sign in to comment.