Demo entry 6328706

asdfsaf

   

Submitted by anonymous on Nov 29, 2016 at 05:22
Language: Swift. Code size: 455 Bytes.

class Adder : Parser {
        var stack: Int[] = []
        func push() { stack.append(self.text.toInt()!) }
        func add() {
            let left = stack.removeLast()
            let right = stack.removeLast()
            stack.append(left + right)
        }
        override func rules() {
            let number = ("0"-"9")+ => push
            let expr = (number ~ "+" ~ number) => add
            start_rule = expr
        }
    }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).