refactor language parsing, add specs