zonecfg_grammar.y revision 7e362f586af53d30ffc869a0ddc7d0f284ef8f82
%{
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include "zonecfg.h"
extern bool newline_terminated;
extern int num_prop_vals; /* # of property values */
/* yacc externals */
extern int yydebug;
extern void yyerror(char *s);
%}
%union {
int ival;
char *strval;
}
%%
{
if ($1 != NULL) {
free_cmd($1);
num_prop_vals = 0;
}
return (0);
}
{
if ($1 != NULL) {
free_cmd($1);
num_prop_vals = 0;
}
if (YYRECOVERING())
}
{
if (YYRECOVERING())
}
{
return (0);
}
{
}
{
cmd = $$;
$$->cmd_handler = &add_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &add_func;
$$->cmd_argc = 0;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &add_func;
$$->cmd_argc = 0;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $2;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &cancel_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &cancel_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &create_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &create_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &create_func;
$$->cmd_argc = 2;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &create_func;
$$->cmd_argc = 3;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &commit_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &commit_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &delete_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &delete_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &end_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &end_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &exit_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &exit_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &export_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &export_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &export_func;
$$->cmd_argc = 2;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &help_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &help_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_UNKNOWN;
$$->cmd_prop_nv_pairs = 0;
}
{
free($2);
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_ZONEPATH;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_AUTOBOOT;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = RT_POOL;
$$->cmd_prop_nv_pairs = 0;
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 2;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
| INFO resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
{
cmd = $$;
$$->cmd_handler = &info_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 3;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
}
{
}
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $2;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 2;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
| REMOVE resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
{
cmd = $$;
$$->cmd_handler = &remove_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 3;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &revert_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &revert_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
{
}
{
}
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 2;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
| SELECT resource_type property_name EQUAL property_value property_name EQUAL property_value property_name EQUAL property_value
{
cmd = $$;
$$->cmd_handler = &select_func;
$$->cmd_res_type = $2;
$$->cmd_prop_nv_pairs = 3;
$$->cmd_prop_name[0] = $3;
$$->cmd_property_ptr[0] = &property[0];
}
{
}
{
cmd = $$;
$$->cmd_handler = &set_func;
$$->cmd_prop_nv_pairs = 0;
$$->cmd_prop_name[0] = $2;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &set_func;
$$->cmd_prop_nv_pairs = 1;
$$->cmd_prop_name[0] = $2;
$$->cmd_property_ptr[0] = &property[0];
}
{
cmd = $$;
$$->cmd_handler = &verify_func;
$$->cmd_argc = 0;
}
{
cmd = $$;
$$->cmd_handler = &verify_func;
$$->cmd_argc = 1;
$$->cmd_argv[0] = $2;
}
| OPTIONS { $$ = PT_OPTIONS; }
| ZONEPATH { $$ = PT_ZONEPATH; }
| AUTOBOOT { $$ = PT_AUTOBOOT; }
| ADDRESS { $$ = PT_ADDRESS; }
| PHYSICAL { $$ = PT_PHYSICAL; }
/*
* The grammar builds data structures from the bottom up. Thus various
* strings are lexed into TOKENs or commands or resource or property values.
* Below is where the resource and property values are built up into more
* complex data structures.
*
* There are three kinds of properties: simple (single valued), complex
* (one or more name=value pairs) and list (concatenation of one or more
* simple or complex properties).
*
* So the property structure has a type which is one of these, and the
* corresponding _simple, _complex or _list is set to the corresponding
* lower-level data structure.
*/
{
}
}
{
}
}
{
}
/*
* One level lower, lists are made up of simple or complex values, so
* simple_prop_val and complex_prop_val fill in a list structure and
* insert it into the linked list which is built up. And because
* complex properties can have multiple name=value pairs, we keep
* track of them in another linked list.
*
* The complex and list structures for the linked lists are allocated
* below, and freed by recursive functions which are ultimately called
* by free_cmd(), which is called from the top-most "commands" part of
* the grammar.
*/
{
} else {
}
}
{
} else {
}
}
{
if (($$ = alloc_complex()) == NULL)
$$->cp_type = $1;
$$->cp_value = $3;
complex = $$;
}
{
if (($$ = alloc_complex()) == NULL)
$$->cp_type = $1;
$$->cp_value = $3;
complex = $$;
}
%%