def read_examples(filename)
  ("\n"+File.read(filename)).split(/\nname: ?/)[1..-1].map{|test|
    name = test[/.*\n/]
    $'[/\noutput: ?/]
    expected = $'
    rest = $`
    if rest[/\ninput2: ?/]
      input2 = $'
      rest = $`
      if rest[/\ninput1?: ?/]
        input = [$', input2]
        prog = $`
      else
        input = [input2]
        prog = rest
      end
    elsif rest[/\ninput: ?/]
      input = $'
      prog = $`
    else
      input = ''
      prog = rest
    end
    [name, prog.b, input, expected].map{|field|
      if Array === field
        field.map{|f|
          f.gsub('EOL', "").sub(/EOF\n/,'')
        }
      else
          field.gsub('EOL', "").sub(/EOF\n/,'')
      end
    }
  }
end
Examples = read_examples("web/examples.txt")
ExamplesAndTests = Examples + read_examples("test/full_tests.txt")