source: src/sen/sen.l @ acbabee

Last change on this file since acbabee was acbabee, checked in by Tomasz Obrebski <obrebski@…>, 9 years ago

many changes, mainly dgp1 algorithm

  • Property mode set to 100644
File size: 1.6 KB
Line 
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)
20ab3     (str|ryc|rys)
21ab4     (np|tzw)
22
23abrv    ({ab1}|{ab2}|{ab3})
24
25SEG     .*\n
26N       {n}{s}{n}{s}N{s}.*\n
27S       {n}{s}{n}{s}S{s}.*\n
28P       {n}{s}{n}{s}P{s}.*\n
29W       {n}{s}{n}{s}W{s}.*\n
30UL      {n}{s}{n}{s}W{s}{ul}.*\n
31Cap     {n}{s}{n}{s}W{s}{ul}{ll}*.*\n
32POINT   {n}{s}{n}{s}P{s}\.({s}.*)?\n
33QMARK   {n}{s}{n}{s}P{s}\?({s}.*)?\n
34EXCL    {n}{s}{n}{s}P{s}\!({s}.*)?\n
35DASH    {n}{s}{n}{s}P{s}\-({s}.*)?\n
36POINTS  {POINT}+
37
38ABRV    {n}{s}{n}{s}W{s}{abrv}({s}.*)?\n
39
40EOS     {POINT}|{POINTS}|{QMARK}|{EXCL}
41
42
43%%
44
45
46{N}({POINT}{N})+          { ECHO; set_position(); }
47({UL}{POINT}{S}?)+{Cap}   { ECHO; set_position(); }
48{ABRV}{POINT}             { ECHO; set_position(); }
49
50
51{P}/{S}{DASH}             { ECHO; set_position(); print_EOS(); }
52{EOS}/{S}({Cap}|{P}|{N})  { ECHO; set_position(); print_EOS(); }
53
54.*                        { ECHO; set_position(); }
55
56<<EOF>>                   { printf("%04d 00 EOS *\n",pos+len); exit(0); }
57
58%%
59
60int main()
61{
62  printf("0000 00 BOS *\n");
63  yylex();
64  return 0;
65}
66
67int yywrap()
68{
69  return 1;
70}
71
72void set_position()
73{
74  char *lastseg;
75  char *tmp;
76
77  yytext[yyleng-1] = '\0';
78
79  tmp = strrchr(yytext, '\n');
80  if( tmp )
81  {
82    lastseg = tmp + 1;
83  }
84  else
85  {
86    lastseg = yytext;
87  }
88
89  sscanf(lastseg, "%d %d", &pos, &len);
90  yytext[yyleng-1] = '\n';
91
92}
93
94void print_EOS()
95{
96  printf("%04d 00 EOS *\n%04d 00 BOS *\n", pos+len, pos+len);
97}
Note: See TracBrowser for help on using the repository browser.