Moved code from parser to compiler