This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const _ = Symbol('_'); | |
| const chunk = (array, size) => array.length === 0 | |
| ? [] | |
| : [array.splice(0, size), ...chunk(array, size)]; | |
| const variables = {}; | |
| const clear = object => { | |
| for (const prop in object) delete object[prop]; | |
| return object; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Based on other parser gist | |
| const tokens = tokenize(code); | |
| const ast = parse(tokens); | |
| run(ast); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const code = '(print "test" (+ 5 (- 4 2)) (print "bruh" (t "test")))'; | |
| const tokens = tokenize(code); | |
| console.log(parse(tokens)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log(match( | |
| [{ variable: 'x' }, 'test', ['_', 'coucou']], | |
| ['test', 'test', ['bruggh', 'coucou']] | |
| )); // true | |
| console.log(scope); // [ { name: 'x', value: 'test' } ] | |
| console.log(match( | |
| [{ variable: 'x' }, 'test', ['_', 'coucou']], | |
| ['test', 'test', ['bruggh', 'coucou']] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const operators = [ | |
| { | |
| op: '!', | |
| precedence: 5, | |
| associativity: 'left', | |
| function: (a) => { | |
| let acc = 1; | |
| for (let i = 1; i < a + 1; i++) acc *= i; | |
| return acc; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const simpleGit = require('simple-git/promise'); | |
| const path = require('path'); | |
| const fs = require('fs/promises'); | |
| const git = new simpleGit(); | |
| const capitalize = (str) => str[0].toUpperCase() + str.slice(1); | |
| function parseProjectName(str) { | |
| const formatted = str | |
| .toLowerCase() | |
| .replace(/-/g, ' '); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const tokens: Tokens = [ | |
| { | |
| token: Token.Word, | |
| value: 'print' | |
| }, | |
| { | |
| token: Token.Bracket, | |
| value: '(' | |
| }, | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const code: string = ` | |
| if test = "brut": | |
| print "yay" | |
| if message = "Hello": | |
| print "World" | |
| else: | |
| print "brush" | |
| set "test" | |
| else: | |
| print "hobo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const test = 'test{bruh{coucou}eheh{yollo{ebeaz}}}test'; | |
| const ast = { | |
| type: 'Program', | |
| body: [], | |
| }; | |
| let string = ''; | |
| function parse(chars, index, ast) { |