diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-04-19 21:45:46 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-04-19 21:45:46 -0700 |
commit | 66a38d816de5d5932fd2d99c74538c43422ad44a (patch) | |
tree | 30342ab840f281739c11f181c273fce74cfa82af /regex.h | |
parent | 20a737a17009582fd3022fb2f67e4b472445bc4f (diff) | |
download | txr-66a38d816de5d5932fd2d99c74538c43422ad44a.tar.gz txr-66a38d816de5d5932fd2d99c74538c43422ad44a.tar.bz2 txr-66a38d816de5d5932fd2d99c74538c43422ad44a.zip |
First cut at implementing \s, \d, \w, \S, \D and \W regex tokens.
* lib.c (init): Call regex_init.
* parser.l: return new REGTOKEN kind.
* parser.y (REGTOKEN): New token type.
(REGTERM): Translate REGTERM to keyword.
(regclass): Restructured to handle inherited nodes as lists.
(regclassterm): Produce $$ as list. Add handling for REGTOKEN
occurring inside character class by expanding it. This might not
be the best approach.
(yybadtoken): Handle REGTOKEN in switch.
* regex.c (struct any_char_set, struct small_char_set,
struct displaced_char_set, struct large_char_set,
struct xlarge_char_set): New bitfield member, stat.
(char_set_create): New parameter for indicating static char set.
(char_set_destroy): Do not free a static char set.
(char_set_compile): Pass zero to new parameter of char_set_create.
(spaces): New static array.
(space_cs, digit_cs, word_cs, cspace_cs, cdigit_cs, cword_cs): New
static pointers to char_set_t.
(init_special_char_sets, nfa_compile_given_set): New static function.
(nfa_compile_regex, dv_compile_regex): Handle new character set token
keywords.
(space_k, digit_k, word_char_k, cspace_k, cdigit_k, cword_char_k,
regex_space_chars): New variables.
(regex_init): New function.
* regex.h (space_k, digit_k, word_char_k, cspace_k, cdigit_k,
cword_char_k, regex_space_chars, regex_init): Declared.
Diffstat (limited to 'regex.h')
-rw-r--r-- | regex.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -24,8 +24,14 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +extern val space_k, digit_k, word_char_k; +extern val cspace_k, cdigit_k, cword_char_k; +extern val regex_space_chars; + val regex_compile(val regex_sexp); val regexp(val); val search_regex(val haystack, val needle_regex, val start_num, val from_end); val match_regex(val str, val regex, val pos); val regsub(val regex, val repl, val str); + +void regex_init(void); |