finished most of scanner.c