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

advent01-1.mc 415B

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