Skip to content

Commit

Permalink
operator: introduce _markplaceholder
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed May 16, 2021
1 parent 8c8223f commit d0d07af
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Units/optscript.r/op-markplaceholder.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--sort=no
--langdef=UnknownX
--map-UnknownX=.unknown

--kinddef-UnknownX=d,def,definitions

--regex-UnknownX=/([ \t]*)def +([a-zA-Z]):/\2/d/{{
\1 length 5 gt {
. _markplaceholder
} if
}}
4 changes: 4 additions & 0 deletions Units/optscript.r/op-markplaceholder.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a input.unknown /^def a:$/;" d
b input.unknown /^ def b:$/;" d
A input.unknown /^def A:$/;" d
B input.unknown /^ def B:$/;" d
6 changes: 6 additions & 0 deletions Units/optscript.r/op-markplaceholder.d/input.unknown
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def a:
def b:
def c:
def A:
def B:
def C:
27 changes: 27 additions & 0 deletions main/lregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -3732,6 +3732,27 @@ static EsObject *lrop_advanceto (OptVM *vm, EsObject *name)
return es_true;
}

static EsObject *lrop_markplaceholder (OptVM *vm, EsObject *name)
{
EsObject *tag = opt_vm_ostack_top (vm);

if (!es_integer_p (tag))
return OPT_ERR_TYPECHECK;

int n = es_integer_get (tag);
if (! (CORK_NIL < n && n < countEntryInCorkQueue()))
return OPT_ERR_RANGECHECK;

tagEntryInfo *e = getEntryInCorkQueue (n);
if (e == NULL)
return OPTSCRIPT_ERR_NOTAGENTRY;

markTagPlaceholder (e, true);

opt_vm_ostack_pop (vm);
return es_false;
}

static struct optscriptOperatorRegistration lropOperators [] = {
{
.name = "_matchstr",
Expand Down Expand Up @@ -3872,6 +3893,12 @@ static struct optscriptOperatorRegistration lropOperators [] = {
.arity = 0,
.help_str = "- _TRACED true|false",
},
{
.name = "_markplaceholder",
.fn = lrop_markplaceholder,
.arity = 1,
.help_str = "tag:int _MARKPLACEHOLDER -",
}
};

extern void initRegexOptscript (void)
Expand Down

0 comments on commit d0d07af

Please sign in to comment.