Code::Blocks  SVN r11506
Classes | Macros | Typedefs | Functions
sqstdrex.cpp File Reference
#include <squirrel.h>
#include <string.h>
#include <ctype.h>
#include <setjmp.h>
#include "sqstdstring.h"
Include dependency graph for sqstdrex.cpp:

Go to the source code of this file.

Classes

struct  tagSQRexNode
 
struct  SQRex
 

Macros

#define scisprint   isprint
 
#define OP_GREEDY   (MAX_CHAR+1)
 
#define OP_OR   (MAX_CHAR+2)
 
#define OP_EXPR   (MAX_CHAR+3)
 
#define OP_NOCAPEXPR   (MAX_CHAR+4)
 
#define OP_DOT   (MAX_CHAR+5)
 
#define OP_CLASS   (MAX_CHAR+6)
 
#define OP_CCLASS   (MAX_CHAR+7)
 
#define OP_NCLASS   (MAX_CHAR+8)
 
#define OP_RANGE   (MAX_CHAR+9)
 
#define OP_CHAR   (MAX_CHAR+10)
 
#define OP_EOL   (MAX_CHAR+11)
 
#define OP_BOL   (MAX_CHAR+12)
 
#define OP_WB   (MAX_CHAR+13)
 
#define SQREX_SYMBOL_ANY_CHAR   ('.')
 
#define SQREX_SYMBOL_GREEDY_ONE_OR_MORE   ('+')
 
#define SQREX_SYMBOL_GREEDY_ZERO_OR_MORE   ('*')
 
#define SQREX_SYMBOL_GREEDY_ZERO_OR_ONE   ('?')
 
#define SQREX_SYMBOL_BRANCH   ('|')
 
#define SQREX_SYMBOL_END_OF_STRING   ('$')
 
#define SQREX_SYMBOL_BEGINNING_OF_STRING   ('^')
 
#define SQREX_SYMBOL_ESCAPE_CHAR   ('\\')
 

Typedefs

typedef int SQRexNodeType
 
typedef struct tagSQRexNode SQRexNode
 

Functions

static SQInteger sqstd_rex_list (SQRex *exp)
 
static SQInteger sqstd_rex_newnode (SQRex *exp, SQRexNodeType type)
 
static void sqstd_rex_error (SQRex *exp, const SQChar *error)
 
static void sqstd_rex_expect (SQRex *exp, SQInteger n)
 
static SQChar sqstd_rex_escapechar (SQRex *exp)
 
static SQInteger sqstd_rex_charclass (SQRex *exp, SQInteger classid)
 
static SQInteger sqstd_rex_charnode (SQRex *exp, SQBool isclass)
 
static SQInteger sqstd_rex_class (SQRex *exp)
 
static SQInteger sqstd_rex_parsenumber (SQRex *exp)
 
static SQInteger sqstd_rex_element (SQRex *exp)
 
static SQBool sqstd_rex_matchcclass (SQInteger cclass, SQChar c)
 
static SQBool sqstd_rex_matchclass (SQRex *exp, SQRexNode *node, SQChar c)
 
static const SQCharsqstd_rex_matchnode (SQRex *exp, SQRexNode *node, const SQChar *str, SQRexNode *next)
 
SQRexsqstd_rex_compile (const SQChar *pattern, const SQChar **error)
 
void sqstd_rex_free (SQRex *exp)
 
SQBool sqstd_rex_match (SQRex *exp, const SQChar *text)
 
SQBool sqstd_rex_searchrange (SQRex *exp, const SQChar *text_begin, const SQChar *text_end, const SQChar **out_begin, const SQChar **out_end)
 
SQInteger sqstd_rex_getsubexpcount (SQRex *exp)
 
SQBool sqstd_rex_getsubexp (SQRex *exp, SQInteger n, SQRexMatch *subexp)
 

Class Documentation

◆ tagSQRexNode

struct tagSQRexNode

Definition at line 54 of file sqstdrex.cpp.

Collaboration diagram for tagSQRexNode:
Class Members
SQInteger left
SQInteger next
SQInteger right
SQRexNodeType type

◆ SQRex

struct SQRex

Definition at line 61 of file sqstdrex.cpp.

Collaboration diagram for SQRex:
Class Members
const SQChar * _bol
SQInteger _currsubexp
const SQChar * _eol
const SQChar ** _error
SQInteger _first
void * _jmpbuf
SQRexMatch * _matches
SQInteger _nallocated
SQRexNode * _nodes
SQInteger _nsize
SQInteger _nsubexpr
SQInteger _op
const SQChar * _p

Macro Definition Documentation

◆ OP_BOL

#define OP_BOL   (MAX_CHAR+12)

Definition at line 39 of file sqstdrex.cpp.

Referenced by sqstd_rex_list(), and sqstd_rex_matchnode().

◆ OP_CCLASS

#define OP_CCLASS   (MAX_CHAR+7)

◆ OP_CHAR

#define OP_CHAR   (MAX_CHAR+10)

Definition at line 37 of file sqstdrex.cpp.

◆ OP_CLASS

#define OP_CLASS   (MAX_CHAR+6)

Definition at line 33 of file sqstdrex.cpp.

Referenced by sqstd_rex_class(), and sqstd_rex_matchnode().

◆ OP_DOT

#define OP_DOT   (MAX_CHAR+5)

Definition at line 32 of file sqstdrex.cpp.

Referenced by sqstd_rex_element(), and sqstd_rex_matchnode().

◆ OP_EOL

#define OP_EOL   (MAX_CHAR+11)

Definition at line 38 of file sqstdrex.cpp.

Referenced by sqstd_rex_element(), and sqstd_rex_matchnode().

◆ OP_EXPR

#define OP_EXPR   (MAX_CHAR+3)

◆ OP_GREEDY

#define OP_GREEDY   (MAX_CHAR+1)

Definition at line 28 of file sqstdrex.cpp.

Referenced by sqstd_rex_element(), and sqstd_rex_matchnode().

◆ OP_NCLASS

#define OP_NCLASS   (MAX_CHAR+8)

Definition at line 35 of file sqstdrex.cpp.

Referenced by sqstd_rex_class(), and sqstd_rex_matchnode().

◆ OP_NOCAPEXPR

#define OP_NOCAPEXPR   (MAX_CHAR+4)

Definition at line 31 of file sqstdrex.cpp.

Referenced by sqstd_rex_element(), and sqstd_rex_matchnode().

◆ OP_OR

#define OP_OR   (MAX_CHAR+2)

Definition at line 29 of file sqstdrex.cpp.

Referenced by sqstd_rex_list(), and sqstd_rex_matchnode().

◆ OP_RANGE

#define OP_RANGE   (MAX_CHAR+9)

Definition at line 36 of file sqstdrex.cpp.

Referenced by sqstd_rex_class(), and sqstd_rex_matchclass().

◆ OP_WB

#define OP_WB   (MAX_CHAR+13)

Definition at line 40 of file sqstdrex.cpp.

Referenced by sqstd_rex_charnode(), and sqstd_rex_matchnode().

◆ scisprint

#define scisprint   isprint

Definition at line 12 of file sqstdrex.cpp.

Referenced by sqstd_rex_charnode(), and sqstd_rex_escapechar().

◆ SQREX_SYMBOL_ANY_CHAR

#define SQREX_SYMBOL_ANY_CHAR   ('.')

Definition at line 42 of file sqstdrex.cpp.

Referenced by sqstd_rex_element().

◆ SQREX_SYMBOL_BEGINNING_OF_STRING

#define SQREX_SYMBOL_BEGINNING_OF_STRING   ('^')

Definition at line 48 of file sqstdrex.cpp.

Referenced by sqstd_rex_class(), and sqstd_rex_list().

◆ SQREX_SYMBOL_BRANCH

#define SQREX_SYMBOL_BRANCH   ('|')

Definition at line 46 of file sqstdrex.cpp.

Referenced by sqstd_rex_element(), and sqstd_rex_list().

◆ SQREX_SYMBOL_END_OF_STRING

#define SQREX_SYMBOL_END_OF_STRING   ('$')

Definition at line 47 of file sqstdrex.cpp.

Referenced by sqstd_rex_element().

◆ SQREX_SYMBOL_ESCAPE_CHAR

#define SQREX_SYMBOL_ESCAPE_CHAR   ('\\')

Definition at line 49 of file sqstdrex.cpp.

Referenced by sqstd_rex_charnode(), and sqstd_rex_escapechar().

◆ SQREX_SYMBOL_GREEDY_ONE_OR_MORE

#define SQREX_SYMBOL_GREEDY_ONE_OR_MORE   ('+')

Definition at line 43 of file sqstdrex.cpp.

Referenced by sqstd_rex_element().

◆ SQREX_SYMBOL_GREEDY_ZERO_OR_MORE

#define SQREX_SYMBOL_GREEDY_ZERO_OR_MORE   ('*')

Definition at line 44 of file sqstdrex.cpp.

Referenced by sqstd_rex_element().

◆ SQREX_SYMBOL_GREEDY_ZERO_OR_ONE

#define SQREX_SYMBOL_GREEDY_ZERO_OR_ONE   ('?')

Definition at line 45 of file sqstdrex.cpp.

Referenced by sqstd_rex_element().

Typedef Documentation

◆ SQRexNode

typedef struct tagSQRexNode SQRexNode

◆ SQRexNodeType

typedef int SQRexNodeType

Definition at line 52 of file sqstdrex.cpp.

Function Documentation

◆ sqstd_rex_charclass()

static SQInteger sqstd_rex_charclass ( SQRex exp,
SQInteger  classid 
)
static

Definition at line 124 of file sqstdrex.cpp.

References SQRex::_nodes, tagSQRexNode::left, OP_CCLASS, and sqstd_rex_newnode().

Referenced by sqstd_rex_charnode().

◆ sqstd_rex_charnode()

static SQInteger sqstd_rex_charnode ( SQRex exp,
SQBool  isclass 
)
static

◆ sqstd_rex_class()

static SQInteger sqstd_rex_class ( SQRex exp)
static

◆ sqstd_rex_compile()

SQRex* sqstd_rex_compile ( const SQChar pattern,
const SQChar **  error 
)

◆ sqstd_rex_element()

static SQInteger sqstd_rex_element ( SQRex exp)
static

◆ sqstd_rex_error()

static void sqstd_rex_error ( SQRex exp,
const SQChar error 
)
static

◆ sqstd_rex_escapechar()

static SQChar sqstd_rex_escapechar ( SQRex exp)
static

Definition at line 108 of file sqstdrex.cpp.

References SQRex::_p, scisprint, SQREX_SYMBOL_ESCAPE_CHAR, and sqstd_rex_error().

Referenced by sqstd_rex_class().

◆ sqstd_rex_expect()

static void sqstd_rex_expect ( SQRex exp,
SQInteger  n 
)
static

Definition at line 102 of file sqstdrex.cpp.

References SQRex::_p, and sqstd_rex_error().

Referenced by sqstd_rex_element().

◆ sqstd_rex_free()

void sqstd_rex_free ( SQRex exp)

◆ sqstd_rex_getsubexp()

SQBool sqstd_rex_getsubexp ( SQRex exp,
SQInteger  n,
SQRexMatch *  subexp 
)

Definition at line 640 of file sqstdrex.cpp.

References SQRex::_matches, and SQRex::_nsubexpr.

Referenced by _regexp_capture().

◆ sqstd_rex_getsubexpcount()

SQInteger sqstd_rex_getsubexpcount ( SQRex exp)

Definition at line 635 of file sqstdrex.cpp.

References SQRex::_nsubexpr.

Referenced by _regexp_capture(), and _regexp_subexpcount().

◆ sqstd_rex_list()

static SQInteger sqstd_rex_list ( SQRex exp)
static

◆ sqstd_rex_match()

SQBool sqstd_rex_match ( SQRex exp,
const SQChar text 
)

Definition at line 588 of file sqstdrex.cpp.

References SQRex::_bol, SQRex::_currsubexp, SQRex::_eol, SQRex::_nodes, NULL, and sqstd_rex_matchnode().

Referenced by _regexp_match().

◆ sqstd_rex_matchcclass()

static SQBool sqstd_rex_matchcclass ( SQInteger  cclass,
SQChar  c 
)
static

Definition at line 342 of file sqstdrex.cpp.

Referenced by sqstd_rex_matchclass(), and sqstd_rex_matchnode().

◆ sqstd_rex_matchclass()

static SQBool sqstd_rex_matchclass ( SQRex exp,
SQRexNode node,
SQChar  c 
)
static

◆ sqstd_rex_matchnode()

static const SQChar* sqstd_rex_matchnode ( SQRex exp,
SQRexNode node,
const SQChar str,
SQRexNode next 
)
static

◆ sqstd_rex_newnode()

static SQInteger sqstd_rex_newnode ( SQRex exp,
SQRexNodeType  type 
)
static

◆ sqstd_rex_parsenumber()

static SQInteger sqstd_rex_parsenumber ( SQRex exp)
static

Definition at line 218 of file sqstdrex.cpp.

References SQRex::_p, and sqstd_rex_error().

Referenced by sqstd_rex_element().

◆ sqstd_rex_search()

SQBool sqstd_rex_search ( SQRex exp,
const SQChar text,
const SQChar **  out_begin,
const SQChar **  out_end 
)

Definition at line 630 of file sqstdrex.cpp.

References sqstd_rex_searchrange().

Referenced by _regexp_capture(), and _regexp_search().

◆ sqstd_rex_searchrange()

SQBool sqstd_rex_searchrange ( SQRex exp,
const SQChar text_begin,
const SQChar text_end,
const SQChar **  out_begin,
const SQChar **  out_end 
)