roughly implement syntax analyser