5 kx
5 kx %{
5 kx
5 kx #ifdef HAVE_CONFIG_H
5 kx #include <config.h>
5 kx #endif
5 kx
5 kx #include <stdlib.h>
5 kx #include <stdio.h>
5 kx #include <unistd.h>
5 kx #include <string.h>
5 kx #include <stdarg.h>
5 kx #include <limits.h>
5 kx #include <locale.h>
5 kx #include <wchar.h>
5 kx #include <wctype.h>
5 kx
5 kx #include <defs.h>
5 kx
5 kx #include <main.h>
5 kx #include <error.h>
5 kx #include <msglog.h>
5 kx #include <xalloc.h>
5 kx #include <utf8ing.h>
5 kx #include <symtab.h>
5 kx #include <parse.h>
5 kx #include <lex.h>
5 kx
5 kx
5 kx %}
5 kx
5 kx
5 kx %union
5 kx {
5 kx SYMBOL *sym;
5 kx }
5 kx
5 kx %token <sym> VARIABLE 501 SECTION 502 REPO 503
5 kx %token <sym> NUMERICAL 510 STRING 511 PATH 512
5 kx %right '='
5 kx %left UNARYMINUS
5 kx /************************************************************
5 kx Following tokens declared only for verbose error messaging
5 kx to prevent "$undefined" values of unexpected symbols:
5 kx */
5 kx %token '!' '"' '#' '$' '%' '&' '\'' '(' ')' '*' '/' '+' '-'
5 kx %token '.' ',' ':' '<' '>' '?' '@' '[' '\\' ']' '^' '`'
5 kx
5 kx %start list
5 kx
5 kx %%
5 kx list: /* nothing */
5 kx | list ';'
5 kx | list repo
5 kx | list section
5 kx | list assign ';'
5 kx | list error ';' { return 1; }
5 kx ;
5 kx
5 kx assign: VARIABLE '=' NUMERICAL { (void)assign_value( $1, $3 ); }
5 kx | VARIABLE '=' '+' NUMERICAL { (void)assign_value( $1, $4 ); }
5 kx | VARIABLE '=' '-' NUMERICAL %prec UNARYMINUS { $4->u.value = -$4->u.value; (void)assign_value( $1, $4 ); }
5 kx | VARIABLE '=' STRING { (void)assign_value( $1, $3 ); }
5 kx | VARIABLE '=' PATH { (void)assign_value( $1, $3 ); }
5 kx | NUMERICAL '=' NUMERICAL { (void)assign_value( $1, $3 ); }
5 kx | STRING '=' STRING { (void)assign_value( $1, $3 ); }
5 kx | PATH '=' PATH { (void)assign_value( $1, $3 ); }
5 kx ;
5 kx
5 kx alist: /* nothing */
5 kx | alist ';'
5 kx | alist assign ';'
5 kx ;
5 kx
5 kx repo: REPO PATH '{'
5 kx {
5 kx if( lookup_repo( $2->u.path ) )
5 kx {
5 kx error( "Repository '%s' is already defined", $2->u.path );
5 kx return 1;
5 kx }
5 kx (void)assign_value( $1, $2 ); push_symlist( (SYMBOL **)&($1->list) );
5 kx }
5 kx alist
5 kx '}' { pop_symlist(); }
5 kx ;
5 kx
5 kx rlist: /* nothing */
5 kx | rlist repo
5 kx ;
5 kx
5 kx section:
5 kx SECTION STRING '{'
5 kx {
5 kx if( lookup_section( $2->u.string ) )
5 kx {
5 kx error( "Section '%s' is already defined", $2->u.string );
5 kx return 1;
5 kx }
5 kx (void)assign_value( $1, $2 ); push_symlist( (SYMBOL **)&($1->list) );
5 kx }
5 kx rlist
5 kx '}' { pop_symlist(); }
5 kx ;
5 kx
5 kx %%
5 kx