source: src/sen.l @ 93afab8

Last change on this file since 93afab8 was 1e551bd, checked in by Mateusz Hromada <ruanda@…>, 15 years ago

Migration to new build system.

  • sen moved and checked
  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[1e551bd]1%{
2
3  void print_EOS(void);
4  void set_position(void);
5
6  int pos=0;
7  int len=0;
8
9%}
10
11ul      [A-Z¡ÆÊ£ÑÓŠ¯¬]
12ll                [a-z±æê³ñ󶿌]
13l       ul|ll
14n       [0-9]+
15s       [ \t]+
16
17
18ab1     (mgr|in¿|prof|hab|doc|dyr|kier|zast)
19ab2     (ul|pl|al)
20
21abrv    (ab1|ab2)
22
23SEG     .*\n
24N       {n}{s}{n}{s}N{s}.*\n
25S       {n}{s}{n}{s}S{s}.*\n
26P       {n}{s}{n}{s}P{s}.*\n
27W       {n}{s}{n}{s}W{s}.*\n
28UL      {n}{s}{n}{s}W{s}{ul}.*\n
29Cap     {n}{s}{n}{s}W{s}{ul}{ll}*.*\n
30POINT   {n}{s}{n}{s}P{s}\.({s}.*)?\n
31QMARK   {n}{s}{n}{s}P{s}\?({s}.*)?\n
32EXCL    {n}{s}{n}{s}P{s}\!({s}.*)?\n
33DASH    {n}{s}{n}{s}P{s}\-({s}.*)?\n
34POINTS  {POINT}+
35
36ABRV    {n}{s}{n}{s}W{s}{abrv}({s}.*)?\n
37
38EOS     {POINT}|{POINTS}|{QMARK}|{EXCL}
39
40
41%%
42
43
44{N}({POINT}{N})+          { ECHO; set_position(); }
45({UL}{POINT}{S}?)+{Cap}   { ECHO; set_position(); }
46{ABRV}{POINT}             { ECHO; set_position(); }
47
48
49{P}/{S}{DASH}             { ECHO; set_position(); print_EOS(); }
50{EOS}/{S}({Cap}|{P}|{N})  { ECHO; set_position(); print_EOS(); }
51
52.*                        { ECHO; set_position(); }
53
54<<EOF>>                   { printf("%04d 00 EOS *\n",pos+len); exit(1); }
55
56%%
57
58int main()
59{
60  printf("0000 00 BOS *\n");
61  yylex();
62  return 0;
63}
64
65int yywrap()
66{
67  return 1;
68}
69
70void set_position()
71{
72  char *lastseg;
73  char *tmp;
74
75  yytext[yyleng-1] = '\0';
76
77  tmp = strrchr(yytext, '\n');
78  if( tmp )
79  {
80    lastseg = tmp + 1;
81  }
82  else
83  {
84    lastseg = yytext;
85  }
86
87  sscanf(lastseg, "%d %d", &pos, &len);
88  yytext[yyleng-1] = '\n';
89
90}
91
92void print_EOS()
93{
94  printf("%04d 00 EOS *\n%04d 00 BOS *\n", pos+len, pos+len);
95}
Note: See TracBrowser for help on using the repository browser.