summaryrefslogtreecommitdiff
path: root/src/libicalss/icalsslexer.l
blob: 57d5ef58e4a1b026edea11e330cd1bf8a2b180ae (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
%{
/*
  ======================================================================
  FILE: icalsslexer.l
  CREATOR: eric 8 Aug 2000

(C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com>

 This program is free software; you can redistribute it and/or modify
 it under the terms of either:

    The LGPL as published by the Free Software Foundation, version
    2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html

  Or:

    The Mozilla Public License Version 2.0. You may obtain a copy of
    the License at https://www.mozilla.org/MPL/

 The Original Code is eric. The Initial Developer of the Original
 Code is Eric Busboom

  ======================================================================*/

#include "icalssyacc.h"
#include "icalgaugeimpl.h"
#include "assert.h"

#include <string.h> /* For strdup() */

const char* input_buffer;
const char* input_buffer_p;

int icalss_input(char* buf, int max_size)
{
    int n;
    int l;

    l = strlen(input_buffer_p);
    if (max_size<l) n = max_size;
    else n = l;

    if (n > 0){
        memcpy(buf, input_buffer_p, n);
        input_buffer_p += n;
        return n;
    } else {
        return 0;
    }
}

#undef YY_INPUT
#define YY_INPUT(b,r,ms) ( r= icalss_input(b,ms))

#undef SS_FATAL_ERROR
#define SS_FATAL_ERROR(msg) sserror(msg)

%}

crlf            \x0D?\x0A
space           [ ]
qsafechar       [^\x00-\x1F\"]
safechar        [^\x00-\x1F\"\:\;\,]
tsafechar       [\x20-\x21\x23-\x2B\x2D-\x39\x3C-\x5B\x5D-\x7E]
valuechar       [^\x00-\x08\x10-\x1F]
xname           X-[a-zA-Z0-9\-]+
xname2          [a-zA-Z0-9\-\ ]
paramtext       {safechar}+
value           {valuechar}+
quotedstring    \"{qsafechar}+\"
digit           [0-9]

%array /* Make yytext an array. Slow, but handy. HACK */

%option caseless

%s sql string_value



%%

%{
%}


SELECT                  { return SELECT; }
FROM                    { return FROM; }
WHERE                   { return WHERE; }
,                       { return COMMA; }
"="                     { return EQUALS; }
"=="                    { return EQUALS; }
"!="                    { return NOTEQUALS; }
"<"                     { return LESS; }
">"                     { return GREATER; }
"<="                    { return LESSEQUALS; }
">="                    { return GREATEREQUALS; }
AND                     { return AND; }
OR                      { return OR; }
IS                      { return IS; }
NOT                     { return NOT; }
NULL                    { return SQLNULL; }
\'                      { return QUOTE; }
[ \t\n\r]+ ;
;                       { return EOL; }

\'[\@\*A-Za-z0-9\-\.\:\ ]+\' {
        int c = input();
        if(c != EOF){
                unput(c);
        }
        if(c!='\''){
                sslval.v_string= icalmemory_tmp_copy(yytext);
                return STRING;
        } else {
                /*ssmore();*/
        }
}

[\@\*A-Za-z0-9\-\.]+ {
        sslval.v_string= icalmemory_tmp_copy(yytext);
        return STRING;
}


.                       { return yytext[0]; }

%%

int yywrap()
{
     return 1;
}