link-grammar-5.8.0/link-grammar/dict-file/read-dict.c
/**
 * Make sure the string s is a valid connector.
 * Return true if the connector is valid, else return false,
 * and print an appropriate warning message.
 */
Make sure the string s is a valid connector.
Return true if the connector is valid, else return false,
and print an appropriate warning message.
Make sure the string s is a valid connector . Return true if the connector is valid else return false and print an appropriate warning message .
static bool check_connector(Dictionary dict, const char * s)
{
	int i;
	i = strlen(s);
	if (i < 1) {
		dict_error(dict, "Expecting a connector.");
		return false;
	}
	i = s[i-1];  
	if ((i != '+') && (i != '-') && (i != ANY_DIR)) {
		dict_error(dict, "A connector must end in a \"+\", \"-\" or \"$\".");
		return false;
	}
	if (*s == '@') s++;
	if (('h' == *s) || ('d' == *s)) s++;
	if (!isupper((unsigned char)*s)) {
		dict_error(dict, "Connectors must start with uppercase after an optional h or d.");
		return false;
	}
	if ((*s == 'I') && (*(s+1) == 'D') && isupper((unsigned char)*(s+2))) {
		dict_error(dict, "Connectors beginning with \"ID\" are forbidden");
		return false;
	}
	bool connector_base = true;
	s++; 
	while (*(s+1)) {
		if ((!isalnum((unsigned char)*s)) && (*s != WILD_TYPE)) {
			dict_error(dict, "All letters of a connector must be ASCII alpha-numeric.");
			return false;
		}
		if (isupper((unsigned char)*s))
		{
			if (!connector_base)
			{
				dict_error(dict, "Connector subscript contains uppercase.");
				return false;
			}
		}
		else
		{
			connector_base = false;
		}
		s++;
	}
	return true;
}
static bool check_connector ( Dictionary dict , const char * s ) { int i ; i = strlen ( s ) ; if ( i < 1 ) { dict_error ( dict , " " ) ; return false ; } i = s [ i - 1 ] ; if ( ( i != ' ' ) && ( i != ' ' ) && ( i != ANY_DIR ) ) { dict_error ( dict , " \" \" \" \" \" \" " ) ; return false ; } if ( * s == ' ' ) s ++ ; if ( ( ' ' == * s ) || ( ' ' == * s ) ) s ++ ; if ( ! isupper ( ( unsigned char ) * s ) ) { dict_error ( dict , " " ) ; return false ; } if ( ( * s == ' ' ) && ( * ( s + 1 ) == ' ' ) && isupper ( ( unsigned char ) * ( s + 2 ) ) ) { dict_error ( dict , " \" \" " ) ; return false ; } bool connector_base = true ; s ++ ; while ( * ( s + 1 ) ) { if ( ( ! isalnum ( ( unsigned char ) * s ) ) && ( * s != WILD_TYPE ) ) { dict_error ( dict , " " ) ; return false ; } if ( isupper ( ( unsigned char ) * s ) ) { if ( ! connector_base ) { dict_error ( dict , " " ) ; return false ; } } else { connector_base = false ; } s ++ ; } return true ; }
Make sure the string s is a valid connector.
Make sure the string s is a valid connector .
/* the last character of the token */ /* Note that IDx when x is a subscript is allowed (to allow e.g. ID4id+). */ /* The first uppercase has been validated above. */