🚨🦀 Setup Rust -> WASM 🦀🚨 (#28)

* initial tokeniser to wasm port

* fix tests

* add wasm to build script

* add rust tools to test action

* tweaks

* maybe tests will be happy

* tweak simple server

* trying to get tests to pass

* it pget vercel to build

* tidy up

* clean up rust files

* change lexer to use recursion so that it's consistent with the rest of the interpreter

* clean up nokeniser further

* rename variables

* readme typos

* run rust tests in CI

* follow clippy's advice

* more clippy clean up

* setup up proper serialzation to js-land

* tidy init promise in tests
This commit is contained in:
Kurt Hutten
2023-02-21 09:42:41 +11:00
committed by GitHub
parent 594d55576a
commit cb8e97eceb
22 changed files with 1181 additions and 381 deletions

View File

@ -7,7 +7,7 @@ import {
} from './lang/abstractSyntaxTree'
import { ProgramMemory, Position, PathToNode, Rotation } from './lang/executor'
import { recast } from './lang/recast'
import { lexer } from './lang/tokeniser'
import { asyncLexer } from './lang/tokeniser'
export type Range = [number, number]
export type TooTip =
@ -155,9 +155,9 @@ export const useStore = create<StoreState>()((set, get) => ({
setAst: (ast) => {
set({ ast })
},
updateAst: (ast, focusPath) => {
updateAst: async (ast, focusPath) => {
const newCode = recast(ast)
const astWithUpdatedSource = abstractSyntaxTree(lexer(newCode))
const astWithUpdatedSource = abstractSyntaxTree(await asyncLexer(newCode))
set({ ast: astWithUpdatedSource, code: newCode })
if (focusPath) {
@ -173,9 +173,9 @@ export const useStore = create<StoreState>()((set, get) => ({
setCode: (code) => {
set({ code })
},
formatCode: () => {
formatCode: async () => {
const code = get().code
const ast = abstractSyntaxTree(lexer(code))
const ast = abstractSyntaxTree(await asyncLexer(code))
const newCode = recast(ast)
set({ code: newCode, ast })
},