%{
+#ifdef HAVE_CONFIG_H
+# include "../../config.h"
+#endif // HAVE_CONFIG_H
+
#include <stdio.h>
#include <string.h>
#include "parser.hh"
#define YYPARSE_PARAM parser_obj
#define YYSTYPE char*
-
+
+extern int yylineno;
+extern char *yytext;
+
extern "C" {
int yylex();
int yywrap() {
}
}
-void yyerror(const char *c) {
- printf("ERROR: %s\n", c);
+void yyerror(const char *c)
+{
+ printf("ERROR: %s, on line %d, near %s\n", c, yylineno, yytext);
}
-
%}
-%token OBRACE EBRACE SEMICOLON DASH NUMBER QUOTES WORD BINDING
+%token OBRACE EBRACE SEMICOLON DASH NUMBER QUOTES WORD BINDING OPTIONS TRUE FALSE
+%expect 1
%%
commands:
| commands command
+ | commands options_block
;
command:
}
;
+options_block:
+ options_keyword OBRACE options EBRACE
+ ;
+
binding:
binding_w_modifier bind_key
;
| NUMBER { ((parser*)parser_obj)->setArgumentNum($1); }
| DASH NUMBER { ((parser*)parser_obj)->setArgumentNegNum($2); }
| QUOTES { ((parser*)parser_obj)->setArgumentStr($1); }
+ | TRUE { ((parser*)parser_obj)->setArgumentTrue($1); }
+ | FALSE { ((parser*)parser_obj)->setArgumentFalse($1); }
+ ;
+
+options_keyword:
+ OPTIONS
+ ;
+
+options:
+ | options option
+ ;
+
+option:
+ WORD parameter SEMICOLON
+ { ((parser*)parser_obj)->setOption($1); }
;
%%