Modify scanner

To make scanner suitable for working with parser