Skip to content

Instantly share code, notes, and snippets.

@kvendrik
Last active October 2, 2015 13:22
Show Gist options
  • Select an option

  • Save kvendrik/757aac28da96a131afdc to your computer and use it in GitHub Desktop.

Select an option

Save kvendrik/757aac28da96a131afdc to your computer and use it in GitHub Desktop.
indexlang
git clone [email protected]:757aac28da96a131afdc.git indexlang-tools
cd indexlang-tools
make prep
./compiler "$(./converter "console.log('hello world');")"
./converter "$(cat jscode.js)" > test.indexlang
./compiler "$(cat test.indexlang)"
if{} = 8,5,26,27
console.log('hello world'); = 2,14,13,18,14,11,4,28,11,14,6,29,30,7,4,11,11,14,33,22,14,17,11,3,30,32,31
for(var i = 0; i < 10; i++){ console.log('hello world '+i); } = 5,14,17,29,21,0,17,47,8,47,36,47,37,31,47,8,47,33,47,38,37,31,47,8,35,35,32,26,47,2,14,13,18,14,11,4,28,11,14,6,29,30,7,4,11,11,14,47,22,14,17,11,3,47,30,35,8,32,31,47,27
INTERPRETER=python ./compiler "$(./converter "print 'hola'")"
#!/usr/bin/env node
var exec = require('child_process').exec;
if(!process.argv[2]){
console.log('Usage: compiler <code_str>');
process.exit(1);
}
var interpreter = process.env.INTERPRETER || 'node',
alp = 'abcdefghijklmnopqrstuvwxyz{}.(\';)<>+=0123456789\n\tABCDEFGHIJKLMNOPQRSTUVWXYZ? '.split(''),
codeStr = process.argv[2].split(',').map(function(idx){
return alp[idx];
}).join('');
exec('echo "'+codeStr+'" | '+interpreter, function(error, stdout, stderr) {
console.log(stdout, stderr);
process.exit(0);
});
#!/usr/bin/env node
var exec = require('child_process').exec;
if(!process.argv[2]){
console.log('Usage: converter <code_str>');
process.exit(1);
}
var alp = 'abcdefghijklmnopqrstuvwxyz{}.(\';)<>+=0123456789\n\tABCDEFGHIJKLMNOPQRSTUVWXYZ? '.split(''),
indexLang = process.argv[2].split('').map(function(char){
return alp.indexOf(char);
}).join(',');
console.log(indexLang);
process.exit(0);
all: prep
prep:
mv compiler.js compiler
mv converter.js converter
chmod 755 compiler converter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment