File: count.l

package info (click to toggle)
ircii 20051015-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,996 kB
  • ctags: 3,193
  • sloc: ansic: 44,257; makefile: 1,144; sh: 522; perl: 127; lex: 26
file content (28 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (3)
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
/*	$eterna: count.l,v 1.4 2001/08/12 16:24:51 mrg Exp $	*/

%{
#include <string.h>
int n = 0;
%}
%%
"#define"(\40|\t)+[A-Z0-9_]+(\40|\t)+"$\n" {
  yytext[yyleng - 2] = '\0';
  printf("%s%d\n", yytext, n);
  n++;
}
" * ".*\$.*\$"\n" {
  char *s = malloc(yyleng + 1), *t;
  strncpy(s, yytext, yyleng - 1);
  s[yyleng - 2] = '\n';
  s[yyleng - 1] = '\0';
  t = (char *)index(s, (int)'$');
  *t = ' ';
  printf(" * NOTE: This file is automatically created!\n *\n * from: %s%s", s + 3, yytext);
}
.*"\n" printf("%s", yytext);
%%
main()
{
  yylex();
  exit(0);
}