X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fparse.y;h=de221f9f094fd6f13ce4e50c3f60566846632391;hb=3d6e0f941d36ff335ad13ecf83405a40775e4c04;hp=f8b0a04411d45a4b5df718149777e3aa58a99f92;hpb=68ff2eb3d2d7874e780000143cbee9a8e7c2e57f;p=chaz%2Fopenbox diff --git a/openbox/parse.y b/openbox/parse.y index f8b0a044..de221f9f 100644 --- a/openbox/parse.y +++ b/openbox/parse.y @@ -23,7 +23,7 @@ extern int yylex(); extern int yyparse(); void yyerror(char *err); -extern int yylineno; +extern int lineno; extern FILE *yyin; static char *path; @@ -31,6 +31,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); %} @@ -54,31 +55,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; } + | BOOL { 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: @@ -107,15 +109,16 @@ listtoken: | 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 +136,7 @@ void parse_rc() } } - yylineno = 1; + lineno = 1; yyparse();