X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fparse.y;h=7e92efd6767dc8e6e703fab08ceee9b8b1066b2c;hb=7a166a383805f7693e0800f3bf693e3736463a0d;hp=37bd3dc394eb91b2edbe1d1fb9be01356319e1cc;hpb=5da148530ee8931c8ed7771c373146afaf2b14e1;p=chaz%2Fopenbox diff --git a/openbox/parse.y b/openbox/parse.y index 37bd3dc3..7e92efd6 100644 --- a/openbox/parse.y +++ b/openbox/parse.y @@ -13,17 +13,19 @@ char *identifier; gboolean bool; char character; - GSList *list; + GList *list; } %{ +#define NO_TAB_H #include "parse.h" +#undef NO_TAB_H extern int yylex(); extern int yyparse(); void yyerror(char *err); -extern int yylineno; +extern int lineno; extern FILE *yyin; static char *path; @@ -31,6 +33,7 @@ static ParseToken t; /* in parse.c */ void parse_token(ParseToken *token); +void parse_assign(char *name, ParseToken *token); void parse_set_section(char *section); %} @@ -38,7 +41,7 @@ void parse_set_section(char *section); %token INTEGER %token STRING %token IDENTIFIER -%token BOOL +%token BOOLEAN %token '(' %token ')' %token '{' @@ -54,31 +57,32 @@ void parse_set_section(char *section); %% sections: - | sections '[' IDENTIFIER ']' { parse_set_section($3); } '\n' lines + | sections '[' IDENTIFIER ']' { parse_set_section($3); } '\n' + { ++lineno; } lines ; lines: - | lines tokens '\n' { t.type = $3; t.data.character = $3; parse_token(&t); } + | lines tokens { t.type='\n'; t.data.character='\n'; parse_token(&t); } '\n' + { ++lineno; } + | lines IDENTIFIER '=' listtoken { parse_assign($2, &t); } '\n' + { ++lineno; } ; tokens: - tokens token - | token + tokens token { parse_token(&t); } + | token { parse_token(&t); } ; token: - REAL { t.type = TOKEN_REAL; t.data.real = $1; parse_token(&t); } - | INTEGER { t.type = TOKEN_INTEGER; t.data.integer = $1; - parse_token(&t); } - | STRING { t.type = TOKEN_STRING; t.data.string = $1; parse_token(&t); } - | IDENTIFIER { t.type = TOKEN_IDENTIFIER; t.data.identifier = $1; - parse_token(&t);} - | BOOL { t.type = TOKEN_BOOL; t.data.bool = $1; parse_token(&t); } - | list { t.type = TOKEN_LIST; t.data.list = $1; parse_token(&t); } - | '{' { t.type = $1; t.data.character = $1; parse_token(&t); } - | '}' { t.type = $1; t.data.character = $1; parse_token(&t); } - | '=' { t.type = $1; t.data.character = $1; parse_token(&t); } - | ',' { t.type = $1; t.data.character = $1; parse_token(&t); } + REAL { t.type = TOKEN_REAL; t.data.real = $1; } + | INTEGER { t.type = TOKEN_INTEGER; t.data.integer = $1; } + | STRING { t.type = TOKEN_STRING; t.data.string = $1; } + | IDENTIFIER { t.type = TOKEN_IDENTIFIER; t.data.identifier = $1; } + | BOOLEAN { t.type = TOKEN_BOOL; t.data.bool = $1; } + | list { t.type = TOKEN_LIST; t.data.list = $1; } + | '{' { t.type = $1; t.data.character = $1; } + | '}' { t.type = $1; t.data.character = $1; } + | ',' { t.type = $1; t.data.character = $1; } ; list: @@ -89,12 +93,12 @@ listtokens: listtokens listtoken { ParseToken *nt = g_new(ParseToken, 1); nt->type = t.type; nt->data = t.data; - $$ = g_slist_append($1, nt); + $$ = g_list_append($1, nt); } - | token { ParseToken *nt = g_new(ParseToken, 1); + | listtoken { ParseToken *nt = g_new(ParseToken, 1); nt->type = t.type; nt->data = t.data; - $$ = g_slist_append(NULL, nt); + $$ = g_list_append(NULL, nt); } ; @@ -103,19 +107,20 @@ listtoken: | INTEGER { t.type = TOKEN_INTEGER; t.data.integer = $1; } | STRING { t.type = TOKEN_STRING; t.data.string = $1; } | IDENTIFIER { t.type = TOKEN_IDENTIFIER; t.data.identifier = $1; } - | BOOL { t.type = TOKEN_BOOL; t.data.bool = $1; } + | BOOLEAN { t.type = TOKEN_BOOL; t.data.bool = $1; } | list { t.type = TOKEN_LIST; t.data.list = $1; } | '{' { t.type = $1; t.data.character = $1; } | '}' { t.type = $1; t.data.character = $1; } - | '=' { t.type = $1; t.data.character = $1; } | ',' { t.type = $1; t.data.character = $1; } ; %% +int lineno; + void yyerror(char *err) { - g_message("%s:%d: %s", path, yylineno, err); + g_message("%s:%d: %s", path, lineno, err); } void parse_rc() @@ -133,7 +138,7 @@ void parse_rc() } } - yylineno = 1; + lineno = 1; yyparse();