~ubuntu-branches/ubuntu/trusty/picviz/trusty

« back to all changes in this revision

Viewing changes to src/libpicviz/filters/filter.lex.l

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2009-03-30 10:42:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090330104208-j095obwkp574t1lm
Tags: upstream-0.5
ImportĀ upstreamĀ versionĀ 0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Picviz - Parallel coordinates ploter
 
3
 * Copyright (C) 2008 Sebastien Tricaud <toady@gscore.org>
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation version 3.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 */
 
17
 
 
18
%{
 
19
#include <string.h>
 
20
 
 
21
#include "filter-parser.h"
 
22
 
 
23
static char *escape_str(char *str)
 
24
{
 
25
        size_t w = 0, i = 0;
 
26
        int escape_next = 0;
 
27
 
 
28
        for ( i = 1; str[i]; i++ ) {
 
29
 
 
30
                if ( ! escape_next && str[i] == '\\' ) {
 
31
                        escape_next = 1;
 
32
                        continue;
 
33
                }
 
34
 
 
35
                str[w++] = str[i];
 
36
                escape_next = 0;
 
37
        }
 
38
 
 
39
        str[w - 1] = '\0';
 
40
        return str;
 
41
}
 
42
 
 
43
%}
 
44
%option noyywrap
 
45
%option 8bit prefix="pcvfilter"
 
46
 
 
47
 /* [show|hide] [only|except] [value|plot|plotmin|plotmax|color] [>|<|=|] ["red"|"foobar"|123] [on axis N] */
 
48
 /* plot = exact value as plotted by picviz
 
49
  * plotmin = number of plots min to display */
 
50
 /* ie.: show only plot > 100 on axis 3 */
 
51
 /* ie.: show only plotmin 5 on axes */
 
52
 
 
53
FILTERDISPLAY  (show|hide)
 
54
FILTERSELECT  (only|except)
 
55
FILTERTYPE (value|plot|color|freq)
 
56
SELECTAXIS  (on\ axis)
 
57
SELECTAXES  (on\ axes)
 
58
NUMBER      [0-9]+
 
59
PERCENT     [0-9]+%
 
60
SQSTRING    \'([^\\\']|\\.)*\'
 
61
DQSTRING    \"([^\\\"]|\\.)*\"
 
62
 
 
63
 /* Operators */
 
64
OPERATOR_AND (\&\&|\&|and|AND)
 
65
OPERATOR_OR  (\|\||\||or|OR)
 
66
 
 
67
OPERATOR_AND_WORD (and)
 
68
OPERATOR_OR_WORD (or)
 
69
 
 
70
 /* Relations */
 
71
RELATION      (\=|\!\=|\>|\<|\<\=|\>\=|is|not)
 
72
/*
 
73
RELATION_EQUAL   \=
 
74
RELATION_NOTEQUAL \!\=
 
75
RELATION_GREATER \>
 
76
RELATION_LESS    \<
 
77
RELATION_LESS_OR_EQUAL \<\=
 
78
RELATION_GREATER_OR_EQUAL \>\=
 
79
*/
 
80
 
 
81
VOID            [ \t]+
 
82
 
 
83
%%
 
84
\(                      { return '('; }
 
85
\)                      { return ')'; }
 
86
 
 
87
{FILTERDISPLAY} {
 
88
                pcvfilterlval.string = strdup(pcvfiltertext);
 
89
                return TOK_DISPLAY;
 
90
             }
 
91
 
 
92
{FILTERSELECT} {
 
93
                pcvfilterlval.string = strdup(pcvfiltertext);
 
94
                return TOK_SELECT;
 
95
             }
 
96
 
 
97
{FILTERTYPE} {
 
98
                pcvfilterlval.string = strdup(pcvfiltertext);
 
99
                return TOK_FILTERTYPE;
 
100
             }
 
101
 
 
102
{SELECTAXIS} {
 
103
                pcvfilterlval.string = strdup(pcvfiltertext);
 
104
                return TOK_SELECTAXIS;
 
105
             }
 
106
 
 
107
{SELECTAXES} {
 
108
                pcvfilterlval.string = strdup(pcvfiltertext);
 
109
                return TOK_SELECTAXES;
 
110
             }
 
111
 
 
112
{VOID}       {
 
113
                        /* We don't care */
 
114
             }
 
115
 
 
116
{DQSTRING}      {
 
117
                        pcvfilterlval.string = strdup(escape_str(pcvfiltertext));
 
118
                        return TOK_DQSTRING;
 
119
                }
 
120
{SQSTRING}      {
 
121
                        pcvfilterlval.string = strdup(escape_str(pcvfiltertext));
 
122
                        return TOK_SQSTRING;
 
123
                }
 
124
 
 
125
{NUMBER}      {
 
126
                        pcvfilterlval.string = strdup(pcvfiltertext);
 
127
                        return TOK_NUMBER;
 
128
              }
 
129
 
 
130
{PERCENT}     {
 
131
                        pcvfilterlval.string = strdup(pcvfiltertext);
 
132
                        return TOK_PERCENT;
 
133
              }
 
134
 
 
135
{RELATION} {
 
136
                pcvfilterlval.string = strdup(pcvfiltertext);
 
137
                return TOK_RELATION;
 
138
}
 
139
 
 
140
{OPERATOR_AND} { return TOK_OPERATOR_AND; };
 
141
{OPERATOR_OR} { return TOK_OPERATOR_OR; };
 
142
 
 
143
%%
 
144
 
 
145
/* remove unused functions */
 
146
typedef void (*dummy_function) ();
 
147
dummy_function picvizfilter_unused[] =
 
148
{
 
149
  (dummy_function) input, (dummy_function) yyunput
 
150
};
 
151
 
 
152