diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-04-02 07:46:46 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-04-02 07:46:46 +0000 |
| commit | 71c8b0b7b2cf2fa79ac4c81b7756f2b230f2de7a (patch) | |
| tree | 7294b08a6708be789f5f674418c7dc80809d78b4 /openbox/parse.l | |
| parent | 4875ff5f8ed227a989c699fe6d8390396e485815 (diff) | |
create a generic tokenizer/sectionizer for the config file. pass off the token to functions registered for each section to parse them further. some fixes for the engine irt font shadows, and fixed a bug with rendering the iconify button when it was not in the layout
Diffstat (limited to 'openbox/parse.l')
| -rw-r--r-- | openbox/parse.l | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/openbox/parse.l b/openbox/parse.l new file mode 100644 index 00000000..c888b9f1 --- /dev/null +++ b/openbox/parse.l @@ -0,0 +1,48 @@ +%{ +#include <glib.h> +#include "y.tab.h" +#ifdef HAVE_STDLIB_H +# include <stdlib.h> +#endif + +extern void yyerror(char *err); + +int yylineno = 1; +%} + +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 */ { ++yylineno; } +^[ \t]*#.* /* comment */ +^[ \t]*\n /* empty lines */ { ++yylineno; } +[ \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; ++yylineno; return *yytext; } +. { return INVALID; } + +%% + +int yywrap() { + return 1; +} |
