working version of parser; partially tested; problem fixed with rule order in grammar