File: lexer

package info (click to toggle)
filtermail 1.06.00-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,688 kB
  • sloc: cpp: 2,487; fortran: 249; makefile: 106; ansic: 51; sh: 36
file content (81 lines) | stat: -rw-r--r-- 2,028 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
%filenames scanner

%baseclass-preinclude   = "../uinput/uinput.h"

%input-interface        = "input.iface"
%input-inline           = "input.inline"
%input-implementation   = "empty"

//%print-tokens

ws          [ \t]+
ws0         [ \t]*
hdr         [[:upper:]-][[:alnum:]-]*[+:]?

name        \/[[:alnum:]._]+
filename    \.{name}+

nr          [0-9]+
date        ([0-9]{2}-){2}[0-9]{2}

%x          regex err

%%

if                      return Tokens::IF;
{hdr}                   return Tokens::HDR;
{filename}{ws}          return rulesFile();

accept                  return action(eAction::ACCEPT);
ignore                  return action(eAction::IGNORE);
spam                    return action(eAction::SPAM);

{nr}/[^-]               return setIdx(Tokens::NR);
{date}                  return setIdx(Tokens::DATE);

{ws}                    // ignore blanks
                        
^{ws0}$                 // |
^{ws0}#.*               // d_comment.add(matched());

^{ws0}#={ws0}\n         incNextOffset();
                        
not                     return Tokens::NOT;
and                     return Tokens::AND;
                        
\n                      return nlOffset();


                                    // <cinps> handles the regexes
[cinps$]                return Tokens::LETTER;

\'                      toMs(StartCondition_::regex);

<regex>{
    \'                  return regex2INITIAL();

    .                   |
    "\\'"               more();

    \n                  return error2INITIAL();
}    

<err>.+                 {
                            toMs(StartCondition_::INITIAL);
                            return ' '; // blank as generic error token
                        }

<*>{
    .                   {       // anyting unexpected
                            redo(1);
                            toMs(StartCondition_::err); 
                        }

                            // back to the specs file at rules-files EOF
    <<EOF>>             return pushedStream();
}