package main

Options :: struct {
	file:           string,
	dump_ast:       bool,
	dont_emit_llvm: bool,
}

parse_args :: proc(args: ^[]string) -> (o: Options) {
	o.file = "<stdin>"
	o.dump_ast = false
	o.dont_emit_llvm = false

	for &arg, idx in args^ {
		if idx == 0 {
			continue
		}

		if len(arg) <= 1 {
			continue
		}

		if arg[0] == '-' && arg[1] != '-' {
			for ch, idx in arg {
				if idx == 0 {
					continue
				}

				switch (ch) {
				case 'd':
					o.dump_ast = true
				case 'L':
					o.dont_emit_llvm = true
				case:
					panic("Invalid command line switch")
				}
			}
		} else if arg[0] == '-' && arg[1] == '-' {
			switch (arg) {
			case "--dump-ast":
				o.dump_ast = true
			case "--dont-emit-llvm":
				o.dont_emit_llvm = true
			case:
				panic("Invalid command line switch")
			}
		} else {
			o.file = arg
		}
	}
	return
}
