forked from paulscherrerinstitute/require
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbLoadTemplate_lex.l
62 lines (51 loc) · 1.51 KB
/
dbLoadTemplate_lex.l
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
/*************************************************************************\
* Copyright (c) 2006 UChicago, as Operator of Argonne
* National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
newline "\n"
backslash "\\"
doublequote "\""
singlequote "'"
comment "#"
whitespace [ \t\r]
escape {backslash}.
dstringchar [^"\n\\]
sstringchar [^'\n\\]
/*
This breaks backward compatibility to 3.14.8:
bareword [a-zA-Z0-9_\-+:./\\\[\]<>;]
Re-enable unquoted chars except #
*/
bareword [a-zA-Z0-9_\-+:./\\\[\]<>;^~*%!|&$()@?]
%%
"pattern" { return(PATTERN); }
"file" { return(DBFILE); }
"global" { return(GLOBAL); }
{doublequote}({dstringchar}|{escape})*{doublequote} |
{singlequote}({sstringchar}|{escape})*{singlequote} {
yylval.Str = dbmfStrdup(yytext+1);
yylval.Str[strlen(yylval.Str)-1] = '\0';
return(QUOTE);
}
{bareword}+ {
yylval.Str = dbmfStrdup(yytext);
return(WORD);
}
"=" { return(EQUALS); }
"," { return(COMMA); }
"{" { return(O_BRACE); }
"}" { return(C_BRACE); }
{comment}.* ;
{whitespace} ;
{newline} { line_num++; }
. {
char message[40];
sprintf(message, "invalid character '%c'", yytext[0]);
yyerror(message);
/* Suppress compiler warning messages */
if (0) yyunput('c',NULL);
if (0) yy_switch_to_buffer(NULL);
}
%%