~ubuntu-branches/ubuntu/quantal/libbonobo/quantal-201207170711

« back to all changes in this revision

Viewing changes to activation-server/activation-context-query-lexer.l

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-02-18 14:40:51 UTC
  • mto: (3.1.1 etch) (1.1.25 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050218144051-fo4h9qh2gim8x3wt
Tags: upstream-2.8.1
ImportĀ upstreamĀ versionĀ 2.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%{
 
2
/*
 
3
 
 
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
 
8
the beginning.
 
9
 
 
10
  - ECL
 
11
 */
 
12
 
 
13
#include "activation-context-query.h"
 
14
#include "activation-context-query-parser.h"
 
15
 
 
16
#include <string.h>
 
17
#include <stdlib.h>
 
18
#define YY_NO_UNPUT
 
19
 
 
20
static char* putSymbol (char *_name);
 
21
static char* putString (char *_name);
 
22
static int yywrap (void);
 
23
int yylex (void);
 
24
void initFlex (const char *_code);
 
25
 
 
26
%}
 
27
 
 
28
DIGIT   [0-9]
 
29
 
 
30
%%
 
31
 
 
32
"=="  { return P_EQ; }
 
33
"!="  { return P_NEQ; }
 
34
"<"   { return P_LT; }
 
35
">"   { return P_GT; }
 
36
"<="  { return P_LEQ; }
 
37
">="  { return P_GEQ; }
 
38
"&&"  { return P_AND; }
 
39
"AND" { return P_AND; }
 
40
"||"  { return P_OR; }
 
41
"OR"  { return P_OR; }
 
42
"~"   { return P_NOT; }
 
43
"NOT" { return P_NOT; }
 
44
"^^"  { return P_XOR; }
 
45
"XOR" { return P_XOR; }
 
46
 
 
47
"/"   { return P_DIVIDE; }
 
48
"+"   { return P_ADD; }
 
49
"-"   { return P_SUBTRACT; }
 
50
"*"   { return P_MULTIPLY; }
 
51
","   { return COMMA; }
 
52
"."   { return PERIOD; }
 
53
 
 
54
"("   { return LPAREN; }
 
55
")"   { return RPAREN; }
 
56
"["   { return LBRACKET; }
 
57
"]"   { return RBRACKET; }
 
58
 
 
59
"$"   { return P_DOLLAR; }
 
60
 
 
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; }
 
63
 
 
64
"'"(\\'|[^'])+"'" { yylval.val_string = putString (yytext); return P_CONST_STRING; }
 
65
 
 
66
{DIGIT}+"."{DIGIT}+ { yylval.val_number = atof (yytext); return P_CONST_NUMBER; }
 
67
{DIGIT}+ { yylval.val_number = atof (yytext); return P_CONST_NUMBER; }
 
68
 
 
69
[a-zA-Z_][a-zA-Z0-9_:]* { yylval.val_string = putSymbol (yytext); return P_CONST_ID; }
 
70
 
 
71
[ \t\n\r]+          /* eat up whitespace */
 
72
 
 
73
. { return PARSE_ERROR; }
 
74
 
 
75
%%
 
76
 
 
77
static char *
 
78
putSymbol (char *_name)
 
79
{
 
80
  return g_strdup (_name);
 
81
}
 
82
 
 
83
static char *
 
84
putString (char *_str)
 
85
{
 
86
  int l = strlen (_str);
 
87
  char *p = (char*) g_malloc (l + 1);
 
88
  char *s = _str + 1;
 
89
  char *d = p;
 
90
  while (s < _str + l - 1)
 
91
  {
 
92
     if (*s != '\\') {
 
93
        *d++ = *s++;
 
94
     } else {
 
95
        s++;
 
96
        if (*s == '\\')
 
97
          *d++ = '\\';
 
98
        else if (*s == 'n')
 
99
          *d++ = '\n';
 
100
        else if (*s == 'r')
 
101
          *d++ = '\r';
 
102
        else if (*s == 't')
 
103
          *d++ = '\t';
 
104
        s++;
 
105
     }
 
106
  }
 
107
 
 
108
  *d = 0;
 
109
  return p;
 
110
}
 
111
 
 
112
void
 
113
initFlex (const char *_code)
 
114
{
 
115
  yy_switch_to_buffer (yy_scan_string (_code));
 
116
}
 
117
 
 
118
static int
 
119
yywrap (void)
 
120
{
 
121
  yy_delete_buffer (YY_CURRENT_BUFFER);
 
122
  return 1;
 
123
}