Cobra Interactive Query Language display pattern matches

NAME

display patterns

SYNTAX

	dp [Setname]
	dp [Setname] n
	dp [Setname] N M
	dp [Setname] n N M

DESCRIPTION

This command is intended to be used to display or summarize the results of a pe pattern expression command.

The command-name can optionally be followed by the name of a set of pattern matches that was created earlier (either directly through a pe command, or seperately with the pattern set command ps. In this case the patterns displayed are taken from the named set only. Use of the command with a setname imples that a pe command was used without setname, leaving the set of matched patterns in the unnamed default location where it will be overwritten with each new search. (Nammed pattern sets were added in Cobra version 6.5.)

Without arguments, the command displays the full source text of all matched patterns.
With a single positive integer argument n, only the n-th match is displayed.
With two positive integer arguments N and M, all matching patterns of between N and M lines (inclusive) long are printed.
Finally, with three positive integer arguments n, N and M, only the n-th match within the length range given is printed.

EXAMPLES

	$ cobra *.c	# Cobra source directory
	: # look for fct parameters used to index arrays without bounds checking
	: pe @type @ident ( .* x:@ident .* ) { ^:x* \( :x ^[> <] \)* ^:x* [ :x ] .* }
	2 patterns matched
	230 tokens marked
	: json
	[
	  { "type"      :       " ",
	    "message"   :       "lines 728..746",
	    "file"      :       "cobra_eval.c",
	    "line"      :       728,
	  },
	  { "type"      :       " ",
	    "message"   :       "lines 1317..1335",
	    "file"      :       "cobra_prog.c",
	    "line"      :       1317,
	  }
	]
	: dp 1			# print source for the first match (18 lines)
	cobra_eval.c:728..746
	bound var 'yyrule', line 732
	   728  static void
	   729  yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
	   730  {
	   731    unsigned long int yylno = yyrline[yyrule];
	>  732    int yynrhs = yyr2[yyrule];
	   733    int yyi;
	   734    YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
	   735               yyrule - 1, yylno);
	   736    /* The symbols being reduced.  */
	   737    for (yyi = 0; yyi < yynrhs; yyi++)
	   738      {
	   739        YYFPRINTF (stderr, "   $%d = ", yyi + 1);
	   740        yy_symbol_print (stderr,
	   741                         yystos[yyssp[yyi + 1 - yynrhs]],
	   742                         &(yyvsp[(yyi + 1) - (yynrhs)])
	   743                                                );
	   744        YYFPRINTF (stderr, "\n");
	   745      }
	   746  }
	: dp			# print source for all matches
	...
	: dp 1 18 18		# print only the first match of 10 lines long
	...			# produces the same output in this case
	: terse on		# switch to terse mode
	: dp			# print a terser summary of all matches
	cobra_eval.c:728..746
	bound var 'yyrule', line 732
	   728  static void
	   729  yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
	 ...
	   745      }
	   746  }
	cobra_prog.c:1317..1335
	bound var 'yyrule', line 1321
	  1317  static void
	  1318  yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
	 ...
	  1334      }
	  1335  }
	2 of 2 patterns printed
	: terse off		# turn off terse mode again
	: q			# quit
	$

SEE ALSO

pattern searches, pe pattern expressions, json, display, list, pre,

Return to index
Manual
Tutorial
(Last Updated: 30 January 2021)