A basic compiler based off of thejameskyle's super-tiny-compiler

advent01-1.mc 401B

1234567891011121314
  1. ; Requires the input for Advent of Code(http://adventofcode.com/) Day 1
  2. (log result)
  3. (include str fs)
  4. (assign input (fs::readIn "advent.txt"))
  5. (assign i 0)
  6. (assign result 0)
  7. (repeat (str::length input)
  8. (assign current (str::charAtIndex input i))
  9. (if (eq current "(") (assign result (add result 1)))
  10. (if (eq current ")") (assign result (subtract result 1)))
  11. (assign i (add i 1))
  12. )
  13. (log result)