all repos — openbox @ 5cf61ee02354c1c9f80c11f3796afc4b948055d6

openbox fork - make it a bit more like ryudo

openbox/parse.l (raw)

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
%{
#include "parse.h"
#ifdef HAVE_STDLIB_H
#  include <stdlib.h>
#endif

extern int lineno;
%}

real [-0-9][0-9]*\.[0-9]+
integer [-0-9][0-9]*
string \"[^"\n]*\"
identifier [a-zA-Z][-.a-zA-Z0-9]*
bool ([tT][rR][uU][eE]|[fF][aA][lL][sS][eE]|[yY][eE][sS]|[nN][oO]|[oO][nN]|[oO][fF][fF])

%%

^[ \t]*#.*\n /* comment */ { ++lineno; }
^[ \t]*#.*   /* comment */
^[ \t]*\n    /* empty lines */ { ++lineno; }
[ \t]        /* whitespace */
{real}       { yylval.real = atof(yytext); return REAL; }
{integer}    { yylval.integer = atoi(yytext); return INTEGER; }
{string}     { yylval.string = g_strdup(yytext+1); /* drop the left quote */
               if (yylval.string[yyleng-2] != '"')
                   yyerror("improperly terminated string on line %d");
               else
                   yylval.string[yyleng-2] = '\0';
               return STRING;
             }
{bool}       { yylval.bool = (!g_ascii_strcasecmp("true", yytext) ||
                              !g_ascii_strcasecmp("yes", yytext) ||
                              !g_ascii_strcasecmp("on", yytext));
               return BOOL;
             }
{identifier} { yylval.identifier = g_strdup(yytext); return IDENTIFIER; }
[{}()\[\]=,] { yylval.character = *yytext; return *yytext; }
\n           { yylval.character = *yytext; return *yytext; }
.            { return INVALID; }

%%

int yywrap() {
    return 1;
}