4
A good bit of this file is taken from kdelibs/corba/kded/lex.l, which
5
solved almost the same problem in a nice way. It was written by either
6
David Faure or Steffan Hansen (unclear which). Don Comeau also
7
deserves credit for teaching me how to use the whole lex/yacc thing in
13
#include "activation-context-query.h"
14
#include "activation-context-query-parser.h"
20
static char* putSymbol (char *_name);
21
static char* putString (char *_name);
22
static int yywrap (void);
24
void initFlex (const char *_code);
33
"!=" { return P_NEQ; }
36
"<=" { return P_LEQ; }
37
">=" { return P_GEQ; }
38
"&&" { return P_AND; }
39
"AND" { return P_AND; }
43
"NOT" { return P_NOT; }
44
"^^" { return P_XOR; }
45
"XOR" { return P_XOR; }
47
"/" { return P_DIVIDE; }
49
"-" { return P_SUBTRACT; }
50
"*" { return P_MULTIPLY; }
52
"." { return PERIOD; }
54
"(" { return LPAREN; }
55
")" { return RPAREN; }
56
"[" { return LBRACKET; }
57
"]" { return RBRACKET; }
59
"$" { return P_DOLLAR; }
61
(TRUE|true|True|YES|yes|Yes) { yylval.val_boolean = TRUE; return P_CONST_BOOLEAN; }
62
(FALSE|false|False|NO|no|No) { yylval.val_boolean = FALSE; return P_CONST_BOOLEAN; }
64
"'"(\\'|[^'])+"'" { yylval.val_string = putString (yytext); return P_CONST_STRING; }
66
{DIGIT}+"."{DIGIT}+ { yylval.val_number = atof (yytext); return P_CONST_NUMBER; }
67
{DIGIT}+ { yylval.val_number = atof (yytext); return P_CONST_NUMBER; }
69
[a-zA-Z_][a-zA-Z0-9_:]* { yylval.val_string = putSymbol (yytext); return P_CONST_ID; }
71
[ \t\n\r]+ /* eat up whitespace */
73
. { return PARSE_ERROR; }
78
putSymbol (char *_name)
80
return g_strdup (_name);
84
putString (char *_str)
86
int l = strlen (_str);
87
char *p = (char*) g_malloc (l + 1);
90
while (s < _str + l - 1)
113
initFlex (const char *_code)
115
yy_switch_to_buffer (yy_scan_string (_code));
121
yy_delete_buffer (YY_CURRENT_BUFFER);