refactor parser to handle arrays, globs and duplicates, add related tests