File: filterh.l

package info (click to toggle)
libzdb 3.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,524 kB
  • sloc: javascript: 7,158; ansic: 6,331; sh: 3,854; cpp: 580; makefile: 114; xml: 59; lex: 35
file content (40 lines) | stat: -rw-r--r-- 687 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (C) Tildeslash. All rights reserved.
 * Use is subject to license terms.
 */

%option noyywrap
%{
  /*
   * Use for filtering text from a C-header file. Filter text between
   * //<< and //>> or from //<< and to eof. '#' may be used instead of 
   * '//' if applicable.
   * 
   * Usage: filterh < file > filtered-file
   */
#include <stdio.h>
#include <string.h>
%}

%x CPP BPP

%%

"//<<"	        	{ BEGIN(CPP); }
"#<<"	        	{ BEGIN(BPP); }

<CPP>{
	"//>>".*"\n"    { BEGIN(INITIAL); }
	[\000-\377]     ;
}

<BPP>{
	"#>>".*"\n"     { BEGIN(INITIAL); }
	[\000-\377]     ;
}

<INITIAL>.      	{ fprintf(yyout, "%s", yytext); }

%%

int main(void) { return yylex(); }