static int raptor_ntriples_term_valid(unsigned char c, int position, raptor_ntriples_term_class term_class) { int result = 0; switch(term_class) { case RAPTOR_TERM_CLASS_URI: /* ends on > */ result = (c != '>'); break; case RAPTOR_TERM_CLASS_BNODEID: /* ends on first non [A-Za-z0-9_:][-.A-Za-z0-9]* */ result = IS_ASCII_ALPHA(c) || IS_ASCII_DIGIT(c) || c == '_' || c == ':'; if(position) /* FIXME * This isn't correct; '.' is allowed in positions 1..N-1 but * this calling convention of character-by-character cannot * check this. */ result = (result || c == '-' || c == '.'); break; case RAPTOR_TERM_CLASS_STRING: /* ends on " */ result = (c != '"'); break; case RAPTOR_TERM_CLASS_LANGUAGE: /* ends on first non [a-zA-Z]+ ('-' [a-zA-Z0-9]+ )? */ result = IS_ASCII_ALPHA(c); if(position) result = (result || IS_ASCII_DIGIT(c) || c == '-'); break; default: RAPTOR_DEBUG2("Unknown N-Triples term class %d", term_class); } return result; }
static int raptor_ntriples_term_valid(unsigned char c, int position, raptor_ntriples_term_class term_class) { int result=0; switch(term_class) { case RAPTOR_TERM_CLASS_URI: /* ends on > */ result=(c!= '>'); break; case RAPTOR_TERM_CLASS_BNODEID: /* ends on first non [A-Za-z][A-Za-z0-9]* */ result=IS_ASCII_ALPHA(c); if(position) result = (result || IS_ASCII_DIGIT(c)); break; case RAPTOR_TERM_CLASS_STRING: /* ends on " */ result=(c!= '"'); break; case RAPTOR_TERM_CLASS_LANGUAGE: /* ends on first non [a-z0-9]+ ('-' [a-z0-9]+ )? */ result=(IS_ASCII_ALPHA(c) || IS_ASCII_DIGIT(c)); if(position) result = (result || c=='-'); break; case RAPTOR_TERM_CLASS_FULL: result=1; break; default: RAPTOR_FATAL2("Unknown ntriples term %d", term_class); } return result; }
static int raptor_ntriples_term_valid(raptor_parser* rdf_parser, unsigned char c, int position, raptor_ntriples_term_class term_class) { int result = 0; switch(term_class) { case RAPTOR_TERM_CLASS_URI: /* ends on > */ result = (c != '>'); break; case RAPTOR_TERM_CLASS_BNODEID: /* ends on first non [A-Za-z][A-Za-z0-9]* */ result = IS_ASCII_ALPHA(c); if(position) result = (result || IS_ASCII_DIGIT(c)); break; case RAPTOR_TERM_CLASS_STRING: /* ends on " */ result = (c != '"'); break; case RAPTOR_TERM_CLASS_LANGUAGE: /* ends on first non [a-zA-Z]+ ('-' [a-zA-Z0-9]+ )? */ result = IS_ASCII_ALPHA(c); if(position) result = (result || IS_ASCII_DIGIT(c) || c == '-'); break; default: raptor_parser_error(rdf_parser, "Unknown N-Triples term class %d", term_class); } return result; }
/** Check if input line contains a meta delimiter; * @return 1 if it does, 0 otherwise. */ static int ltermMetaInput(struct lterms *lts) { struct LtermInput *lti = &(lts->ltermInput); UNICHAR *delimLoc, *ustr, *ustr2; LTERM_LOG(ltermMetaInput,40,("\n")); if (lts->options & LTERM_NOMETA_FLAG) return 0; /* Assert that there is at least one free character position in the buffer */ assert(lti->inputChars < MAXCOL); /* Insert null character at the end of the input buffer */ lti->inputLine[lti->inputChars] = U_NUL; /* Locate first occurrence of meta delimiter in input line */ delimLoc = ucschr(lti->inputLine, ltermGlobal.metaDelimiter); if (delimLoc == NULL) return 0; for (ustr=lti->inputLine; ustr<delimLoc; ustr++) /* skip spaces/TABs */ if ((*ustr != U_SPACE) && (*ustr != U_TAB)) break; if (ustr == delimLoc) { /* Nameless meta command */ LTERM_LOG(ltermMetaInput,41,("Nameless meta command\n")); return 1; } if (!IS_ASCII_LETTER(*ustr)) /* meta command must start with a letter */ return 0; for (ustr2=ustr+1; ustr2<delimLoc; ustr2++) if (!IS_ASCII_LETTER(*ustr2) && !IS_ASCII_DIGIT(*ustr2)) return 0; LTERM_LOG(ltermMetaInput,41,("Named meta command\n")); return 1; }