summaryrefslogtreecommitdiffstats
path: root/lexer
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-01-09 22:29:31 +0100
committerDave Davenport <qball@gmpclient.org>2017-01-09 22:29:31 +0100
commitca01af6338382c75f31555160f40aa5385be6521 (patch)
treea7722edb1e926ba49ab107b09ab15c53ed71f161 /lexer
parentb010da57d74922ba35e94e254417a569fa3097d5 (diff)
Try to improve error handling and messages
Diffstat (limited to 'lexer')
-rw-r--r--lexer/theme-lexer.l13
-rw-r--r--lexer/theme-parser.y17
2 files changed, 22 insertions, 8 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index 117cf6f1..f920b891 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -4,7 +4,6 @@
%{
#include <stdio.h>
-
#include "lexer/theme-parser.h"
int last_state = 0;
GQueue *queue = NULL;
@@ -341,6 +340,18 @@ if ( queue == NULL ){
<INITIAL>. {
return T_ERROR;
}
+<ENTRY>. {
+ return T_ERROR_ENTRY;
+}
+<PROPERTIES>. {
+ return T_ERROR_PROPERTY;
+}
+<NAMESTR>. {
+ return T_ERROR_NAMESTRING;
+}
+<DEFAULTS>. {
+ return T_ERROR_DEFAULTS;
+}
<*>. {
return T_ERROR;
}
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index fa1d8e94..61c4553e 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -1,10 +1,10 @@
%define api.pure
+%locations
%glr-parser
%skeleton "glr.c"
-%locations
%debug
%error-verbose
-
+%parse-param {const char *what}
%code requires {
#include "theme.h"
}
@@ -13,10 +13,9 @@
#include <stdlib.h>
#include <glib.h>
-
#include "lexer/theme-parser.h"
ThemeWidget *rofi_theme = NULL;
-void yyerror(YYLTYPE *yylloc, const char* s);
+void yyerror(YYLTYPE *yylloc, const char *what, const char* s);
int yylex (YYSTYPE *, YYLTYPE *);
%}
@@ -33,12 +32,16 @@ int yylex (YYSTYPE *, YYLTYPE *);
Distance distance;
}
-%token <ival> T_END 0 "end of file"
-%token <ival> T_ERROR 1 "error from file parser"
+%token <ival> T_END 0 "end of file"
+%token <ival> T_ERROR 1 "error from file parser"
+%token <ival> T_ERROR_PROPERTY 2 "invalid property value"
+%token <ival> T_ERROR_ENTRY 3 "invalid property name"
+%token <ival> T_ERROR_NAMESTRING 4 "invalid element name"
+%token <ival> T_ERROR_DEFAULTS 5 "invalid defaults name"
%token <ival> T_INT
%token <fval> T_DOUBLE
%token <sval> T_STRING
-%token <sval> N_STRING
+%token <sval> N_STRING "property name"
%token <ival> T_POSITION;
%token <ival> T_HIGHLIGHT_STYLE
%token <sval> NAME_ELEMENT "Element name"