summaryrefslogtreecommitdiff
path: root/ace/Svc_Conf.l
blob: f3098c048bccd7c416544726fcf9fcf224ae48c7 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
%{
// $Id$
// Sample lexical analysis for regular expression subset.  Must be
// compiled with FLEX and an ANSI C++ compiler.

// Lexical tokens values defined by YACC.
#include "ace/Svc_Conf.h"
#include "ace/Svc_Conf_Tokens.h"

ACE_RCSID (ace,
	   Svc_Conf_l,
	   "$Id$")

// Keeps track of the current line for debugging output.
int yylineno = 1;

// Array that implements the underlying lexer buffer stack.
YY_BUFFER_STATE yybuffer_stack[ACE_SERVICE_DIRECTIVE_STACK_DEPTH];

// Array index of the buffer currently in use.
int yy_stack_index = 0;

#define token(x)  x
%}

%s PARAMETERS
%s NORMAL

letter	        [a-zA-Z_]
letter_or_digit	[a-zA-Z_0-9]
digit           [0-9]
ident           {letter}{letter_or_digit}*
pathname        ([A-Za-z\%]:)?[a-zA-Z_0-9/\%\.\\~-]+
symbol		[ -~]
string		(\"{symbol}*\"|\'{symbol}*\')
white_space	[ \t]
newline         \n
other		.

%%

^#{other}*$   	      ; /* EMPTY */
dynamic	              { return token (ACE_DYNAMIC); }
static	              { return token (ACE_STATIC); }
suspend	              { return token (ACE_SUSPEND); }
resume	              { return token (ACE_RESUME); }
remove	              { return token (ACE_REMOVE); }
stream	              { return token (ACE_USTREAM); }
Module		      { return token (ACE_MODULE_T); }
Service_Object	      { return token (ACE_SVC_OBJ_T); }
STREAM		      { return token (ACE_STREAM_T); }
active	              { return token (ACE_ACTIVE); }
inactive	      { return token (ACE_INACTIVE); }
":"		      { return token (ACE_COLON); }
"*"		      { return token (ACE_STAR); }
"("                   { return token (ACE_LPAREN); }
")"                   { return token (ACE_RPAREN); }
"{"                   { return token (ACE_LBRACE); }
"}"                   { return token (ACE_RBRACE); }
{string}	      { // Check for first type of string, i.e.,
                        // "double quotes" delimited.  
                        char *s = strrchr (yytext, '"');
                        if (s == 0)
                          // Check for second type of string, i.e.,
                          // 'single quotes' delimited.
                          s = strrchr (yytext, '\'');

                        ACE_ASSERT (s != 0);
                        // Eliminate the opening and closing double or
                        // single quotes.
                        *s = '\0';
			yyleng -= 1;
                        yylval->ident_ = ace_obstack->copy (yytext + 1, yyleng);
			return token (ACE_STRING); }
{ident}		      {
		        yylval->ident_ = ace_obstack->copy (yytext, yyleng);
			return token (ACE_IDENT);
		      }
{pathname}	      {
		        yylval->ident_ = ace_obstack->copy (yytext, yyleng);
			return token (ACE_PATHNAME);
		      }
{white_space}+	      ; /* EMPTY */
{newline}	      { yylineno++; }
{other}		      { ACE_ERROR ((LM_ERROR,
                                ACE_LIB_TEXT ("unknown character = (%d"), 
                                          *yytext));
                        if (ACE_OS::ace_isprint (*yytext))
                          ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("|%c"), *yytext));
                        ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT (")\n")));
                      }
<<EOF>>               { yyterminate(); }
%%
int
yywrap (void)
{
  ::fflush (yyin);
  yytext[0] = '#';
  yyleng = 0;

  return 1;
}

void
yy_push_buffer (FILE *file)
{
  // External synchronization is required.

  if (yy_stack_index >= ACE_SERVICE_DIRECTIVE_STACK_DEPTH)
    {
      ACE_ERROR ((LM_ERROR,
                  "(%P|%t) Service Configurator directive nesting "
                  "is too deep.\n"
                  "(%P|%t) Consider increasing value of "
                  "ACE_SERVICE_DIRECTIVE_STACK_DEPTH.\n"));

      // Not much we can do, so resort to flushing the current buffer
      // and switch to the supplied stream.
      yyrestart (file);
    }
  else
    {
      yybuffer_stack[yy_stack_index++] = YY_CURRENT_BUFFER;
      yy_switch_to_buffer (yy_create_buffer (file, YY_BUF_SIZE));
    }
}

void
yy_push_buffer (const char *directive)
{
  // External synchronization is required.

  if (yy_stack_index >= ACE_SERVICE_DIRECTIVE_STACK_DEPTH)
    {
      ACE_ERROR ((LM_ERROR,
                  "(%P|%t) Service Configurator directive nesting "
                  "is too deep.\n"
                  "(%P|%t) Consider increasing value of "
                  "ACE_SERVICE_DIRECTIVE_STACK_DEPTH.\n"));

      // Not much we can do.
    }
  else
    {
      yybuffer_stack[yy_stack_index++] = YY_CURRENT_BUFFER;

      // yy_scan_string() already switches the buffer so setting
      // YY_CURRENT_BUFFER here is a bit redundant.  No biggy.
      YY_CURRENT_BUFFER = yy_scan_string (directive);
    }
}

void
yy_pop_buffer (void)
{
  // External synchronization is required.

  if (--yy_stack_index >= 0)
    {
      yy_delete_buffer (YY_CURRENT_BUFFER);
      yy_switch_to_buffer (yybuffer_stack[yy_stack_index]);
    }
}