summaryrefslogtreecommitdiffstats
path: root/lib/libaccess/avascan.l
blob: ceae1426a7170b2c1aca09b822e6f07759d3a20b (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/** BEGIN COPYRIGHT BLOCK
 * Copyright 2001 Sun Microsystems, Inc.
 * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
%{
 
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include "y.tab.h"
#include "libaccess/ava.h"
#include "netsite.h"
 
int linenum = 1;
int first_time = 1;
int old_state;
int num_nested_comments = 0;

extern AVAEntry tempEntry;   
extern AVATable entryTable;  
                             
void strip_quotes(void);
 
%}
 
%s  COMMENT NORM DEFINES DEF_TYPE 
 
uc_letter                           [A-Z]                               
lc_letter                           [a-z]
digit                               [0-9]
under_score                         _

letter                              ([A-Z,a-z])

white_space                         ([ \t]*)
identifier                          ([_,A-Z,a-z][_,A-Z,a-z,0-9]*)
def_identifier                      (({white_space}{identifier})+)
text                                (\"[^\"]*\")
comments                            (([^"*/"\n])*)



%%

%{
   if (first_time) {
      BEGIN NORM;
      first_time = tempEntry.numOrgs = 0;
      old_state = NORM;
      tempEntry.userid = 0;
      tempEntry.country = 0;
      tempEntry.CNEntry = 0;
      tempEntry.email = 0;
      tempEntry.locality = 0;
      tempEntry.state = 0;
      entryTable.numEntries = 0;
   }
%}


"/*"                  {BEGIN COMMENT; num_nested_comments++;}
<COMMENT>"*/"         {num_nested_comments--; 
                       if (!num_nested_comments) BEGIN old_state;}
<COMMENT>.   {;}

<NORM>{identifier}  {yylval.string = PERM_STRDUP(yytext);
			 return USER_ID;}
<NORM>":"{white_space}\{ {BEGIN DEF_TYPE;
                          old_state = DEF_TYPE;}

<DEF_TYPE>"C"               {BEGIN DEFINES; old_state = DEFINES;
                             return DEF_C; }
<DEF_TYPE>"O"               {BEGIN DEFINES; old_state = DEFINES;
                             return DEF_CO;}
<DEF_TYPE>"OU"              {BEGIN DEFINES; old_state = DEFINES;
                             return DEF_OU;}
<DEF_TYPE>"CN"              {BEGIN DEFINES; old_state = DEFINES;
                             return DEF_CN;}
<DEF_TYPE>"L"               {BEGIN DEFINES; old_state = DEFINES;
                             return DEF_L;}
<DEF_TYPE>"E"               {BEGIN DEFINES; old_state = DEFINES;
                             return DEF_E;}
<DEF_TYPE>"ST"              {BEGIN DEFINES; old_state = DEFINES;
                             return DEF_ST;}
<DEF_TYPE>"}"               {BEGIN NORM;old_state = NORM;}

<DEFINES>=                     {return EQ_SIGN;}
<DEFINES>{text}  {BEGIN DEF_TYPE; old_state = DEF_TYPE;
                                strip_quotes();
                                return DEF_ID;}

{white_space}   {;}
\n              {linenum++;}
.               {yyerror("Bad input character");} 
%%

int yywrap () {
 return 1;
}

void strip_quotes(void) {
  yytext[strlen(yytext)-1]= '\0';
  yylval.string = PERM_STRDUP(&yytext[1]);
}