summaryrefslogtreecommitdiff
path: root/comm/OLD/ReqMgr.l
blob: bad288c07b1d5a186a097547f32496fead918d71 (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
%{
/*
 *	The Unix Channel
 *
 *	by Michel Beaudouin-Lafon
 *
 *	Copyright 1993
 *	Centre d'Etudes de la Navigation Aerienne (CENA)
 *
 *	Request management, by Stephane Chatty
 *
 *	$Id$
 *	$CurLog$
 */

#include <stdio.h>
#include <string.h>
#include "ccu/HashTable.h"
#include "ccu/String.h"
#include "ReqMgr.yacc.h"	// produced from the parser file with '-d' option of yacc

extern int tee (int);
#define RETURN(x) return (tee(x))

extern "C" {
	int atoi (const char *);
	void exit (int);
	int read (int, char*, int);
}


CcuDictionnary* ResWords;
int LineNo = 1;
static char IdBuf [1024];

void
LexInit ()
{
	if (!ResWords) {
		ResWords = new CcuDictionnary (10);
		(*ResWords)["client"] = (void*) (Y_CLIENT);
		(*ResWords)["request"] = (void*) (Y_REQUEST);
		(*ResWords)["getters"] = (void*) (Y_GETTERS);
		(*ResWords)["setters"] = (void*) (Y_SETTERS);
		(*ResWords)["const"] = (void*) (Y_CONST);
//		(*ResWords)[""] = (void*) (Y_);
	}
	LineNo = 1;

#ifdef FLEX_SCANNER
static void yyrestart (FILE*);
	yyrestart (0);
#endif
}

%}

Int	[-]?[0-9]+
Ident	[a-zA-Z_][a-zA-Z_0-9]*
nl	[\n]
sp0	[ \t]*
sp1	[ \t]+
LocHeader	\"{Ident}.h\"
GlobHeader	\<Ident.h\>

%%

[,();{}*]	RETURN (yytext[0]);

\%.*\n		{ /* comments */
		++LineNo;
		}

{sp1}		{}

{nl}		{
		++LineNo;
		}

->		{ RETURN (Y_YIELDS); }

#include
{Ident}		{
		CcuHashCell* c;
		if (c = ResWords->Get (yytext)) {
			RETURN(int (c->GetInfo ()));
		} else {
			yylval.string = NewString (yytext);
			RETURN (Y_ID);
		}
		}

.		{
		RETURN (-1);
		}