pgn_read/core/parser.py
def add_token_to_game(text, game, pos=0):
    """Apply first match in text after pos to game and return match end point.
    """
    if isinstance(game, GameIgnoreCasePGN):
        match = ignore_case_format.search(text, pos)
    elif isinstance(game, GameTextPGN):
        match = text_format.search(text, pos)
    else:
        match = import_format.search(text, pos)
    if not match:
        game.set_game_error()
        return None
    lastindex = match.lastindex
    if game.state is not None:
        if lastindex == IFG_GAME_TERMINATION:
            game.append_game_termination_after_error(match)
        elif lastindex == IFG_COMMENT_TO_EOL:
            game.append_comment_to_eol_after_error(match)
        elif lastindex == IFG_START_RAV:
            game.append_start_rav_after_error(match)
        elif lastindex == IFG_END_RAV:
            game.append_end_rav_after_error(match)
        elif lastindex == IFG_ESCAPE:
            game.append_escape_after_error(match)
        elif lastindex == IFG_PASS:
            game.append_pass_after_error(match)
        elif lastindex == IFG_BAD_TAG:
            game.append_bad_tag_after_error(match)
        elif lastindex == IFG_COMMENT:
            game.append_comment_after_error(match)
        elif lastindex == IFG_DOTS:
            game.append_token_after_error_without_separator(match)
        elif lastindex == IFG_CHECK_INDICATOR:
            game.append_token_after_error_without_separator(match),
        else:
            game.append_token_after_error(match)
        return match.end()
    if lastindex == IFG_END_TAG:
        game.append_start_tag(match)
    elif lastindex == IFG_PIECE_MOVE:
        game.append_piece_move(match)
    elif lastindex == IFG_PIECE_DESTINATION:
        game.append_piece_move(match)
    elif lastindex == IFG_PAWN_TO_RANK:
        game.append_pawn_move(match)
    elif lastindex == IFG_PAWN_PROMOTE_TO_RANK:
        game.append_pawn_move(match)
    elif lastindex == IFG_PAWN_PROMOTE_PIECE:
        game.append_pawn_promote_move(match)
    elif lastindex == IFG_CASTLES:
        game.append_castles(match)
    elif lastindex == IFG_GAME_TERMINATION:
        game.append_game_termination(match)
    elif lastindex == IFG_MOVE_NUMBER:
        game.ignore_move_number(match)
    elif lastindex == IFG_DOTS:
        game.ignore_dots(match)
    elif lastindex == IFG_COMMENT_TO_EOL:
        game.append_comment_to_eol(match)
    elif lastindex == IFG_COMMENT:
        game.append_token(match)
    elif lastindex == IFG_START_RAV:
        game.append_start_rav(match)
    elif lastindex == IFG_END_RAV:
        game.append_end_rav(match)
    elif lastindex == IFG_NUMERIC_ANNOTATION_GLYPH:
        game.append_token(match)
    elif lastindex == IFG_RESERVED:
        game.append_reserved(match)
    elif lastindex == IFG_ESCAPE:
        game.ignore_escape(match)
    elif lastindex == IFG_PASS:
        game.append_pass_and_set_error(match)
    elif lastindex == IFG_CHECK_INDICATOR:
        game.ignore_check_indicator(match),
    elif lastindex == IFG_TRADITIONAL_ANNOTATION:
        game.append_glyph_for_traditional_annotation(match),
    elif lastindex == IFG_BAD_COMMENT:
        game.append_token_and_set_error(match),
    elif lastindex == IFG_BAD_RESERVED:
        game.append_token_and_set_error(match),
    elif lastindex == IFG_BAD_TAG:
        game.append_bad_tag_and_set_error(match),
    elif lastindex == IFG_OTHER_WITH_NON_NEWLINE_WHITESPACE:
        game.append_other_or_disambiguation_pgn(match)
    elif lastindex == IFG_END_OF_FILE_MARKER:
        game.ignore_end_of_file_marker_prefix_to_tag(match)
    else:
        game.append_token_and_set_error(match)
    return match.end()
Apply first match in text after pos to game and return match end point.
    
Apply first match in text after pos to game and return match end point.
Apply first match in text after pos to game and return match end point .
def add_token_to_game(text, game, pos=0):
    if isinstance(game, GameIgnoreCasePGN):
        match = ignore_case_format.search(text, pos)
    elif isinstance(game, GameTextPGN):
        match = text_format.search(text, pos)
    else:
        match = import_format.search(text, pos)
    if not match:
        game.set_game_error()
        return None
    lastindex = match.lastindex
    if game.state is not None:
        if lastindex == IFG_GAME_TERMINATION:
            game.append_game_termination_after_error(match)
        elif lastindex == IFG_COMMENT_TO_EOL:
            game.append_comment_to_eol_after_error(match)
        elif lastindex == IFG_START_RAV:
            game.append_start_rav_after_error(match)
        elif lastindex == IFG_END_RAV:
            game.append_end_rav_after_error(match)
        elif lastindex == IFG_ESCAPE:
            game.append_escape_after_error(match)
        elif lastindex == IFG_PASS:
            game.append_pass_after_error(match)
        elif lastindex == IFG_BAD_TAG:
            game.append_bad_tag_after_error(match)
        elif lastindex == IFG_COMMENT:
            game.append_comment_after_error(match)
        elif lastindex == IFG_DOTS:
            game.append_token_after_error_without_separator(match)
        elif lastindex == IFG_CHECK_INDICATOR:
            game.append_token_after_error_without_separator(match),
        else:
            game.append_token_after_error(match)
        return match.end()
    if lastindex == IFG_END_TAG:
        game.append_start_tag(match)
    elif lastindex == IFG_PIECE_MOVE:
        game.append_piece_move(match)
    elif lastindex == IFG_PIECE_DESTINATION:
        game.append_piece_move(match)
    elif lastindex == IFG_PAWN_TO_RANK:
        game.append_pawn_move(match)
    elif lastindex == IFG_PAWN_PROMOTE_TO_RANK:
        game.append_pawn_move(match)
    elif lastindex == IFG_PAWN_PROMOTE_PIECE:
        game.append_pawn_promote_move(match)
    elif lastindex == IFG_CASTLES:
        game.append_castles(match)
    elif lastindex == IFG_GAME_TERMINATION:
        game.append_game_termination(match)
    elif lastindex == IFG_MOVE_NUMBER:
        game.ignore_move_number(match)
    elif lastindex == IFG_DOTS:
        game.ignore_dots(match)
    elif lastindex == IFG_COMMENT_TO_EOL:
        game.append_comment_to_eol(match)
    elif lastindex == IFG_COMMENT:
        game.append_token(match)
    elif lastindex == IFG_START_RAV:
        game.append_start_rav(match)
    elif lastindex == IFG_END_RAV:
        game.append_end_rav(match)
    elif lastindex == IFG_NUMERIC_ANNOTATION_GLYPH:
        game.append_token(match)
    elif lastindex == IFG_RESERVED:
        game.append_reserved(match)
    elif lastindex == IFG_ESCAPE:
        game.ignore_escape(match)
    elif lastindex == IFG_PASS:
        game.append_pass_and_set_error(match)
    elif lastindex == IFG_CHECK_INDICATOR:
        game.ignore_check_indicator(match),
    elif lastindex == IFG_TRADITIONAL_ANNOTATION:
        game.append_glyph_for_traditional_annotation(match),
    elif lastindex == IFG_BAD_COMMENT:
        game.append_token_and_set_error(match),
    elif lastindex == IFG_BAD_RESERVED:
        game.append_token_and_set_error(match),
    elif lastindex == IFG_BAD_TAG:
        game.append_bad_tag_and_set_error(match),
    elif lastindex == IFG_OTHER_WITH_NON_NEWLINE_WHITESPACE:
        game.append_other_or_disambiguation_pgn(match)
    elif lastindex == IFG_END_OF_FILE_MARKER:
        game.ignore_end_of_file_marker_prefix_to_tag(match)
    else:
        game.append_token_and_set_error(match)
    return match.end()
def add_token_to_game ( text , game , pos = 0 ) : if isinstance ( game , GameIgnoreCasePGN ) : match = ignore_case_format . search ( text , pos ) elif isinstance ( game , GameTextPGN ) : match = text_format . search ( text , pos ) else : match = import_format . search ( text , pos ) if not match : game . set_game_error ( ) return None lastindex = match . lastindex if game . state is not None : if lastindex == IFG_GAME_TERMINATION : game . append_game_termination_after_error ( match ) elif lastindex == IFG_COMMENT_TO_EOL : game . append_comment_to_eol_after_error ( match ) elif lastindex == IFG_START_RAV : game . append_start_rav_after_error ( match ) elif lastindex == IFG_END_RAV : game . append_end_rav_after_error ( match ) elif lastindex == IFG_ESCAPE : game . append_escape_after_error ( match ) elif lastindex == IFG_PASS : game . append_pass_after_error ( match ) elif lastindex == IFG_BAD_TAG : game . append_bad_tag_after_error ( match ) elif lastindex == IFG_COMMENT : game . append_comment_after_error ( match ) elif lastindex == IFG_DOTS : game . append_token_after_error_without_separator ( match ) elif lastindex == IFG_CHECK_INDICATOR : game . append_token_after_error_without_separator ( match ) , else : game . append_token_after_error ( match ) return match . end ( ) if lastindex == IFG_END_TAG : game . append_start_tag ( match ) elif lastindex == IFG_PIECE_MOVE : game . append_piece_move ( match ) elif lastindex == IFG_PIECE_DESTINATION : game . append_piece_move ( match ) elif lastindex == IFG_PAWN_TO_RANK : game . append_pawn_move ( match ) elif lastindex == IFG_PAWN_PROMOTE_TO_RANK : game . append_pawn_move ( match ) elif lastindex == IFG_PAWN_PROMOTE_PIECE : game . append_pawn_promote_move ( match ) elif lastindex == IFG_CASTLES : game . append_castles ( match ) elif lastindex == IFG_GAME_TERMINATION : game . append_game_termination ( match ) elif lastindex == IFG_MOVE_NUMBER : game . ignore_move_number ( match ) elif lastindex == IFG_DOTS : game . ignore_dots ( match ) elif lastindex == IFG_COMMENT_TO_EOL : game . append_comment_to_eol ( match ) elif lastindex == IFG_COMMENT : game . append_token ( match ) elif lastindex == IFG_START_RAV : game . append_start_rav ( match ) elif lastindex == IFG_END_RAV : game . append_end_rav ( match ) elif lastindex == IFG_NUMERIC_ANNOTATION_GLYPH : game . append_token ( match ) elif lastindex == IFG_RESERVED : game . append_reserved ( match ) elif lastindex == IFG_ESCAPE : game . ignore_escape ( match ) elif lastindex == IFG_PASS : game . append_pass_and_set_error ( match ) elif lastindex == IFG_CHECK_INDICATOR : game . ignore_check_indicator ( match ) , elif lastindex == IFG_TRADITIONAL_ANNOTATION : game . append_glyph_for_traditional_annotation ( match ) , elif lastindex == IFG_BAD_COMMENT : game . append_token_and_set_error ( match ) , elif lastindex == IFG_BAD_RESERVED : game . append_token_and_set_error ( match ) , elif lastindex == IFG_BAD_TAG : game . append_bad_tag_and_set_error ( match ) , elif lastindex == IFG_OTHER_WITH_NON_NEWLINE_WHITESPACE : game . append_other_or_disambiguation_pgn ( match ) elif lastindex == IFG_END_OF_FILE_MARKER : game . ignore_end_of_file_marker_prefix_to_tag ( match ) else : game . append_token_and_set_error ( match ) return match . end ( )
Apply first match in text after pos to game and return match end point.
Apply first match in text after pos to game and return match end point .
"""Apply first match in text after pos to game and return match end point.
    """
text
game
pos