Exemple #1
0
static int lp_argcapture (lua_State *L) {
  int n = (int)luaL_checkinteger(L, 1);
  TTree *tree = newemptycap(L, Carg);
  tree->key = n;
  luaL_argcheck(L, 0 < n && n <= SHRT_MAX, 1, "invalid argument index");
  return 1;
}
Exemple #2
0
/*
** Constant capture
*/
static int lp_constcapture (lua_State *L) {
  int i;
  int n = lua_gettop(L);  /* number of values */
  if (n == 0)  /* no values? */
    newleaf(L, TTrue);  /* no capture */
  else if (n == 1)
    newemptycap(L, Cconst, 1);  /* single constant capture */
  else {  /* create a group capture with all values */
    TTree *tree = newtree(L, 1 + 3 * (n - 1) + 2);
    tree->tag = TCapture;
    tree->cap = Cgroup;
    tree->key = 0;
    tree = sib1(tree);
    for (i = 1; i <= n - 1; i++) {
      tree->tag = TSeq;
      tree->u.ps = 3;  /* skip TCapture and its sibling */
      auxemptycap(L, sib1(tree), Cconst, i);
      tree = sib2(tree);
    }
    auxemptycap(L, tree, Cconst, i);
  }
  return 1;
}
Exemple #3
0
static int lp_poscapture (lua_State *L) {
  newemptycap(L, Cposition);
  return 1;
}
Exemple #4
0
static int lp_backref (lua_State *L) {
  luaL_checkstring(L, 1);
  newemptycap(L, Cbackref, 1);
  return 1;
}