Source code syntax validation method

Added a new method `validate` that returns a boolean as to whether the source code syntax is valid.