All pastes #1242862 Raw Edit

conf.y

public text v1 · immutable
#1242862 ·published 2008-11-02 03:28 UTC
rendered paste body
%{
#define	YYSTYPE char
#define YYERROR_VERBOSE
#include <stdio.h>
#include <string.h>
#include "conf.h"
#include "conf_parser.h"

void	yyerror(const char *str) {
        fprintf(stderr, "error: %s\n", str);
}
%}
%debug
%defines
%locations
%token NEWLINE READONLY TOKDEBUG MOUNTPOINT LOGFILE LOGLEVEL PKGDIR DBTYPE DBPATH
%token <number> NUMBER
%token <number> INTEGER
%token <string> WORD
%token <string> STRING
%token <string> FILENAME

%union
{
        int number;
        char *string;
}

%%
commands: /* empty */
        |
        commands command NEWLINE
        ;

command:
        readonly | debug | mountpoint;

readonly:
        READONLY {
           conf->readonly = true;
        }
        ;

debug:
        TOKDEBUG {
           conf->debug = true;
        }
        ;
  
mountpoint:
        MOUNTPOINT FILENAME {
           conf->mountpoint = $2;
        }
        ;
%%