blob: c63e9695f4856ffe90bf4bf9bbbeb2c6f08cadcf (
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
|
// Copyright (C) 1999-2018
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"
%pure-parser
%parse-param {LUTColorMap* cm}
%lex-param {rgbFlexLexer* ll}
%parse-param {rgbFlexLexer* ll}
%{
#define YYDEBUG 1
#define DISCARD_(x) {yyclearin; rgbDiscard(x);}
#include <string.h>
#include <iostream>
#include "lut.h"
#undef yyFlexLexer
#define yyFlexLexer rgbFlexLexer
#include <FlexLexer.h>
extern int rgblex(void*, rgbFlexLexer*);
extern void rgberror(LUTColorMap*, rgbFlexLexer*, const char*);
extern void rgbDiscard(int);
%}
%union {
#define LUTBUFSIZE 4096
char str[LUTBUFSIZE];
int integer;
float real;
}
%type <real> numeric
%token <real> REAL
%token <integer> INT
%token <str> STRING
%token EOF_
%token DEBUG_
%token FALSE_
%token NO_
%token OFF_
%token ON_
%token TRUE_
%token YES_
%%
commands: commands command terminator
| command terminator
;
command : DEBUG_ debug
| numeric numeric numeric {cm->newRGBColor($1,$2,$3);}
| '#' {DISCARD_(1)} STRING
;
terminator: '\n'
| ';'
| EOF_ {YYACCEPT;}
;
numeric : REAL {$$=$1;}
| INT {$$=$1;}
;
debug : ON_ {yydebug=1;}
| OFF_ {yydebug=0;}
;
%%
|