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 a string (without quotes), a token type (when prefixed with a @ symbol), a regular expression (when preceded with a / symbol), or a pattern expression (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.

  • 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 can be used as a shorthand for m no. To avoid confusion with the undo command, unmark cannot be abbreviated.

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" )	# first form
	: w (.fnm == "cobra.h" )	# alternative, using 'with'
	: m no (.lnr > 100 )
	: w (.lnr <= 100)
	: m [
	: m ir ==

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, jump, list, next, display, pre, qualifiers, stretch, undo, unmark, with

Return to index
Manual
Tutorial
(Last Updated: 7 May 2017)