Cobra Interactive Query Language mark

NAME

mark — mark tokens if they match one or two patterns

SYNTAX

	m[ark] [qualifier]* pattern [pattern2]
	pattern:   string | @string | /re | (expr)
	qualifier: ir | no | &

DESCRIPTION

If used without qualifiers, the mark command can only add additional marks, but not remove them. The qualifiers can be used to restrict an existing set of marks to a subset.

A pattern can be one of the following:

  • a string (without quotes) to match the token text precisely,
  • a token type (when prefixed with a @ symbol),
  • a regular expression (when preceded by a / symbol), or
  • a pattern expression (when enclosed in round braces).

A qualifier is one of the three terms ir, no, or &. Qualifiers can be escaped as \no, \&, or \ir if a literal match is intended, as can the / that would otherwise identify a regular expression, or a round brace ( that would otherwise indicate a pattern expression.

  • The qualifier ir restricts the effect of the mark command to tokens defined within the range associated with a marked token. If no range is defined for the token, the mark is removed.
  • The qualifier no inverts the effect of a mark command, by removing, rather than adding, marks from tokens that match the pattern(s) that follow.
  • The qualifier & adds a constraint to the earlier matches and it will only retain marks that match the additional pattern(s) provided.
This means that existing token markings can be removed in any of the following ways:
	m[ark] no   pattern [pattern2]
	m[ark] &    pattern [pattern2]
	m[ark] & ir pattern [pattern2]
The command unmark is a shorthand for m no. To avoid confusion with the undo command, unmark cannot be abbreviated.

Pattern expressions are general boolean clauses enclosed in round braces. For instance:

	m & (a <= b && (.lnr < 100 || .fnm == cobra_lib.c))
The following operators are recognized in expressions:
  • +, !, –, *, /, %
  • >, >=, <, <=, ==, !=
  • &&, ||
The operands of the expression can be of the following types:



    stringsin double quotes if they contain spaces or tabs
    regular expressionsprefixed with a /
    constantspositive or negative integer numbers
    predefined function size(n)returns the number of marks in set n
    token attributesas summarized in the following table


Token attributes can be one or more of the following:


    .lenthe length of the token name
    .seqthe sequence number of the token
    .markthe mark value (non-zero if selected or matched)
    .rangethe number of lines in the associated range, or 0 if none


    .curlythe level of nesting of curly braces
    .roundthe level of nesting of round braces
    .bracketthe level of nesting of square brackets


    .fctthe name of the function, or "global"
    .fnmthe filename
    .lnrthe line number in the file


EXAMPLES

	: m s ++	# mark statements s++ (note the operator is a separate token)
	: m @ident \(	# identifiers that are followed by a (
	: m else if	# else keywords that are followed by if
	: m /^[fg]oo	# names starting with either foo or goo
	: m \/foo	# tokens that match the string '/foo'
	: m no goo	# unmark tokens named goo
	: unmark goo	# same
	: m ir default	# default keywords inside ranges associated with marked tokens
	: m /.		# mark all tokens
	: r
	: m @key
	: m & (.fnm == "cobra.h") # restrict to the set of marks that match the expression
	: m no (.lnr > 100 )	  # remove marks that match the expression
	: m & (.fnm == /\.h$)
	: m [
	: m ir ==
	: >2
	: m while
	: n \(
	: >1
	: w (size(1) > size(2))

NOTES

The arguments to the mark command (and all others that take arguments) are separated by white space. This means that if you want a space to be part of the pattern to be matched you need an escape character, for example:
	: m /other\ prefix

SEE ALSO

back, contains, display, jump, list, next, patterns, pre, qualifiers, reset, stretch, undo, unmark,

Return to index
Manual
Tutorial
(Last Updated: 14 May 2019)