@turing-machine-js/builder 1.0.0 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -9
- package/dist/index.cjs.js +0 -1
- package/dist/index.es.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turing-machine-js/builder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "A turing machine builder",
|
|
5
5
|
"author": "Ruslan Gilmullin <mellonis14@gmain.com>",
|
|
6
6
|
"homepage": "https://github.com/mellonis/turing-machine-js#readme",
|
|
@@ -22,13 +22,8 @@
|
|
|
22
22
|
"builder"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@turing-machine-js/machine": "^
|
|
25
|
+
"@turing-machine-js/machine": "^2.0.0-alpha.1"
|
|
26
26
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "rollup -c ../../rollup.config.mjs",
|
|
31
|
-
"test": "jest --colors"
|
|
32
|
-
},
|
|
33
|
-
"gitHead": "2a9ef21893e125282272aba41a747c7b638400db"
|
|
27
|
+
"module": "dist/index.js",
|
|
28
|
+
"gitHead": "2eb49e091614e3c65f95bbd7626943263fb4d1b3"
|
|
34
29
|
}
|
package/dist/index.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@turing-machine-js/machine");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(e);const n={L:e.movements.left,R:e.movements.right,S:e.movements.stay},o=Symbol("reference"),s=Symbol("state");module.exports=function({alphabetString:t,initialState:l,finalStateList:r,states:c}){const m=new e.Alphabet({symbolList:t.split("")}),i=new a.default({tapeBlock:new e.TapeBlock({alphabetList:[m]})}),{symbol:b}=i.tapeBlock;let f=r.reduce(((t,a)=>({...t,[a]:{[s]:e.haltState,[o]:e.haltState}})),{});return Object.keys(c).forEach((t=>{null!=c[t]&&(f[t]={[o]:new e.Reference})})),Object.keys(c).forEach((t=>{if(null!=c[t]){const a={};Object.keys(c[t]).forEach((s=>{if(!m.has(s))throw new Error("invalid state declaration");let l=c[t][s].symbol;l===s&&(l=e.symbolCommands.keep),l===m.blankSymbol&&(l=e.symbolCommands.erase);const r=n[c[t][s].movement];if(!r)throw new Error("invalid state declaration");const i=f[c[t][s].state][o];a[b([s])]={command:{symbol:l,movement:r},nextState:i}}));const l=new e.State(a);l.name=t,f[t][s]=l,f[t][o].bind(l)}})),f=Object.keys(f).reduce(((e,t)=>({...e,[t]:f[t][s]})),{}),[i,f[l],f]};
|
package/dist/index.es.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e,{Alphabet as t,TapeBlock as n,haltState as a,Reference as o,symbolCommands as s,State as l,movements as r}from"@turing-machine-js/machine";const i={L:r.left,R:r.right,S:r.stay},c=Symbol("reference"),m=Symbol("state");function b({alphabetString:r,initialState:b,finalStateList:f,states:y}){const h=new t({symbolList:r.split("")}),d=new e({tapeBlock:new n({alphabetList:[h]})}),{symbol:w}=d.tapeBlock;let k=f.reduce(((e,t)=>({...e,[t]:{[m]:a,[c]:a}})),{});return Object.keys(y).forEach((e=>{null!=y[e]&&(k[e]={[c]:new o})})),Object.keys(y).forEach((e=>{if(null!=y[e]){const t={};Object.keys(y[e]).forEach((n=>{if(!h.has(n))throw new Error("invalid state declaration");let a=y[e][n].symbol;a===n&&(a=s.keep),a===h.blankSymbol&&(a=s.erase);const o=i[y[e][n].movement];if(!o)throw new Error("invalid state declaration");const l=k[y[e][n].state][c];t[w([n])]={command:{symbol:a,movement:o},nextState:l}}));const n=new l(t);n.name=e,k[e][m]=n,k[e][c].bind(n)}})),k=Object.keys(k).reduce(((e,t)=>({...e,[t]:k[t][m]})),{}),[d,k[b],k]}export default b;
|