Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


  <div class="container">

  <textarea id="language_input" type="text"/>
3 22 +</textarea>
  <div class="results" id="language_output">5</div>

  <div id="stack_output"></div>

  <h4>A Simple Stack Based Language</h4>
  <p>Simple Stack based language in postfix notation.</p>

  <p>Ehem,  I'll say that again in English</p>

  <h4>A Backwards Calculator</h4>
  <p> a really simple calculator with a twist.</p>

  <p>Postfix means instead of writing "2 + 3" you write "3 2 +". Make sure there is space between every number and every operator. Parentheses will not help you here.</p>


3 22 +        ->        25




                .container {
  float: left;
  margin: 0 60px 0 60px;

.details {



var selInput ='#language_input')
  .on('keyup', _.debounce(executeFromInput, 500))
var selOutput ='#language_output')

// Drive first one

function executeFromInput() {
  var input = selInput.node().value;
  var tokens = parse(input)
  var output = execute(tokens);

function execute(tokens) {
  var stack = [];
  _.each(tokens, function (t, i) {
    if (stack.length > 10000) return userError('Stack overflow. That means something went horribly wrong on my end. Sorry boo.');
    switch (t.type) {
    // For values, just throw'm on to the stack.
    case "number":
    // Operators
    case "operator":
     if (stack.length < 2) return userError('Stack underflow. That means you used an operator with not enough values on the stack.');

     // Take operatands off of stack.
     var a = stack.pop();
     var b = stack.pop();

     // Operator implementations
     switch(t.value) {
     case '+':
       log(a, b, t)
       a.value = a.value + b.value;
     case '-':
       a.value = a.value - b.value;
     case '*':
       a.value = a.value * b.value;
     case '/':
       a.value = a.value / b.value;

     // Finally push new value back on stack;
  return (t, i) { return t.value }).join(' ')

function parse(input) {
  var tokens = [];
  // Tokens are any-whitespace delimited
  // TODO: Can reduce this by using regex that matches any group of whitespace for split, instead of string
  _.each(input.split(' '), function (word, i) {
    // First match group is operators, second match group is values. Reserving a lot more than I'm implementing. See execute()
    var reTokens= /(\+|\-|\/|\*|\x|\^)|(\d+(.\d*)?(e\d*)?)/i;
    var matchTokens = word.match(reTokens);
    // Do nothing with words we don't understand
    if ( ! matchTokens ) return;
    var token = {
      type: 'BLANK_TOKEN_TYPE',
      value: 'BLANK_TOKEN_VALUE',
    var op = matchTokens[1];
    var number = matchTokens[2];
    if (op) {
      token.type = 'operator';
      token.value = op
    } else if (number) {
      token.type = 'number';
      token.value = parseFloat(number, 10)
  return tokens;
function userError(message) {
    throw new Error(message)

function log(mess,ag,es) { console.log.apply(console, arguments) }