synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
21
README.md
Normal file
21
README.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# 🔤 Xerlang
|
||||||
|
|
||||||
|
Le LANGAGE DE PROGRAMMATION xerboxion. 3 surfaces (Flow textuel, Ionique/glyphes, Graphe) qui compilent vers le même graphe de bions, exécuté en VRAI WASM (les 32 bions de /bions.json = la stdlib). Run → résultat + émet sur le bus xion. bion → ploxion → cubion → xion.
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| id | `xerlang` |
|
||||||
|
| fournit | `xerlang` `compile` `bions-runtime` |
|
||||||
|
| bions qu'il nomme | `jOSApps` `jOSPorts` |
|
||||||
|
| fichiers | `app.blade.php` |
|
||||||
|
| dans le labo | `resources/views/ploxions/xerlang/` (dépôt `my_website2`) |
|
||||||
|
|
||||||
|
## Contribuer
|
||||||
|
|
||||||
|
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=xerlang — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||||
|
- **Dans VS Code** : `xb prendre xerlang` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
|
||||||
|
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
|
||||||
|
|
||||||
|
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
|
||||||
|
|
||||||
|
© 2026 chill-tekk · ne pas nuire
|
||||||
170
app.blade.php
Normal file
170
app.blade.php
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
{{-- PL0XI0N xerlang — le LANGAGE DE PROGRAMMATION XERBOXION (RS-7 : « on crée le
|
||||||
|
langage xerboxion »). 3 surfaces d'un coup (RS-7 : « fais tout ») : Flow textuel,
|
||||||
|
Ionique/glyphes, Graphe. Toutes compilent vers le MÊME graphe de bions, exécuté
|
||||||
|
en VRAI WASM dans le navigateur (les 32 bions de /bions.json = la stdlib).
|
||||||
|
Run -> résultat + émet sur le bus xion (jOSPorts) + export -> core. Contrat jOSApps. --}}
|
||||||
|
<style>
|
||||||
|
.xl{height:100%;display:flex;flex-direction:column;background:var(--xr-bg,#060b09);color:var(--xr-text,#dffbe9);font-family:var(--xr-font,ui-sans-serif,system-ui);font-size:.85rem}
|
||||||
|
.xl__tabs{display:flex;gap:4px;padding:8px 10px 0;flex:0 0 auto}
|
||||||
|
.xl__tab{cursor:pointer;border:1px solid var(--xr-border,rgba(0,255,159,.2));border-bottom:0;background:rgba(255,255,255,.03);color:var(--xr-muted,#8aa0c0);padding:5px 12px;border-radius:8px 8px 0 0;font-size:.78rem}
|
||||||
|
.xl__tab.on{background:rgba(0,255,159,.1);color:var(--xr-accent,#3fe0d0);font-weight:700}
|
||||||
|
.xl__main{flex:1;display:flex;min-height:0;border-top:1px solid var(--xr-border,rgba(0,255,159,.2))}
|
||||||
|
.xl__ed{flex:1;display:flex;flex-direction:column;min-width:0}
|
||||||
|
.xl__ta{flex:1;background:#04080a;border:0;color:#dffbe9;font:0.9rem ui-monospace,monospace;padding:12px;resize:none;outline:none;line-height:1.5}
|
||||||
|
.xl__graph{flex:1;overflow:auto;padding:14px;display:none;align-content:flex-start;gap:10px;flex-wrap:wrap}
|
||||||
|
.xl__node{border:1px solid var(--xr-accent,#3fe0d0);border-radius:10px;padding:8px 12px;background:rgba(0,255,159,.06);min-width:80px;text-align:center}
|
||||||
|
.xl__node b{display:block;color:var(--xr-accent,#3fe0d0)} .xl__node small{color:var(--xr-muted,#8aa0c0);font-size:.7rem}
|
||||||
|
.xl__arrow{align-self:center;color:var(--xr-accent2,#f233b3);font-size:1.3rem}
|
||||||
|
.xl__side{width:170px;flex:0 0 auto;border-left:1px solid var(--xr-border,rgba(0,255,159,.2));overflow-y:auto;padding:8px}
|
||||||
|
.xl__side h4{margin:0 0 6px;font-size:.7rem;text-transform:uppercase;color:var(--xr-muted,#8aa0c0)}
|
||||||
|
.xl__b{display:flex;justify-content:space-between;padding:3px 6px;border-radius:5px;cursor:pointer;font:0.74rem ui-monospace,monospace}
|
||||||
|
.xl__b:hover{background:rgba(0,255,159,.1)} .xl__b span{color:var(--xr-muted,#8aa0c0);font-size:.66rem}
|
||||||
|
.xl__bar{flex:0 0 auto;display:flex;align-items:center;gap:8px;padding:8px 10px;border-top:1px solid var(--xr-border,rgba(0,255,159,.2))}
|
||||||
|
.xl__run{background:var(--xr-accent,#3fe0d0);color:#04140f;border:0;border-radius:8px;font-weight:800;padding:6px 16px;cursor:pointer}
|
||||||
|
.xl__btn{background:none;border:1px solid var(--xr-border,rgba(0,255,159,.3));color:var(--xr-accent,#3fe0d0);border-radius:7px;padding:5px 11px;cursor:pointer;font-size:.76rem}
|
||||||
|
.xl__out{flex:0 0 auto;max-height:120px;overflow-y:auto;padding:8px 12px;border-top:1px solid var(--xr-border,rgba(0,255,159,.2));font:0.8rem ui-monospace,monospace;white-space:pre-wrap}
|
||||||
|
.xl__out .ok{color:var(--xr-accent,#3fe0d0)} .xl__out .err{color:#ff7a7a} .xl__out .dim{color:var(--xr-muted,#8aa0c0)}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
(function(){
|
||||||
|
var ID='xerlang';
|
||||||
|
|
||||||
|
function mount(container){
|
||||||
|
var bions={}, names=[], alive=true, mode='flow';
|
||||||
|
container.innerHTML=''
|
||||||
|
+'<div class="xl">'
|
||||||
|
+'<div class="xl__tabs"><span class="xl__tab on" data-m="flow">▷ Flow</span><span class="xl__tab" data-m="ionique">⟨⟩ Ionique</span><span class="xl__tab" data-m="graphe">▢ Graphe</span></div>'
|
||||||
|
+'<div class="xl__main">'
|
||||||
|
+' <div class="xl__ed"><textarea class="xl__ta" data-ta spellcheck="false"></textarea><div class="xl__graph" data-graph></div></div>'
|
||||||
|
+' <div class="xl__side"><h4>bions (stdlib)</h4><div data-pal>chargement…</div></div>'
|
||||||
|
+'</div>'
|
||||||
|
+'<div class="xl__bar"><button class="xl__run" data-run>▶ Run</button><button class="xl__btn" data-bus>→ bus xion</button><button class="xl__btn" data-core>→ core (export)</button><span class="dim" style="flex:1;color:var(--xr-muted,#8aa0c0);font-size:.72rem">bion → ploxion → cubion → xion</span></div>'
|
||||||
|
+'<div class="xl__out" data-out><span class="dim">écris un programme, ▶ Run. Ex : add 7 5 |> mul 2 |> emit "r"</span></div>'
|
||||||
|
+'</div>';
|
||||||
|
var root=container.querySelector('.xl'), ta=root.querySelector('[data-ta]'), graph=root.querySelector('[data-graph]'), pal=root.querySelector('[data-pal]'), out=root.querySelector('[data-out]');
|
||||||
|
var samples={
|
||||||
|
flow:'# xerboxion — bions scalaires + ARRAY BIONS (validé)\nx = add 7 5\nemit "somme" x\na = array 5 3 8 1 9 2\ns = sort a\nemit "trie" s',
|
||||||
|
ionique:'# alphabet O I N B T S X E R\n⟨7 5⟩ B:add ▷ B:mul ⟨2⟩ ▷ X:emit',
|
||||||
|
graphe:'add 7 5 |> mul 2 |> emit "r"'
|
||||||
|
};
|
||||||
|
ta.value=samples.flow;
|
||||||
|
function log(msg,cls){ out.innerHTML+='\n<span class="'+(cls||'')+'">'+esc(msg)+'</span>'; out.scrollTop=out.scrollHeight; }
|
||||||
|
function esc(s){ return String(s).replace(/[&<>]/g,function(c){return{'&':'&','<':'<','>':'>'}[c];}); }
|
||||||
|
|
||||||
|
// ---- charge + instancie les bions WASM ----
|
||||||
|
fetch('/bions.json').then(function(r){return r.json();}).then(function(d){
|
||||||
|
var arr=d.bions||d; if(!Array.isArray(arr)) arr=Object.values(arr);
|
||||||
|
var chain=Promise.resolve();
|
||||||
|
arr.forEach(function(b){ if(!b||!b.b64) return; chain=chain.then(function(){
|
||||||
|
var bytes=Uint8Array.from(atob(b.b64),function(c){return c.charCodeAt(0);});
|
||||||
|
return WebAssembly.instantiate(bytes,{}).then(function(m){
|
||||||
|
var fn=m.instance.exports[b.name]||m.instance.exports[Object.keys(m.instance.exports)[0]];
|
||||||
|
if(typeof fn==='function'){ bions[b.name]={fn:fn,desc:b.desc,params:b.params}; names.push(b.name); }
|
||||||
|
}).catch(function(){});
|
||||||
|
}); });
|
||||||
|
chain.then(function(){ if(!alive)return; renderPal(); log('✓ '+names.length+' bions chargés (WASM)','ok'); });
|
||||||
|
}).catch(function(){ log('bions.json indisponible','err'); });
|
||||||
|
|
||||||
|
function renderPal(){ pal.innerHTML=
|
||||||
|
ANAMES.map(function(n){return '<div class="xl__b" data-ins="'+n+'">'+n+' <span>array bion</span></div>';}).join('')
|
||||||
|
+ names.sort().map(function(n){return '<div class="xl__b" data-ins="'+n+'">'+n+' <span>'+esc(bions[n].desc||'')+'</span></div>';}).join(''); }
|
||||||
|
|
||||||
|
// ---- parseur FLOW : lignes "x = expr" / "expr" ; expr = call ( |> call )* ----
|
||||||
|
function parseFlow(src){
|
||||||
|
var prog=[];
|
||||||
|
src.split('\n').forEach(function(line){
|
||||||
|
line=line.replace(/#.*/,'').trim(); if(!line) return;
|
||||||
|
var name=null, m=line.match(/^([a-z_][a-z0-9_]*)\s*=\s*(.+)$/i); if(m){ name=m[1]; line=m[2]; }
|
||||||
|
var segs=line.split('|>').map(function(s){return s.trim();});
|
||||||
|
prog.push({assign:name, pipe:segs.map(parseCall)});
|
||||||
|
});
|
||||||
|
return prog;
|
||||||
|
}
|
||||||
|
// ionique: ⟨a b⟩ B:name ▷ B:name ⟨c⟩ ▷ X:emit -> même structure de pipe
|
||||||
|
function parseIonique(src){
|
||||||
|
var prog=[];
|
||||||
|
src.split('\n').forEach(function(line){
|
||||||
|
line=line.replace(/#.*/,'').trim(); if(!line) return;
|
||||||
|
var segs=line.split('▷').map(function(s){return s.trim();});
|
||||||
|
var pipe=segs.map(function(s){
|
||||||
|
var args=[]; s=s.replace(/⟨([^⟩]*)⟩/g,function(_,g){ g.trim().split(/\s+/).forEach(function(t){if(t)args.push(t);}); return ''; }).trim();
|
||||||
|
var op=s.replace(/^[BXKWP]:/,'')||null;
|
||||||
|
if(/^X:/.test(s)||op==='emit') return {op:'emit', args:args.length?args:['xion']};
|
||||||
|
return {op:op, args:args};
|
||||||
|
});
|
||||||
|
prog.push({assign:null, pipe:pipe});
|
||||||
|
});
|
||||||
|
return prog;
|
||||||
|
}
|
||||||
|
function parseCall(s){
|
||||||
|
if(/^emit\b/.test(s)){ var a=s.slice(4).trim().match(/"([^"]*)"|(\S+)/g)||[]; return {op:'emit', args:a.map(stripq)}; }
|
||||||
|
var t=s.split(/\s+/).filter(Boolean); return {op:t[0], args:t.slice(1)};
|
||||||
|
}
|
||||||
|
function stripq(x){ return x.replace(/^"|"$/g,''); }
|
||||||
|
|
||||||
|
// ---- ARRAY BIONS (validé RS-7) : le type tableau du langage xerboxion ----
|
||||||
|
// Les bions WASM sont scalaires ; ces ops opèrent sur des TABLEAUX de bions.
|
||||||
|
// Noms choisis pour NE PAS entrer en collision avec les bions scalaires (add/min/max…).
|
||||||
|
var AOPS={
|
||||||
|
array:function(){ return Array.prototype.slice.call(arguments).map(Number); }, // array 5 3 8 → [5,3,8]
|
||||||
|
vec: function(){ return Array.prototype.slice.call(arguments).map(Number); }, // alias (tableau dynamique)
|
||||||
|
at: function(a,i){ return Array.isArray(a)? a[Number(i)] : undefined; }, // accès O(1)
|
||||||
|
len: function(a){ return Array.isArray(a)? a.length : 0; },
|
||||||
|
push: function(a,x){ return (Array.isArray(a)?a:[]).concat([Number(x)]); }, // amorti O(1)
|
||||||
|
sum: function(a){ return Array.isArray(a)? a.reduce(function(s,x){return s+Number(x);},0) : Number(a); },
|
||||||
|
sort: function(a){ return Array.isArray(a)? a.slice().sort(function(x,y){return x-y;}) : a; },
|
||||||
|
rev: function(a){ return Array.isArray(a)? a.slice().reverse() : a; }
|
||||||
|
};
|
||||||
|
var ANAMES=['array','vec','at','len','push','sum','sort','rev'];
|
||||||
|
|
||||||
|
// ---- éval : exécute le graphe de bions ----
|
||||||
|
function run(){
|
||||||
|
out.innerHTML='<span class="dim">run…</span>';
|
||||||
|
var prog = mode==='ionique'?parseIonique(ta.value):parseFlow(ta.value);
|
||||||
|
var vars={}, last=null;
|
||||||
|
try{
|
||||||
|
prog.forEach(function(stmt){
|
||||||
|
var val=null, piped=null;
|
||||||
|
stmt.pipe.forEach(function(call,i){
|
||||||
|
var args=call.args.map(function(a){ return resolve(a,vars); });
|
||||||
|
if(i>0 && piped!==null) args.unshift(piped); // |> : injecte le résultat précédent en 1er
|
||||||
|
if(call.op==='emit'){ var topic=typeof args[args.length-1]==='string'?args.pop():(typeof args[0]==='string'?args.shift():'xion'); var v=args.length?args[args.length-1]:piped; emitBus(topic,v); log('→ bus ploxion.xerlang.'+topic+' = '+v,'ok'); piped=v; return; }
|
||||||
|
if(AOPS[call.op]){ piped=AOPS[call.op].apply(null,args); return; } // array bions (tableaux, pas de map(Number))
|
||||||
|
var b=bions[call.op]; if(!b) throw 'bion inconnu : '+call.op;
|
||||||
|
piped=b.fn.apply(null,args.map(Number));
|
||||||
|
});
|
||||||
|
val=piped; last=val;
|
||||||
|
if(stmt.assign){ vars[stmt.assign]=val; log(stmt.assign+' = '+val,'dim'); }
|
||||||
|
else if(val!==null && val!==undefined) log('= '+val,'ok');
|
||||||
|
});
|
||||||
|
log('✓ ('+names.length+' bions WASM, exécuté sur le moteur xerboxion)','dim');
|
||||||
|
}catch(e){ log('✗ '+e,'err'); }
|
||||||
|
renderGraph(prog);
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
function resolve(a,vars){ if(a in vars) return vars[a]; if(/^-?\d+(\.\d+)?$/.test(a)) return Number(a); if(/^".*"$/.test(a)) return a.slice(1,-1); return a; }
|
||||||
|
function emitBus(topic,v){ try{ if(window.jOSPorts&&window.jOSPorts.emit) window.jOSPorts.emit('xerlang',topic,String(v)); }catch(e){} }
|
||||||
|
|
||||||
|
function renderGraph(prog){
|
||||||
|
var h=''; prog.forEach(function(stmt){ stmt.pipe.forEach(function(c,i){ if(i>0)h+='<div class="xl__arrow">▶</div>'; h+='<div class="xl__node"><b>'+esc(c.op||'?')+'</b><small>'+esc(c.args.join(' '))+'</small></div>'; }); h+='<div style="flex-basis:100%"></div>'; });
|
||||||
|
graph.innerHTML=h||'<span class="dim" style="color:var(--xr-muted,#8aa0c0)">programme vide</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- interactions ----
|
||||||
|
root.addEventListener('click',function(e){
|
||||||
|
var tab=e.target.closest('[data-m]'); if(tab){ mode=tab.getAttribute('data-m'); root.querySelectorAll('.xl__tab').forEach(function(t){t.classList.toggle('on',t===tab);});
|
||||||
|
ta.style.display=mode==='graphe'?'none':''; graph.style.display=mode==='graphe'?'flex':'none';
|
||||||
|
if(mode!=='graphe' && ta.value.trim()==='' ) ta.value=samples[mode]||'';
|
||||||
|
if(mode==='ionique'&&ta.value.indexOf('▷')<0) ta.value=samples.ionique;
|
||||||
|
if(mode==='graphe') run(); return; }
|
||||||
|
if(e.target.closest('[data-run]')){ run(); return; }
|
||||||
|
if(e.target.closest('[data-bus]')){ var v=run(); emitBus('result',v); log('→ émis sur le bus xion','ok'); return; }
|
||||||
|
if(e.target.closest('[data-core]')){ var prog=mode==='ionique'?parseIonique(ta.value):parseFlow(ta.value); log('export core (composition) :','dim'); log(JSON.stringify(prog),'dim'); log('→ compilable en module WASM sur xerboxion-core (à câbler)','dim'); return; }
|
||||||
|
var ins=e.target.closest('[data-ins]'); if(ins){ ta.value+=(ta.value&&!/\n$/.test(ta.value)?'\n':'')+ins.getAttribute('data-ins')+' '; ta.focus(); }
|
||||||
|
});
|
||||||
|
return { unmount:function(){ alive=false; container.innerHTML=''; } };
|
||||||
|
}
|
||||||
|
window.jOSApps=window.jOSApps||{};
|
||||||
|
window.jOSApps[ID]={manifest:{id:ID,name:'Xerlang',icon:'🔤'},mount:mount};
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user