/usr/include/speech_tools/EST_Regex.h is in libestools2.1-dev 1:2.1~release-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | /************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1997 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/************************************************************************/
#ifndef __EST_REGEX_H__
#define __EST_REGEX_H__
class EST_Regex;
#include "EST_String.h"
/** A Regular expression class to go with the CSTR EST_String class.
*
* The regular expression syntax is the FSF syntax used in emacs and
* in the FSF String library. This is translated into the syntax supported
* by Henry Spensor's regular expression library, this translation is a place
* to look if you find regular expressions not matching where expected.
*
* @see EST_String
* @see string_example
* @author Richard Caley <rjc@cstr.ed.ac.uk>
* @author (regular expression library by Henry Spencer, University of Toronto)
* @version $Id: EST_Regex.h,v 1.3 2004/05/04 00:00:16 awb Exp $
*/
class EST_Regex : protected EST_String {
private:
/// The compiled form.
void *compiled;
/// Compiled form for whole string match.
void *compiled_match;
protected:
/// Compile expression.
void compile();
/// Compile expression in a form which only matches whole string.
void compile_match();
/// Translate the expression into the internally used syntax.
char *regularize(int match) const;
public:
/// Empty constructor, just for form.
EST_Regex(void);
/// Construct from EST_String.
EST_Regex(EST_String s);
/// Construct from C string.
EST_Regex(const char *ex);
/// Copy constructor.
EST_Regex(const EST_Regex &ex);
/// Destructor.
~EST_Regex();
/// Size of the expression.
int size() const { return EST_String::size; };
/// Run to find a matching substring
int run(const char *on, int from, int &start, int &end, int *starts=NULL, int *ends=NULL);
/// Run to see if it matches the entire string.
int run_match(const char *on, int from=0, int *starts=NULL, int *ends=NULL);
/// Get the expression as a string.
EST_String tostring(void) const {return (*this);};
/// Cast operator, disambiguates it for some compilers
operator const char *() const { return (const char *)tostring(); }
int operator == (const EST_Regex ex) const
{ return (const EST_String)*this == (const EST_String)ex; }
int operator != (const EST_Regex ex) const
{ return (const EST_String)*this != (const EST_String)ex; }
/**@name Assignment */
//@{
///
EST_Regex &operator = (const EST_Regex ex);
///
EST_Regex &operator = (const EST_String s);
///
EST_Regex &operator = (const char *s);
//@}
/// Stream output of regular expression.
friend ostream &operator << (ostream &s, const EST_Regex &str);
};
ostream &operator << (ostream &s, const EST_Regex &str);
/**@name Predefined_regular_expressions
* Some regular expressions matching common things are predefined
*/
//@{
/// White space
extern EST_Regex RXwhite; // "[ \n\t\r]+"
/// Sequence of alphabetic characters.
extern EST_Regex RXalpha; // "[A-Za-z]+"
/// Sequence of lower case alphabetic characters.
extern EST_Regex RXlowercase; // "[a-z]+"
/// Sequence of upper case alphabetic characters.
extern EST_Regex RXuppercase; // "[A-Z]+"
/// Sequence of letters and/or digits.
extern EST_Regex RXalphanum; // "[0-9A-Za-z]+"
/// Initial letter or underscore followed by letters underscores or digits.
extern EST_Regex RXidentifier; // "[A-Za-z_][0-9A-Za-z_]+"
/// Integer.
extern EST_Regex RXint; // "-?[0-9]+"
/// Floating point number.
extern EST_Regex RXdouble; // "-?\\(\\([0-9]+\\.[0-9]*\\)\\|\\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)\\([eE][---+]?[0-9]+\\)?"
//@}
// GCC lets us use the static constant to declare arrays, Sun CC
// doesn't, so for a quiet, if ugly, life we declare it here with a suitable
// value and check in EST_Regex.cc to make sure it`s OK
#define EST_Regex_max_subexpressions 10
#endif
|