Simplified Emmental

From Esolang
Jump to navigation Jump to search

Simplified Emmental is a self-modifying language. It is stack-based.

Instruction set

Instruction Description
# Push NUL (ASCII 0) onto stack.
0..9 Pop symbol, multiply by 10, add 0..9 respectively, push back on.
. Pop symbol from the stack and output it.

External resources

Interpreter

#!/usr/bin/ruby
eval 'm=[];c=0;'+ARGF.read.gsub(/[0-9#.]/,Hash.new{|_, k|"c=c*10+#{k};"}.merge({'#'=>'m<<c;c=0;','.'=>'putc c;c=m.pop;'}))