Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
regexp_nfa.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <limits.h>
#include "nvim/ascii.h"
#include "nvim/garray.h"

Data Structures

union  Ptrlist
 
struct  Frag
 
struct  regsub_T
 
struct  regsubs_T
 
struct  nfa_pim_S
 
struct  nfa_thread_T
 
struct  nfa_list_T
 

Macros

#define NFA_ADD_NL   31
 
#define EMIT(c)
 
#define CLASS_not   0x80
 
#define CLASS_af   0x40
 
#define CLASS_AF   0x20
 
#define CLASS_az   0x10
 
#define CLASS_AZ   0x08
 
#define CLASS_o7   0x04
 
#define CLASS_o9   0x02
 
#define CLASS_underscore   0x01
 
#define EMIT2(c)   EMIT(c); EMIT(NFA_CONCAT);
 
#define EMITMBC(c)   EMIT(c); EMIT(NFA_CONCAT);
 
#define A_grave   0xc0
 
#define A_acute   0xc1
 
#define A_circumflex   0xc2
 
#define A_virguilla   0xc3
 
#define A_diaeresis   0xc4
 
#define A_ring   0xc5
 
#define C_cedilla   0xc7
 
#define E_grave   0xc8
 
#define E_acute   0xc9
 
#define E_circumflex   0xca
 
#define E_diaeresis   0xcb
 
#define I_grave   0xcc
 
#define I_acute   0xcd
 
#define I_circumflex   0xce
 
#define I_diaeresis   0xcf
 
#define N_virguilla   0xd1
 
#define O_grave   0xd2
 
#define O_acute   0xd3
 
#define O_circumflex   0xd4
 
#define O_virguilla   0xd5
 
#define O_diaeresis   0xd6
 
#define O_slash   0xd8
 
#define U_grave   0xd9
 
#define U_acute   0xda
 
#define U_circumflex   0xdb
 
#define U_diaeresis   0xdc
 
#define Y_acute   0xdd
 
#define a_grave   0xe0
 
#define a_acute   0xe1
 
#define a_circumflex   0xe2
 
#define a_virguilla   0xe3
 
#define a_diaeresis   0xe4
 
#define a_ring   0xe5
 
#define c_cedilla   0xe7
 
#define e_grave   0xe8
 
#define e_acute   0xe9
 
#define e_circumflex   0xea
 
#define e_diaeresis   0xeb
 
#define i_grave   0xec
 
#define i_acute   0xed
 
#define i_circumflex   0xee
 
#define i_diaeresis   0xef
 
#define n_virguilla   0xf1
 
#define o_grave   0xf2
 
#define o_acute   0xf3
 
#define o_circumflex   0xf4
 
#define o_virguilla   0xf5
 
#define o_diaeresis   0xf6
 
#define o_slash   0xf8
 
#define u_grave   0xf9
 
#define u_acute   0xfa
 
#define u_circumflex   0xfb
 
#define u_diaeresis   0xfc
 
#define y_acute   0xfd
 
#define y_diaeresis   0xff
 
#define PUSH(s)   st_push((s), &stackp, stack_end)
 
#define POP()
 
#define NFA_PIM_UNUSED   0 /* pim not used */
 
#define NFA_PIM_TODO   1 /* pim not done yet */
 
#define NFA_PIM_MATCH   2 /* pim executed, matches */
 
#define NFA_PIM_NOMATCH   3 /* pim executed, no match */
 
#define ADDSTATE_HERE_OFFSET   10
 
#define PTR2LEN(x)   utf_ptr2len(x)
 
#define ADD_STATE_IF_MATCH(state)
 

Typedefs

typedef union Ptrlist Ptrlist
 
typedef struct Frag Frag_T
 
typedef struct nfa_pim_S nfa_pim_T
 

Enumerations

enum  {
  NFA_SPLIT = -1024, NFA_MATCH, NFA_EMPTY, NFA_START_COLL,
  NFA_END_COLL, NFA_START_NEG_COLL, NFA_END_NEG_COLL, NFA_RANGE,
  NFA_RANGE_MIN, NFA_RANGE_MAX, NFA_CONCAT, NFA_OR,
  NFA_STAR, NFA_STAR_NONGREEDY, NFA_QUEST, NFA_QUEST_NONGREEDY,
  NFA_BOL, NFA_EOL, NFA_BOW, NFA_EOW,
  NFA_BOF, NFA_EOF, NFA_NEWL, NFA_ZSTART,
  NFA_ZEND, NFA_NOPEN, NFA_NCLOSE, NFA_START_INVISIBLE,
  NFA_START_INVISIBLE_FIRST, NFA_START_INVISIBLE_NEG, NFA_START_INVISIBLE_NEG_FIRST, NFA_START_INVISIBLE_BEFORE,
  NFA_START_INVISIBLE_BEFORE_FIRST, NFA_START_INVISIBLE_BEFORE_NEG, NFA_START_INVISIBLE_BEFORE_NEG_FIRST, NFA_START_PATTERN,
  NFA_END_INVISIBLE, NFA_END_INVISIBLE_NEG, NFA_END_PATTERN, NFA_COMPOSING,
  NFA_END_COMPOSING, NFA_ANY_COMPOSING, NFA_OPT_CHARS, NFA_PREV_ATOM_NO_WIDTH,
  NFA_PREV_ATOM_NO_WIDTH_NEG, NFA_PREV_ATOM_JUST_BEFORE, NFA_PREV_ATOM_JUST_BEFORE_NEG, NFA_PREV_ATOM_LIKE_PATTERN,
  NFA_BACKREF1, NFA_BACKREF2, NFA_BACKREF3, NFA_BACKREF4,
  NFA_BACKREF5, NFA_BACKREF6, NFA_BACKREF7, NFA_BACKREF8,
  NFA_BACKREF9, NFA_ZREF1, NFA_ZREF2, NFA_ZREF3,
  NFA_ZREF4, NFA_ZREF5, NFA_ZREF6, NFA_ZREF7,
  NFA_ZREF8, NFA_ZREF9, NFA_SKIP, NFA_MOPEN,
  NFA_MOPEN1, NFA_MOPEN2, NFA_MOPEN3, NFA_MOPEN4,
  NFA_MOPEN5, NFA_MOPEN6, NFA_MOPEN7, NFA_MOPEN8,
  NFA_MOPEN9, NFA_MCLOSE, NFA_MCLOSE1, NFA_MCLOSE2,
  NFA_MCLOSE3, NFA_MCLOSE4, NFA_MCLOSE5, NFA_MCLOSE6,
  NFA_MCLOSE7, NFA_MCLOSE8, NFA_MCLOSE9, NFA_ZOPEN,
  NFA_ZOPEN1, NFA_ZOPEN2, NFA_ZOPEN3, NFA_ZOPEN4,
  NFA_ZOPEN5, NFA_ZOPEN6, NFA_ZOPEN7, NFA_ZOPEN8,
  NFA_ZOPEN9, NFA_ZCLOSE, NFA_ZCLOSE1, NFA_ZCLOSE2,
  NFA_ZCLOSE3, NFA_ZCLOSE4, NFA_ZCLOSE5, NFA_ZCLOSE6,
  NFA_ZCLOSE7, NFA_ZCLOSE8, NFA_ZCLOSE9, NFA_ANY,
  NFA_IDENT, NFA_SIDENT, NFA_KWORD, NFA_SKWORD,
  NFA_FNAME, NFA_SFNAME, NFA_PRINT, NFA_SPRINT,
  NFA_WHITE, NFA_NWHITE, NFA_DIGIT, NFA_NDIGIT,
  NFA_HEX, NFA_NHEX, NFA_OCTAL, NFA_NOCTAL,
  NFA_WORD, NFA_NWORD, NFA_HEAD, NFA_NHEAD,
  NFA_ALPHA, NFA_NALPHA, NFA_LOWER, NFA_NLOWER,
  NFA_UPPER, NFA_NUPPER, NFA_LOWER_IC, NFA_NLOWER_IC,
  NFA_UPPER_IC, NFA_NUPPER_IC, NFA_FIRST_NL = NFA_ANY + NFA_ADD_NL, NFA_LAST_NL = NFA_NUPPER_IC + NFA_ADD_NL,
  NFA_CURSOR, NFA_LNUM, NFA_LNUM_GT, NFA_LNUM_LT,
  NFA_COL, NFA_COL_GT, NFA_COL_LT, NFA_VCOL,
  NFA_VCOL_GT, NFA_VCOL_LT, NFA_MARK, NFA_MARK_GT,
  NFA_MARK_LT, NFA_VISUAL, NFA_CLASS_ALNUM, NFA_CLASS_ALPHA,
  NFA_CLASS_BLANK, NFA_CLASS_CNTRL, NFA_CLASS_DIGIT, NFA_CLASS_GRAPH,
  NFA_CLASS_LOWER, NFA_CLASS_PRINT, NFA_CLASS_PUNCT, NFA_CLASS_SPACE,
  NFA_CLASS_UPPER, NFA_CLASS_XDIGIT, NFA_CLASS_TAB, NFA_CLASS_RETURN,
  NFA_CLASS_BACKSPACE, NFA_CLASS_ESCAPE
}
 

Functions

 if (++depth >=5000||subs==NULL)
 
 if (off_arg<=-ADDSTATE_HERE_OFFSET)
 
 switch (state->c)
 
 if (r==NULL)
 
 if (listidx+1==tlen)
 
 if (count==0)
 
else if (count > 1)
 

Variables

static regsubs_T FUNC_ATTR_WARN_UNUSED_RESULT
 
int off = off_arg
 
int add_here = FALSE
 
int listindex = 0
 
int k
 
int found = FALSE
 
nfa_thread_Tthread
 
struct multipos save_multipos
 
int save_in_use
 
char_usave_ptr
 
int i
 
regsub_Tsub
 
regsubs_Tsubs = subs_arg
 
int count = l->n - tlen
 
int listidx = *ip
 
regsubs_Tr = addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET)
 
l n
 
ip = listidx - 1
 

Macro Definition Documentation

#define A_acute   0xc1
#define a_acute   0xe1
#define A_circumflex   0xc2
#define a_circumflex   0xe2
#define A_diaeresis   0xc4
#define a_diaeresis   0xe4
#define A_grave   0xc0
#define a_grave   0xe0
#define A_ring   0xc5
#define a_ring   0xe5
#define A_virguilla   0xc3
#define a_virguilla   0xe3
#define ADD_STATE_IF_MATCH (   state)
Value:
if (result) { \
add_state = state->out; \
add_off = clen; \
}
#define ADDSTATE_HERE_OFFSET   10
#define C_cedilla   0xc7
#define c_cedilla   0xe7
#define CLASS_af   0x40
#define CLASS_AF   0x20
#define CLASS_az   0x10
#define CLASS_AZ   0x08
#define CLASS_not   0x80
#define CLASS_o7   0x04
#define CLASS_o9   0x02
#define CLASS_underscore   0x01
#define E_acute   0xc9
#define e_acute   0xe9
#define E_circumflex   0xca
#define e_circumflex   0xea
#define E_diaeresis   0xcb
#define e_diaeresis   0xeb
#define E_grave   0xc8
#define e_grave   0xe8
#define EMIT (   c)
Value:
do { \
if (post_ptr >= post_end) { \
realloc_post_list(); \
} \
*post_ptr++ = c; \
} while (0)
if(++depth >=5000||subs==NULL)
Definition: regexp_nfa.c:3963
#define EMIT2 (   c)    EMIT(c); EMIT(NFA_CONCAT);
#define EMITMBC (   c)    EMIT(c); EMIT(NFA_CONCAT);
#define I_acute   0xcd
#define i_acute   0xed
#define I_circumflex   0xce
#define i_circumflex   0xee
#define I_diaeresis   0xcf
#define i_diaeresis   0xef
#define I_grave   0xcc
#define i_grave   0xec
#define N_virguilla   0xd1
#define n_virguilla   0xf1
#define NFA_ADD_NL   31
#define NFA_PIM_MATCH   2 /* pim executed, matches */
#define NFA_PIM_NOMATCH   3 /* pim executed, no match */
#define NFA_PIM_TODO   1 /* pim not done yet */
#define NFA_PIM_UNUSED   0 /* pim not used */
#define O_acute   0xd3
#define o_acute   0xf3
#define O_circumflex   0xd4
#define o_circumflex   0xf4
#define O_diaeresis   0xd6
#define o_diaeresis   0xf6
#define O_grave   0xd2
#define o_grave   0xf2
#define O_slash   0xd8
#define o_slash   0xf8
#define O_virguilla   0xd5
#define o_virguilla   0xf5
#define POP ( )
Value:
st_pop(&stackp, stack); \
if (stackp < stack) { \
st_error(postfix, end, p); \
xfree(stack); \
}
xfree(tofree)
return NULL
Definition: eval.c:23776
return
Definition: eval.c:15725
if(++depth >=5000||subs==NULL)
Definition: regexp_nfa.c:3963
char_u * p
Definition: eval.c:2249
#define PTR2LEN (   x)    utf_ptr2len(x)
#define PUSH (   s)    st_push((s), &stackp, stack_end)
#define U_acute   0xda
#define u_acute   0xfa
#define U_circumflex   0xdb
#define u_circumflex   0xfb
#define U_diaeresis   0xdc
#define u_diaeresis   0xfc
#define U_grave   0xd9
#define u_grave   0xf9
#define Y_acute   0xdd
#define y_acute   0xfd
#define y_diaeresis   0xff

Typedef Documentation

typedef struct Frag Frag_T
typedef struct nfa_pim_S nfa_pim_T
typedef union Ptrlist Ptrlist

Enumeration Type Documentation

anonymous enum
Enumerator
NFA_SPLIT 
NFA_MATCH 
NFA_EMPTY 
NFA_START_COLL 
NFA_END_COLL 
NFA_START_NEG_COLL 
NFA_END_NEG_COLL 
NFA_RANGE 
NFA_RANGE_MIN 
NFA_RANGE_MAX 
NFA_CONCAT 
NFA_OR 
NFA_STAR 
NFA_STAR_NONGREEDY 
NFA_QUEST 
NFA_QUEST_NONGREEDY 
NFA_BOL 
NFA_EOL 
NFA_BOW 
NFA_EOW 
NFA_BOF 
NFA_EOF 
NFA_NEWL 
NFA_ZSTART 
NFA_ZEND 
NFA_NOPEN 
NFA_NCLOSE 
NFA_START_INVISIBLE 
NFA_START_INVISIBLE_FIRST 
NFA_START_INVISIBLE_NEG 
NFA_START_INVISIBLE_NEG_FIRST 
NFA_START_INVISIBLE_BEFORE 
NFA_START_INVISIBLE_BEFORE_FIRST 
NFA_START_INVISIBLE_BEFORE_NEG 
NFA_START_INVISIBLE_BEFORE_NEG_FIRST 
NFA_START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A_FNAME 
NFA_SFNAME 
NFA_PRINT 
NFA_SPRINT 
NFA_WHITE 
NFA_NWHITE 
NFA_DIGIT 
NFA_NDIGIT 
NFA_HEX 
NFA_NHEX 
NFA_OCTAL 
NFA_NOCTAL 
NFA_WORD 
NFA_NWORD 
NFA_HEAD 
NFA_NHEAD 
NFA_ALPHA 
NFA_NALPHA 
NFA_LOWER 
NFA_NLOWER 
NFA_UPPER 
NFA_NUPPER 
NFA_LOWER_IC 
NFA_NLOWER_IC 
NFA_UPPER_IC 
NFA_NUPPER_IC 
NFA_FIRST_NL 
NFA_LAST_NL 
NFA_CURSOR 
NFA_LNUM 
NFA_LNUM_GT 
NFA_LNUM_LT 
NFA_COL 
NFA_COL_GT 
NFA_COL_LT 
NFA_VCOL 
NFA_VCOL_GT 
NFA_VCOL_LT 
NFA_MARK 
NFA_MARK_GT 
NFA_MARK_LT 
NFA_VISUAL 
NFA_CLASS_ALNUM 
NFA_CLASS_ALPHA 
NFA_CLASS_BLANK 
NFA_CLASS_CNTRL 
NFA_CLASS_DIGIT 
NFA_CLASS_GRAPH 
NFA_CLASS_LOWER 
NFA_CLASS_PRINT 
NFA_CLASS_PUNCT 
NFA_CLASS_SPACE 
NFA_CLASS_UPPER 
NFA_CLASS_XDIGIT 
NFA_CLASS_TAB 
NFA_CLASS_RETURN 
NFA_CLASS_BACKSPACE 
NFA_CLASS_ESCAPE 

Function Documentation

if ( ++depth >=5000||  subs = NULL)
if ( off_arg<=-  ADDSTATE_HERE_OFFSET)
if ( r  = NULL)
if ( listidx 1 = = tlen)
if ( count  = = 0)
else if ( count  ,
 
)
switch ( state->  c)

Variable Documentation

int add_here = FALSE
count = l->n - tlen
int found = FALSE
regsubs_T FUNC_ATTR_WARN_UNUSED_RESULT
Initial value:
{
int subidx
int i
* ip = listidx - 1
int k
int listidx = *ip
int listindex = 0
l n
int off = off_arg
return r = addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET)
int save_in_use
struct multipos save_multipos
char_u* save_ptr
regsub_T* sub
return subs = subs_arg
nfa_thread_T* thread