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
|
/* Copyright (C) 1999-2017
* Smithsonian Astrophysical Observatory, Cambridge, MA, USA
* For conditions of distribution and use, see copyright notice in "copyright"
*/
%option noyywrap
%option caseless
%option never-interactive
%option c++
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "parser.H"
extern YYSTYPE* cblval;
%}
D [0-9]
E [Ee][+-]?{D}+
/* rules */
%%
adjust {return ADJUST_;}
begin {return BEGIN_;}
bias {return BIAS_;}
bw {return BW_;}
channel {return CHANNEL_;}
cmyk {return CMYK_;}
colormap {return COLORMAP_;}
colorbar {return COLORBAR_;}
colorspace {return COLORSPACE_;}
contrast {return CONTRAST_;}
cursor {return CURSOR_;}
debug {return DEBUG_;}
delete {return DELETE_;}
edit {return EDIT_;}
end {return END_;}
get {return GET_;}
gray {return GRAY_;}
false {return FALSE_;}
file {return FILE_;}
height {return HEIGHT_;}
hide {return HIDE_;}
id {return ID_;}
invert {return INVERT_;}
itt {return ITT_;}
level {return LEVEL_;}
list {return LIST_;}
load {return LOAD_;}
macosx {return MACOSX_;}
map {return MAP_;}
motion {return MOTION_;}
n {return N_;}
name {return NAME_;}
no {return NO_;}
off {return OFF_;}
on {return ON_;}
postscript {return POSTSCRIPT_;}
print {return PRINT_;}
query {return QUERY_;}
reset {return RESET_;}
resolution {return RESOLUTION_;}
rgb {return RGB_;}
save {return SAVE_;}
show {return SHOW_;}
tag {return TAG_;}
true {return TRUE_;}
value {return VALUE_;}
var {return VAR_;}
version {return VERSION_;}
width {return WIDTH_;}
win32 {return WIN32_;}
window {return WINDOW_;}
y {return Y_;}
yes {return YES_;}
[+-]?{D}+ { // Integer
cblval->integer = atoi(yytext);
return INT;
}
[+-]?{D}+"."?({E})? |
[+-]?{D}*"."{D}+({E})? { // Real Number
cblval->real = atof(yytext);
return REAL;
}
0[xX][0-9a-fA-F]+ { // Pointer
cblval->ptr = (void*)strtoul(yytext,NULL,16);
return POINTER;
}
\"[^\"\n]*\" |
\'[^\'\n]*\' { // Quoted String
int ll = (yyleng-2)<(CBBUFSIZE-1) ? (yyleng-2):(CBBUFSIZE-1);
strncpy(cblval->str,yytext+1,ll); // skip the " "
cblval->str[ll] = '\0'; // Remove the '"'
return STRING;
}
\{[^\}\n]*\} { // Quoted String
int ll = (yyleng-2)<(CBBUFSIZE-1) ? (yyleng-2):(CBBUFSIZE-1);
strncpy(cblval->str,yytext+1,ll); // skip the '{'
cblval->str[ll] = '\0'; // Remove the '}'
return STRING;
}
[!-~][!-~]+ { // General String-- at least 2 printable chars
int ll = yyleng <(CBBUFSIZE-1) ? yyleng:(CBBUFSIZE-1);
strncpy(cblval->str,yytext,ll);
cblval->str[ll] = '\0';
return STRING;
}
[ \t]+ { // White Spaces
}
. { // Else, return the char
return yytext[0];
}
%%
|