%{
/*******************************************************************************
* Copyright (c) 2007, Perforce Software, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE
* SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*******************************************************************************/
/*******************************************************************************
* Config file parser for p4dctl
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include "parsesupp.h"
#include "config.h"
#include "server.h"
#define YYDEBUG 1
int yylex();
%}
%union {
int ival;
char * sval;
void * pval;
}
%type <pval> varlist
%type <pval> variable
%type <pval> environment
%type <pval> server_def
%type <pval> server_spec
%type <ival> server_type
%type <sval> server_name
%type <pval> setting
%type <pval> settinglist
%type <sval> settingname
%type <sval> var
%type <sval> value
%type <sval> word
%token <sval> WORD STRING NUMBER PATH
%token EXECUTE ENVIRONMENT OWNER ENABLED ARGS UMASK PRETTYNAMES PREFIX
%token P4D P4P P4BROKER P4FTP P4WEB P4DTG OTHER
%%
config: block
| config block
| /* Empty config is legal */
;
block: environment { AddEnviron( $1 ); }
| settinglist { AddSettings( $1 ); }
| server_def
;
environment: ENVIRONMENT '{' varlist '}' { $$ = $3; }
;
varlist: variable { $$ = $1; }
| varlist variable { $$ = AddVar( $1, $2 ); }
;
server_def: server_type server_name '{' server_spec '}' {
$$ = MakeServer( $2, $1, $4 );
if( !$$ )
yyerror( "Exiting." );
}
;
server_type: P4D { $$ = SERVER_P4D; }
| P4P { $$ = SERVER_P4P; }
| P4BROKER { $$ = SERVER_P4BROKER; }
| P4FTP { $$ = SERVER_P4FTP; }
| P4WEB { $$ = SERVER_P4WEB; }
| P4DTG { $$ = SERVER_P4DTG; }
| OTHER { $$ = SERVER_OTHER; }
;
server_name: word
;
/*
* Server specs consist of one optional environment block
* and a series of settings in any order
*/
server_spec: environment settinglist { $$ = MakeServerSpec( $2, $1 ); }
| settinglist environment { $$ = MakeServerSpec( $1, $2 ); }
| settinglist environment settinglist {
$$ = MakeServerSpec( $1, $2 );
AddServerSettings( $$, $3 );
}
| settinglist { $$ = MakeServerSpec( $1, NULL);}
;
/*
* Non-empty setting lists not permitted
*/
settinglist: setting { $$ = $1; }
| settinglist setting { $$ = AddVar( $1, $2 ); }
;
setting: settingname '=' value { $$ = MakeVar( $1, $3); }
| settingname value { yyerror( "Missing '='" ); }
| word {
char e[256];
snprintf( e, 256, "Unknown setting: %s", $1);
yyerror( e );
}
;
settingname: EXECUTE { $$ = strdup("Execute"); }
| OWNER { $$ = strdup("Owner"); }
| ENABLED { $$ = strdup("Enabled"); }
| ARGS { $$ = strdup("Args"); }
| UMASK { $$ = strdup("Umask"); }
| PREFIX { $$ = strdup("Prefix" ); }
| PRETTYNAMES { $$ = strdup("PrettyNames"); }
;
variable: var '=' value { $$ = MakeVar( $1, $3 ); }
;
var: word { $$ = $1; }
;
value: word
| STRING
| PATH
| NUMBER
;
word: WORD
# |
Change |
User |
Description |
Committed |
|
#1
|
16543 |
Matt Attaway |
Update P4DCTL with code from 15.2 and reorg files |
|
|