Hapy built-in rules provide convenience and safety for common use cases. All these rules are objects and functions declared in Hapy/Rules.cc. Text matching is case sensitive. Hapy rule expression syntax is documented elsewhere.
Besides rule semantics, the table below provides a semantically equivalent expression using non-terminals or other rules. The actual Hapy implementation of a built-in rule usually differs from its semantic equivalent.
|Built-in rule||Semantics||Semantically equivalent expression|
|anychar_r||matches any single character (byte, octet)||"\000" | "\001" | ... | "\377"|
|char_set_r(const string &set)||matches any single character in the user-specified set||set | set | ... | set[N]|
|char_range_r(char first, char last)||matches any single character in the user-specified inclusive range||first | (char)(first+1) | ... | last|
|alpha_r||matches any alphabetic character (see isalpha(3) man page)||"A" | "B" | ... "z"|
|digit_r||matches any decimal digit (see isdigit(3) man page)||"0" | "1" | ... "9"|
|alnum_r||matches any alphabetic character and any decimal digit (see isalnum(3) man page)||alpha_r | digit_r|
|space_r||matches any whitespace character, including tabulation and line termination characters (see isspace(3) man page).||" " | "\t" | "\r" | "\n" | ...|
|eol_r||matches the end of the line; currently that means a "\n" character; is there a better way?||"\n"|
|char_r(char c)||matches a given character||"<c>"|
|string_r(const string &s)||matches a given sequence of characters (string)||"<s>"|
|quoted_r(const Rule &element, const Rule &open, const Rule &close)||matches zero or more elements enclosed in opening and closing "quotes"; the opening and closing rules do not have to match; this is handy for comments, strings, CDATA, and other "enclosed" elements.||open >> *(element-close) >> close|
|empty_r||an always successful zero-size match; matches any input without advancing the input position|
|end_r||matches the end of input; a zero-size match|