]> Dogcows Code - chaz/openbox/blob - openbox/parse.l
stop using build/ dir configure shits all over itself for other people
[chaz/openbox] / openbox / parse.l
1 %{
2 #include "parse.h"
3 #ifdef HAVE_STDLIB_H
4 # include <stdlib.h>
5 #endif
6
7 int yylineno = 1;
8 %}
9
10 real [-0-9][0-9]*\.[0-9]+
11 integer [-0-9][0-9]*
12 string \"[^"\n]*\"
13 identifier [a-zA-Z][-.a-zA-Z0-9]*
14 bool ([tT][rR][uU][eE]|[fF][aA][lL][sS][eE]|[yY][eE][sS]|[nN][oO]|[oO][nN]|[oO][fF][fF])
15
16 %%
17
18 ^[ \t]*#.*\n /* comment */ { ++yylineno; }
19 ^[ \t]*#.* /* comment */
20 ^[ \t]*\n /* empty lines */ { ++yylineno; }
21 [ \t] /* whitespace */
22 {real} { yylval.real = atof(yytext); return REAL; }
23 {integer} { yylval.integer = atoi(yytext); return INTEGER; }
24 {string} { yylval.string = g_strdup(yytext+1); /* drop the left quote */
25 if (yylval.string[yyleng-2] != '"')
26 yyerror("improperly terminated string on line %d");
27 else
28 yylval.string[yyleng-2] = '\0';
29 return STRING;
30 }
31 {bool} { yylval.bool = (!g_ascii_strcasecmp("true", yytext) ||
32 !g_ascii_strcasecmp("yes", yytext) ||
33 !g_ascii_strcasecmp("on", yytext));
34 return BOOL;
35 }
36 {identifier} { yylval.identifier = g_strdup(yytext); return IDENTIFIER; }
37 [{}()\[\]=,] { yylval.character = *yytext; return *yytext; }
38 \n { yylval.character = *yytext; return *yytext; }
39 . { return INVALID; }
40
41 %%
42
43 int yywrap() {
44 return 1;
45 }
This page took 0.03514 seconds and 4 git commands to generate.