Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
swazrgb authored and ribrdb committed Apr 2, 2024
1 parent 87f816e commit 93dfff9
Show file tree
Hide file tree
Showing 47 changed files with 2,420 additions and 5,635 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# desynced-tools

Tools for working with behaviors and blueprints from Desynced.

# Getting started
Expand All @@ -10,33 +11,37 @@ Try online at https://desynced-behavior-editor.web.app/ or for command line tool
# Tools

## ds-disas

Usage: `ds-disas filename.txt`

Converts a Desynced blueprint or behavior string to assembly language.
The output filename will be the input with ".asm" added.
To produce the input file, copy a behavior or blueprint in the game and then paste that into a plain text file.

## ds-as

Usage: `ds-as filename.asm`

Convert from assembly language back into a Desynced clipboard string.
The output filename will be the input with ".txt" added.

## js2ds

Usage: `js2ds filename.js` or `js2ds filename.ts`

Convert from JavaScript or TypeScript to desynced-tools assembly language.
The output filename will be the input with ".asm" added.


# Development

Checkout out the code from https://github.com/ribrdb/desynced-tools

First run `npm install` to install dependencies, then run `npm run generate` to generate required code.

## Web demo

To build the web demo:
- `npm run esbuild`
- Extract the monaco 0.45.0 distribution into website/monaco-editor-0.45.0/
https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.45.0.tgz

- `npm run esbuild`
- Extract the monaco 0.45.0 distribution into website/monaco-editor-0.45.0/
https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.45.0.tgz
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
easier syntax for setting them.
- Review instructions to see if more should have JS overrides.
- Figure out how to support mods?
- Write a vscode extension.
- Write a vscode extension.
15 changes: 6 additions & 9 deletions as.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#!/usr/bin/env node
import * as fs from "fs";
import { ObjectToDesyncedString } from "./dsconvert";
import { assemble } from "./assembler";
import { ObjectToDesyncedString } from "./dsconvert";
import * as fs from "fs";

const code = fs.readFileSync(process.argv[2], "utf8");
const obj = assemble(code);
let typ = 'C'
if ('frame' in obj) {
typ = 'B';
let typ = "C";
if ("frame" in obj) {
typ = "B";
}
const str = ObjectToDesyncedString(obj, typ);
fs.writeFileSync(process.argv[2] + ".txt", str);
fs.writeFileSync(
process.argv[2] + ".json",
JSON.stringify(obj, undefined, 2)
);
fs.writeFileSync(process.argv[2] + ".json", JSON.stringify(obj, undefined, 2));
59 changes: 33 additions & 26 deletions asm.monarch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,59 @@ export const asmSyntax = {
// defaultToken: 'invalid',

keywords: [
'nil', 'true', 'false', 'self', 'signal', 'visual', 'goto', 'store'
"nil",
"true",
"false",
"self",
"signal",
"visual",
"goto",
"store",
],


// this came from an example, not sure if it really matches json escapes.
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
escapes:
/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,

// The main tokenizer for our languages
tokenizer: {
root: [
// identifiers and keywords

[/\w+:|:\w+/, 'type.identifier' ], // to show labels nicely
[/p\d+|[A-Z]/, 'variable'],
[/\$\w+(?==)/, 'attribute.name'],
[/[a-z_]\w+/, {cases:{
'@keywords': 'keyword',
'@default': 'identifier' }} ],

[/\w+:|:\w+/, "type.identifier"], // to show labels nicely
[/p\d+|[A-Z]/, "variable"],
[/\$\w+(?==)/, "attribute.name"],
[
/[a-z_]\w+/,
{
cases: {
"@keywords": "keyword",
"@default": "identifier",
},
},
],

// whitespace
{ include: '@whitespace' },
{ include: "@whitespace" },

// numbers
[/\d+/, 'number'],

[/\d+/, "number"],

// strings
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' } ],



[/"([^"\\]|\\.)*$/, "string.invalid"], // non-teminated string
[/"/, { token: "string.quote", bracket: "@open", next: "@string" }],
],



string: [
[/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'],
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' } ]
[/[^\\"]+/, "string"],
[/@escapes/, "string.escape"],
[/\\./, "string.escape.invalid"],
[/"/, { token: "string.quote", bracket: "@close", next: "@pop" }],
],

whitespace: [
[/[ \t\r\n]+/, 'white'],
[/;.*$/, 'comment'],
[/[ \t\r\n]+/, "white"],
[/;.*$/, "comment"],
],
},
};
Loading

0 comments on commit 93dfff9

Please sign in to comment.