diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-12-09 19:49:49 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-12-09 19:49:49 +0100 |
commit | d18f037d1c82f5081711753caec7d819000e0054 (patch) | |
tree | e74c04b1b38ff7f36b709d5f6cb15c1fe171050c /lexer/theme-lexer.l | |
parent | ea28bcdc74dc4085b1c337dcb469aa641b3a8a6c (diff) |
Add lex/bison parser for theme.
Diffstat (limited to 'lexer/theme-lexer.l')
-rw-r--r-- | lexer/theme-lexer.l | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l new file mode 100644 index 00000000..4094a256 --- /dev/null +++ b/lexer/theme-lexer.l @@ -0,0 +1,33 @@ +%option noyywrap + +%{ +#include <stdio.h> + + +#include "lexer/theme-parser.tab.h" +int yylex(void); +#define YY_DECL int yylex() + +%} + +%% + +"@" { return CLASS;} +"\{" { return BOPEN;} +"\}" { return BCLOSE;} +":" { return PSEP; } +";" { return PCLOSE;} +"." { return NSEP; } +[ \t] ; // ignore all whitespace +[0-9]+\.[0-9]+ { yylval.fval = g_ascii_strtod(yytext, NULL); return T_FLOAT;} +[0-9]+ { yylval.ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} +(true|false) { yylval.bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} +[a-zA-Z0-9]+ { yylval.sval = g_strdup(yytext); return N_STRING;} +\"[a-zA-Z0-9]+\" { yylval.sval = g_strdup(yytext); return T_STRING;} +#[0-9A-Fa-f]+ { yylval.colorval = (unsigned int)strtoull ( &yytext[1], NULL, 16); return T_COLOR;} +[\r\n]+ ; + +<*><<EOF>> { + yyterminate(); +} +%% |