Error_code::Type fetch_image::fetch_from_source(anime_database& db, std::size_t source_index, const astd::string_view starting_number, const astd::filesystem::path& destination) { source_token number_token(db.input.sources[source_index], "number", starting_number); if (!number_token.valid) { return Error_code::SOURCE_PATH_PARSING_FAILED; } source_token image_token(db.input.sources[source_index], "image", "0"); if (!image_token.valid) { return Error_code::SOURCE_PATH_PARSING_FAILED; } Error_code::Type result = Error_code::CHAPTER_NOT_FOUND; for (std::size_t number_index = 0; number_index < number_token.values.size() && result == Error_code::CHAPTER_NOT_FOUND; ++number_index) { result = fetch_chapter(db, number_token, image_token, source_index, number_index, destination); } return result; }
int yylex(void) { char *s; uDatum u; #ifdef DISTRIB extern Int *higherPriority; #endif /* DISTRIB */ /* initial for a token */ clear_text(); if (bof) { bof = 0; if (nextc == '%') { /* comment line */ skip_percent_comment();/* return next token */ end_text(); clear_text(); } /* printf("bof \n"); */ if (nextc == '>' || nextc == '<') getAgentName(); } restart: while (isspace(nextc) && (nextc != '\n') && (nextc != '\r')) { /* skip blanks */ input(); } if ((nextc == '\n') || (nextc == '\r')) { input(); if (nextc == '%') { /* comment line */ skip_percent_comment();/* return next token */ end_text(); clear_text(); } /* printf("restart\n"); */ if (nextc == '>' || nextc == '<') getAgentName(); goto restart; } end_text(); clear_text(); if (nextc == 0) { /* EOF */ #ifdef DISTRIB if (setHighPrior) { *higherPriority=0; setHighPrior = 0; } #endif return 0; /* don't do input() so next token is EOF */ } #ifdef TTYEDEN prompt = promptsemi; #endif if (isdigit(nextc) || nextc == '.') /* a number or a dot */ return number_token(); if (isalpha(nextc) || nextc == '_') /* a keyword or an identifier */ { append_agentName = 1; return id_token(); } /*if (nextc == '^') { input(); append_agentName = 1; return context_token(); }*/ if (nextc == '\'') { while (input(), nextc != '\'') { if (nextc == '\\') input(); else if (nextc == 0) error("unexpected end-of-file in character constant"); } input(); /* read the quote */ /* mustn't alter the following two lines */ end_text(); /* accept the text */ last_char = '\0'; /* delete the last quote */ backslash(yytext + 1); /* resolve the backslashs */ if (yytext[2]) /* more than one char */ error("single char expected"); u.i = yytext[1]; yylval.dp = makedatum(MYCHAR, u); return CONSTANT; } if (nextc == '\"') { #ifdef TTYEDEN prompt = promptchar; #endif while (input(), nextc != '\"') { if (nextc == '\\') input(); else if (nextc == 0) error("unexpected end-of-file in string constant"); } input(); /* read the quote */ /* mustn't alter the following two lines */ end_text(); /* accept the text */ last_char = '\0'; /* delete the last quote */ backslash(yytext + 1); /* resolve the backslashs */ s = (char *) emalloc(strlen(yytext)); strcpy(s, yytext + 1); u.s = s; yylval.dp = makedatum(STRING, u); return CONSTANT; } input(); /* accept the char, must be the 1st char */ switch (*yytext) { /* the 1st char */ case '@': yylval.dp = makedatum(UNDEF, u); /* bug fix Ash + Carters */ RETURN_TOKEN(CONSTANT); break; case '~': /* for agency --sun */ if (isalpha(nextc) || nextc == '_') { clear_text(); append_agentName = 0; return id_token(); } break; case '$': while (isdigit(nextc)) input(); if (yyleng == 1) RETURN_TOKEN('$'); yylval.narg = atoi(yytext + 1); RETURN_TOKEN(ARG); case '/': #ifdef TTYEDEN prompt = promptcomment; #endif if (nextc == '*') { /* nested comment */ skip_comment(); /* return next token */ end_text(); clear_text(); #ifdef TTYEDEN prompt = prompt1; #endif goto restart; } break; case '#': if (nextc == '#') { skip_one_line_comment(); end_text(); clear_text(); #ifdef TTYEDEN prompt = prompt1; #endif goto restart; } break; } return (multi_symbol_token()); }