def test_GIVEN_trying_to_parse_play_WHEN_eof_is_the_only_token_THEN_syntax_error_is_raised( self): tokens = [Token(TokenTypes.Eof)] parser = Parser(t for t in tokens) with self.assertRaises(SPLSyntaxError): parser.play()
def test_GIVEN_trying_to_parse_play_WHEN_minimal_valid_play_THEN_no_errors_raised( self): tokens = [Token(TokenTypes.EndLine)] # Have to have an initial line. tokens = _add_act(tokens) tokens = _add_scene(tokens) tokens.append(Token(TokenTypes.Eof)) parser = Parser(t for t in tokens) parser.play()
def main(input_file, output_dir, cls_name, cls_maj_version, cls_min_version): with open(input_file) as f: spl_lexer = Lexer(f.read()) spl_parser = Parser(spl_lexer.token_generator()) ast = spl_parser.play() asl = flatten_ast(ast) cls = Builder(cls_name).asl_dump(asl).build() cls.set_version(cls_maj_version, cls_min_version) Exporter(cls).export_as_file(output_dir)