analyser: added symbol analysis for a lot of expressions and statements

Also refactored the symbol checking code to extract common code