Lines Matching refs:ch
165 // Returns true iff ch appears anywhere in str (excluding the
167 bool IsInSet(char ch, const char* str) {
168 return ch != '\0' && strchr(str, ch) != NULL;
171 // Returns true iff ch belongs to the given classification. Unlike
174 bool IsDigit(char ch) { return '0' <= ch && ch <= '9'; }
175 bool IsPunct(char ch) {
176 return IsInSet(ch, "^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~");
178 bool IsRepeat(char ch) { return IsInSet(ch, "?*+"); }
179 bool IsWhiteSpace(char ch) { return IsInSet(ch, " \f\n\r\t\v"); }
180 bool IsWordChar(char ch) {
181 return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||
182 ('0' <= ch && ch <= '9') || ch == '_';
191 // matches ch. The result is undefined if the atom is invalid.
192 bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
195 case 'd': return IsDigit(ch);
196 case 'D': return !IsDigit(ch);
197 case 'f': return ch == '\f';
198 case 'n': return ch == '\n';
199 case 'r': return ch == '\r';
200 case 's': return IsWhiteSpace(ch);
201 case 'S': return !IsWhiteSpace(ch);
202 case 't': return ch == '\t';
203 case 'v': return ch == '\v';
204 case 'w': return IsWordChar(ch);
205 case 'W': return !IsWordChar(ch);
207 return IsPunct(pattern_char) && pattern_char == ch;
210 return (pattern_char == '.' && ch != '\n') || pattern_char == ch;
250 const char ch = regex[i];
252 if (ch == '^' && i > 0) {
256 } else if (ch == '$' && regex[i + 1] != '\0') {
260 } else if (IsInSet(ch, "()[]{}|")) {
262 << "'" << ch << "' is unsupported.";
264 } else if (IsRepeat(ch) && !prev_repeatable) {
266 << "'" << ch << "' can only follow a repeatable token.";
270 prev_repeatable = !IsInSet(ch, "^$?*+");