Refactoring parser

modulize the parser(not pass testing yet)