/* A Bison parser, made by GNU Bison 3.8.2.  */

/* Bison implementation for Yacc-like parsers in C

   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
   Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */

/* As a special exception, you may create a larger work that contains
   part or all of the Bison parser skeleton and distribute that work
   under terms of your choice, so long as that work isn't itself a
   parser generator using the skeleton or a modified version thereof
   as a parser skeleton.  Alternatively, if you modify or redistribute
   the parser skeleton itself, you may (at your option) remove this
   special exception, which will cause the skeleton and the resulting
   Bison output files to be licensed under the GNU General Public
   License without this special exception.

   This special exception was added by the Free Software Foundation in
   version 2.2 of Bison.  */

/* C LALR(1) parser skeleton written by Richard Stallman, by
   simplifying the original so-called "semantic" parser.  */

/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
   especially those whose name start with YY_ or yy_.  They are
   private implementation details that can be changed or removed.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

/* Identify Bison output, and Bison version.  */
#define YYBISON 30802

/* Bison version string.  */
#define YYBISON_VERSION "3.8.2"

/* Skeleton name.  */
#define YYSKELETON_NAME "yacc.c"

/* Pure parsers.  */
#define YYPURE 0

/* Push parsers.  */
#define YYPUSH 0

/* Pull parsers.  */
#define YYPULL 1




/* First part of user prologue.  */
#line 17 "gram.y"

/*
 *  pmlogrewrite parser
 */
#include "pmapi.h"
#include "libpcp.h"
#include "logger.h"
#include <errno.h>
#include <assert.h>

#define PM_TEXT_TYPE_MASK (PM_TEXT_ONELINE | PM_TEXT_HELP)

static indomspec_t	*current_indomspec;
static int		current_star_indom;
static int		do_walk_indom;
static int		star_domain;

static metricspec_t	*current_metricspec;
static int		current_star_metric;
static int		star_cluster;
static int		do_walk_metric;
static int		output = OUTPUT_ALL;
static int		one_inst;
static char		*one_name;

static textspec_t	*current_textspec;
static int		do_walk_text;

static int		current_label_id;
static char *		current_label_name;
static char *		current_label_value;
static int		current_label_instance;
static char *		current_label_instance_name;
static labelspec_t	*current_labelspec;
static int		do_walk_label;

indomspec_t *
walk_indom(int mode)
{
    static indomspec_t	*ip;

    if (do_walk_indom) {
	if (mode == W_START)
	    ip = indom_root;
	else
	    ip = ip->i_next;
	while (ip != NULL && pmInDom_domain(ip->old_indom) != star_domain)
	    ip = ip->i_next;
    }
    else {
	if (mode == W_START)
	    ip = current_indomspec;
	else
	    ip = NULL;
    }

    return ip;
}

metricspec_t *
walk_metric(int mode, int flag, char *which, int dupok)
{
    static metricspec_t	*mp;

    if (do_walk_metric) {
	if (mode == W_START)
	    mp = metric_root;
	else
	    mp = mp->m_next;
	while (mp != NULL) {
	    if (pmID_domain(mp->old_desc.pmid) == star_domain &&
		(star_cluster == PM_ID_NULL || star_cluster == pmID_cluster(mp->old_desc.pmid)))
		break;
	    mp = mp->m_next;
	}
    }
    else {
	if (mode == W_START)
	    mp = current_metricspec;
	else
	    mp = NULL;
    }

    if (mp != NULL) {
	if (!dupok && (mp->flags & flag)) {
	    pmsprintf(mess, sizeof(mess), "Duplicate %s clause for metric %s", which, mp->old_name);
	    yyerror(mess);
	}
	if (flag != METRIC_DELETE) {
	    if (mp->flags & METRIC_DELETE) {
		pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted metric %s", which, mp->old_name);
		yyerror(mess);
	    }
	}
	else {
	    if (mp->flags & (~METRIC_DELETE)) {
		pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for metric %s", mp->old_name);
		yyerror(mess);
	    }
	}
    }

    return mp;
}

static const char *
textTypeStr(int type)
{
    switch(type)
	{
	case PM_TEXT_ONELINE:
	    return "one line";
	case PM_TEXT_HELP:
	    return "help";
	default:
	    break;
	}

    return "unknown";
}
 
textspec_t *
walk_text(int mode, int flag, char *which, int dupok)
{
    static textspec_t	*tp;

    if (do_walk_text) {
	if (mode == W_START)
	    tp = text_root;
	else
	    tp = tp->t_next;

	/* Only consider the active specs. */
	while (tp != NULL && (tp->flags & TEXT_ACTIVE) == 0)
	    tp = tp->t_next;
    }
    else {
	if (mode == W_START) {
	    tp = current_textspec;
	    if (tp)
		assert ((tp->flags & TEXT_ACTIVE));
	}
	else
	    tp = NULL;
    }

    if (tp != NULL) {
	tp->flags &= ~TEXT_ACTIVE;
	
	if (!dupok && (tp->flags & flag)) {
	    if ((tp->old_type & PM_TEXT_PMID)) {
		pmsprintf(mess, sizeof(mess), "Duplicate %s clause for %s text for metric %s",
			  which, textTypeStr(tp->old_type), pmIDStr(tp->old_id));
	    }
	    else {
		assert((tp->old_type & PM_TEXT_INDOM));
		pmsprintf(mess, sizeof(mess), "Duplicate %s clause for %s text for indom %s",
			  which, textTypeStr(tp->old_type), pmInDomStr(tp->old_id));
	    }
	    yyerror(mess);
	}
	if (flag != TEXT_DELETE) {
	    if (tp->flags & TEXT_DELETE) {
		if ((tp->old_type & PM_TEXT_PMID)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted %s text for metric %s",
			      which, textTypeStr(tp->old_type), pmIDStr(tp->old_id));
		}
		else {
		    assert((tp->old_type & PM_TEXT_INDOM));
		    pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted %s text for indom %s",
			      which, textTypeStr(tp->old_type), pmInDomStr(tp->old_id));
		}
		yyerror(mess);
	    }
	}
	else {
	    if (tp->flags & (~TEXT_DELETE)) {
		if ((tp->old_type & PM_TEXT_PMID)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for %s text for metric %s",
			      textTypeStr(tp->old_type), pmIDStr(tp->old_id));
		}
		else {
		    assert((tp->old_type & PM_TEXT_INDOM));
		    pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for %s text for indom %s",
			      textTypeStr(tp->old_type), pmInDomStr(tp->old_id));
		}
		yyerror(mess);
	    }
	}
    }

    return tp;
}

labelspec_t *
walk_label(int mode, int flag, char *which, int dupok)
{
    static labelspec_t	*lp;

    if (do_walk_label > 1) {
	if (mode == W_START)
	    lp = label_root;
	else
	    lp = lp->l_next;

	/* Only consider the active specs. */
	while (lp != NULL && (lp->flags & LABEL_ACTIVE) == 0)
	    lp = lp->l_next;
    }
    else {
	if (mode == W_START)
	    lp = current_labelspec;
	else
	    lp = NULL;
    }

    if (lp != NULL) {
	lp->flags &= ~LABEL_ACTIVE;
	
	if (!dupok && (lp->flags & flag)) {
	    if ((lp->old_type & PM_LABEL_CONTEXT)) {
		pmsprintf(mess, sizeof(mess), "Duplicate %s clause for context label",
			  which);
	    }
	    else if ((lp->old_type & PM_LABEL_DOMAIN)) {
		pmsprintf(mess, sizeof(mess), "Duplicate %s clause for label for domain %d",
			  which, pmID_domain(lp->old_id));
	    }
	    else if ((lp->old_type & PM_LABEL_CLUSTER)) {
		pmsprintf(mess, sizeof(mess), "Duplicate %s clause for label for cluster %d.%d",
			  which, pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
	    }
	    else if ((lp->old_type & PM_LABEL_ITEM)) {
		pmsprintf(mess, sizeof(mess), "Duplicate %s clause for label for metric %s",
			  which, pmIDStr(lp->old_id));
	    }
	    else if ((lp->old_type & PM_LABEL_INDOM)) {
		pmsprintf(mess, sizeof(mess), "Duplicate %s clause for label for indom %s",
			  which, pmInDomStr(lp->old_id));
	    }
	    else if ((lp->old_type & PM_LABEL_INSTANCES)) {
		pmsprintf(mess, sizeof(mess), "Duplicate %s clause for label for the instances of indom %s",
			  which, pmInDomStr(lp->old_id));
	    }
	    yyerror(mess);
	}
	if (flag != LABEL_DELETE) {
	    if (lp->flags & LABEL_DELETE) {
		if ((lp->old_type & PM_LABEL_CONTEXT)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted context label",
			      which);
		}
		else if ((lp->old_type & PM_LABEL_DOMAIN)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted label for domain %d",
			      which, pmID_domain(lp->old_id));
		}
		else if ((lp->old_type & PM_LABEL_CLUSTER)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted label for cluster %d.%d",
			      which, pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
		}
		else if ((lp->old_type & PM_LABEL_ITEM)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted label for metric %s",
			      which, pmIDStr(lp->old_id));
		}
		else if ((lp->old_type & PM_LABEL_INDOM)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted label for indom %s",
			      which, pmInDomStr(lp->old_id));
		}
		else if ((lp->old_type & PM_LABEL_INSTANCES)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting %s clause for deleted label for the instances of indom %s",
			      which, pmInDomStr(lp->old_id));
		}
		yyerror(mess);
	    }
	}
	else {
	    if (lp->flags & (~LABEL_DELETE)) {
		if ((lp->old_type & PM_LABEL_CONTEXT)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for context label");
		}
		else if ((lp->old_type & PM_LABEL_DOMAIN)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for label for domain %d",
			      pmID_domain(lp->old_id));
		}
		else if ((lp->old_type & PM_LABEL_CLUSTER)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for label for cluster %d.%d",
			      pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
		}
		else if ((lp->old_type & PM_LABEL_ITEM)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for label for metric %s",
			      pmIDStr(lp->old_id));
		}
		else if ((lp->old_type & PM_LABEL_INDOM)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for label for indom %s",
			      pmInDomStr(lp->old_id));
		}
		else if ((lp->old_type & PM_LABEL_INSTANCES)) {
		    pmsprintf(mess, sizeof(mess), "Conflicting delete and other clauses for label for the instances of indom %s",
			      pmInDomStr(lp->old_id));
		}
		yyerror(mess);
	    }
	}
    }

    return lp;
}

void
deactivate_labels(void)
{
    labelspec_t	*lp;
    for (lp = walk_label(W_START, LABEL_ACTIVE, "active", 0); lp != NULL; lp = walk_label(W_NEXT, 0, "", 0)) {
	lp->flags &= ~LABEL_ACTIVE;
    }
}

void
new_context_label()
{
    labelspec_t	*lp;
    int		sts;
    char	buf[PM_MAXLABELJSONLEN];

    /*
     * Ignore the other change specs which were identified and
     * add the new label to the generic context label change spec.
     * Search for an existing one first.
     */
    deactivate_labels();
    for (lp = label_root; lp != NULL; lp = lp->l_next) {
	if (lp->old_type == PM_LABEL_CONTEXT) {
	    assert (lp->old_id == PM_ID_NULL);
	    if (lp->old_label == NULL)
		break;
	}
    }

    /* Create one if none exists. */
    if (lp == NULL)
	lp = create_label(PM_LABEL_CONTEXT, PM_ID_NULL, 0, NULL, NULL);

    /* Add the new label to the label change spec. */
    pmsprintf(buf, sizeof(buf), "{%s:%s}",
	      current_label_name, current_label_value);
    if ((sts = __pmAddLabels(&lp->new_labels, buf, PM_LABEL_CONTEXT)) < 0) {
	pmsprintf(mess, sizeof(mess),
		  "Unable to add new context label %s: %s",
		  buf, pmErrStr(sts));
	yyerror(mess);
    }
    lp->new_labels->inst = 0;
    lp->flags |= LABEL_NEW;
}

void
new_domain_label(int domain)
{
    labelspec_t		*lp;
    int			sts;
    int			found = 0;
    __pmContext		*ctxp;
    __pmHashCtl		*hcp;
    __pmHashNode	*node;
    char		buf[PM_MAXLABELJSONLEN];

    /*
     * Ignore the change specs which were previously identified and instead
     * search the metadata for metrics in the given domain.
     * Create or re-use the change record for each one found. 
     */
    deactivate_labels();

    ctxp = __pmHandleToPtr(pmWhichContext());
    assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
    PM_UNLOCK(ctxp->c_lock);

    /* Prepare the JSON for the new label. */
    pmsprintf(buf, sizeof(buf), "{%s:%s}",
	      current_label_name, current_label_value);

    hcp = &ctxp->c_archctl->ac_log->hashpmid;
    for (node = __pmHashWalk(hcp, PM_HASH_WALK_START);
	 node != NULL;
	 node = __pmHashWalk(hcp, PM_HASH_WALK_NEXT)) {
	if (pmID_domain(node->key) != domain)
	    continue;

	/*
	 * A metric in this domain exists.
	 * Add the new label to the generic label change spec for this
	 * domain. Search for an existing one first.
	 */
	found = 1;
	for (lp = label_root; lp != NULL; lp = lp->l_next) {
	    if (lp->old_type != PM_LABEL_DOMAIN)
		continue;
	    if (lp->old_id != domain)
		continue;
	    if (lp->old_label == NULL)
		break;
	}

	/* Create one if none exists. */
	if (lp == NULL)
	    lp = create_label(PM_LABEL_DOMAIN, domain, 0, NULL, NULL);

	/* Add the new label to the label change spec. */
	if ((sts = __pmAddLabels(&lp->new_labels, buf, PM_LABEL_DOMAIN)) < 0) {
	    pmsprintf(mess, sizeof(mess),
		      "Unable to add new domain label %s: %s",
		      buf, pmErrStr(sts));
	    yyerror(mess);
	}
	lp->new_labels->inst = 0;
	lp->flags |= LABEL_NEW;

	/* We only need to find one metric in the specified domain. */
	break;
    }

    /* Did we find any clusters matching the spec? */
    if (! found) {
	pmsprintf(mess, sizeof(mess),
		  "No matching domain for new label %s", buf);
	yywarn(mess);
    }
}

void
new_cluster_label(int cluster)
{
    labelspec_t		*lp;
    int			sts;
    int			found = 0;
    __pmContext		*ctxp;
    __pmHashCtl		*hcp;
    __pmHashNode	*node;
    char		buf[PM_MAXLABELJSONLEN] = "";

    /*
     * Ignore the change specs which were previously identified and instead
     * search the metadata for metrics in the given domain.
     * Create or re-use the change record for each one found. 
     */
    deactivate_labels();

    ctxp = __pmHandleToPtr(pmWhichContext());
    assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
    PM_UNLOCK(ctxp->c_lock);

    /* Prepare the JSON for the new label. */
    pmsprintf(buf, sizeof(buf), "{%s:%s}",
	      current_label_name, current_label_value);

    hcp = &ctxp->c_archctl->ac_log->hashpmid;
    for (node = __pmHashWalk(hcp, PM_HASH_WALK_START);
	 node != NULL;
	 node = __pmHashWalk(hcp, PM_HASH_WALK_NEXT)) {
	if (pmID_domain(node->key) != pmID_domain(cluster))
	    continue;
	if (! current_star_metric && 
	    pmID_cluster(node->key) != pmID_cluster(cluster))
	    continue;

	/*
	 * A metric in this cluster exists.
	 * Add the new label to the generic label change spec for the
	 * identified cluster. Search for an existing one first.
	 */
	found = 1;
	for (lp = label_root; lp != NULL; lp = lp->l_next) {
	    if (lp->old_type != PM_LABEL_CLUSTER)
		continue;
	    if (pmID_domain(lp->old_id) != pmID_domain((pmID)(node->key)))
		continue;
	    if (pmID_cluster(lp->old_id) != pmID_cluster((pmID)(node->key)))
		continue;
	    if (lp->old_label == NULL)
		break;
	}

	if (lp == NULL) {
	    pmID current_cluster =
		pmID_build(pmID_domain(node->key), pmID_cluster(node->key), 0);
	    lp = create_label(PM_LABEL_CLUSTER, current_cluster, 0, NULL, NULL);
	}

	/* Add the new label to the label change spec. */
	if ((sts = __pmAddLabels(&lp->new_labels, buf, PM_LABEL_CLUSTER)) < 0) {
	    pmsprintf(mess, sizeof(mess),
		      "Unable to add new cluster label %s: %s",
		      buf, pmErrStr(sts));
	    yyerror(mess);
	}
	lp->new_labels->inst = 0;
	lp->flags |= LABEL_NEW;

	/* Do we need to look for more clusters? */
	if (! current_star_metric)
	    break;
    }

    /* Did we find any clusters matching the spec? */
    if (! found) {
	pmsprintf(mess, sizeof(mess),
		  "No matching cluster for new label %s", buf);
	yywarn(mess);
    }
}

void
new_item_label(int item)
{
    labelspec_t		*lp;
    int			sts;
    int			found = 0;
    __pmContext		*ctxp;
    __pmHashCtl		*hcp;
    __pmHashNode	*node;
    char		buf[PM_MAXLABELJSONLEN] = "";

    /*
     * Ignore the change specs which were previously identified and instead
     * search the metadata for metrics in the given domain.
     * Create or re-use the change record for each one found. 
     */
    deactivate_labels();

    ctxp = __pmHandleToPtr(pmWhichContext());
    assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
    PM_UNLOCK(ctxp->c_lock);

    /* Prepare the JSON for the new label. */
    pmsprintf(buf, sizeof(buf), "{%s:%s}",
	      current_label_name, current_label_value);

    hcp = &ctxp->c_archctl->ac_log->hashpmid;
    for (node = __pmHashWalk(hcp, PM_HASH_WALK_START);
	 node != NULL;
	 node = __pmHashWalk(hcp, PM_HASH_WALK_NEXT)) {
	if (pmID_domain(node->key) != pmID_domain(item))
	    continue;
	if (current_star_metric < 2) {
	    if (pmID_cluster(node->key) != pmID_cluster(item))
		continue;
	    if (! current_star_metric && (pmID)(node->key) != (pmID)item)
		continue;
	}

	/*
	 * A metric with this pmID exists.
	 * Add the new label to the generic label change spec for the
	 * identified item. Search for an existing one first.
	 */
	found = 1;
	for (lp = label_root; lp != NULL; lp = lp->l_next) {
	    if (lp->old_type != PM_LABEL_ITEM)
		continue;
	    if ((pmID)(lp->old_id) != (pmID)(node->key))
		continue;
	    if (lp->old_label == NULL)
		break;
	}

	if (lp == NULL)
	    lp = create_label(PM_LABEL_ITEM, (pmID)node->key, 0, NULL, NULL);

	/* Add the new label to the label change spec. */
	if ((sts = __pmAddLabels(&lp->new_labels, buf, PM_LABEL_ITEM)) < 0) {
	    pmsprintf(mess, sizeof(mess),
		      "Unable to add new metric item label %s: %s",
		      buf, pmErrStr(sts));
	    yyerror(mess);
	}
	lp->new_labels->inst = 0;
	lp->flags |= LABEL_NEW;

	/* Do we need to look for more items? */
	if (! current_star_metric)
	    break;
    }

    /* Did we find any items matching the spec? */
    if (! found) {
	pmsprintf(mess, sizeof(mess),
		  "No matching metric for new label %s", buf);
	yywarn(mess);
    }
}

void
new_indom_label(int indom)
{
    labelspec_t		*lp;
    int			sts;
    int			found = 0;
    __pmContext		*ctxp;
    __pmHashCtl		*hcp;
    __pmHashNode	*node;
    char		buf[PM_MAXLABELJSONLEN] = "";

    /*
     * Ignore the change specs which were previously identified and instead
     * search the metadata for metrics in the given domain.
     * Create or re-use the change record for each one found. 
     */
    deactivate_labels();

    ctxp = __pmHandleToPtr(pmWhichContext());
    assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
    PM_UNLOCK(ctxp->c_lock);

    /* Prepare the JSON for the new label. */
    pmsprintf(buf, sizeof(buf), "{%s:%s}",
	      current_label_name, current_label_value);

    hcp = &ctxp->c_archctl->ac_log->hashindom;
    for (node = __pmHashWalk(hcp, PM_HASH_WALK_START);
	 node != NULL;
	 node = __pmHashWalk(hcp, PM_HASH_WALK_NEXT)) {
	if (pmInDom_domain(node->key) != pmInDom_domain(indom))
	    continue;
	if (! current_star_indom && 
	    pmInDom_serial(node->key) != pmInDom_serial(indom))
	    continue;

	/*
	 * A metric in this indom exists.
	 * Add the new label to the generic label change spec for the
	 * identified indom. Search for an existing one first.
	 */
	found = 1;
	for (lp = label_root; lp != NULL; lp = lp->l_next) {
	    if (lp->old_type != PM_LABEL_INDOM)
		continue;
	    if (pmInDom_domain(lp->old_id) != pmInDom_domain((pmInDom)(node->key)))
		continue;
	    if (pmInDom_serial(lp->old_id) != pmInDom_serial((pmInDom)(node->key)))
		continue;
	    if (lp->old_instance != -1)
		continue;
	    if (lp->old_label == NULL)
		break;
	}

	if (lp == NULL) {
	    pmInDom current_indom =
		pmInDom_build(pmInDom_domain(node->key), pmInDom_serial(node->key));
	    lp = create_label(PM_LABEL_INDOM, current_indom, 0, NULL, NULL);
	}

	/* Add the new label to the label change spec. */
	if ((sts = __pmAddLabels(&lp->new_labels, buf, PM_LABEL_INDOM)) < 0) {
	    pmsprintf(mess, sizeof(mess),
		      "Unable to add new indom label %s: %s",
		      buf, pmErrStr(sts));
	    yyerror(mess);
	}
	lp->new_labels->inst = 0;
	lp->flags |= LABEL_NEW;

	/* Do we need to look for more indoms? */
	if (! current_star_indom)
	    break;
    }

    /* Did we find any indoms matching the spec? */
    if (! found) {
	pmsprintf(mess, sizeof(mess),
		  "No matching indom for new label %s", buf);
	yywarn(mess);
    }
}

void
new_indom_instance_label(int indom)
{
    labelspec_t		*lp;
    int			sts;
    int			found = 0;
    __pmContext		*ctxp;
    __pmHashCtl		*hcp;
    __pmHashNode	*node;
    __pmLogInDom	*idp;
    char		buf[PM_MAXLABELJSONLEN] = "";

    /*
     * Ignore the change specs which were previously identified and instead
     * search the metadata for metrics in the given domain.
     * Create or re-use the change record for each one found. 
     */
    deactivate_labels();

    ctxp = __pmHandleToPtr(pmWhichContext());
    assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
    PM_UNLOCK(ctxp->c_lock);

    /* Prepare the JSON for the new label. */
    pmsprintf(buf, sizeof(buf), "{%s:%s}",
	      current_label_name, current_label_value);

    hcp = &ctxp->c_archctl->ac_log->hashindom;
    for (node = __pmHashWalk(hcp, PM_HASH_WALK_START);
	 node != NULL;
	 node = __pmHashWalk(hcp, PM_HASH_WALK_NEXT)) {
	if (pmInDom_domain(node->key) != pmInDom_domain(indom))
	    continue;
	if (! current_star_indom && 
	    pmInDom_serial(node->key) != pmInDom_serial(indom))
	    continue;

	/*
	 * A metric in this indom exists.
	 * Add the new label to the generic label change specs for the
	 * identified indom instances. Search for existing ones first.
	 */
	for (idp = (__pmLogInDom *)node->data; idp != NULL; idp = idp->next) {
	    int indom_ix;
	    for (indom_ix = 0; indom_ix < idp->numinst; ++indom_ix) {
		int instance = idp->instlist[indom_ix];
		if (current_label_instance != -1 && instance != current_label_instance)
		    continue;
		found = 1;
		for (lp = label_root; lp != NULL; lp = lp->l_next) {
		    if (lp->old_type != PM_LABEL_INSTANCES)
			continue;
		    if (pmInDom_domain(lp->old_id) != pmInDom_domain((pmInDom)(node->key)))
			continue;
		    if (pmInDom_serial(lp->old_id) != pmInDom_serial((pmInDom)(node->key)))
			continue;
		    if (lp->old_instance != instance)
			continue;
		    if (lp->old_label == NULL)
			break;
		}

		if (lp == NULL) {
		    pmInDom current_indom =
			pmInDom_build(pmInDom_domain(node->key), pmInDom_serial(node->key));
		    lp = create_label(PM_LABEL_INSTANCES, current_indom,
				      instance, NULL, NULL);
		}

		/* Add the new label to the label change spec. */
		if ((sts = __pmAddLabels(&lp->new_labels, buf, PM_LABEL_INSTANCES)) < 0) {
		    pmsprintf(mess, sizeof(mess),
			      "Unable to add new indom instance label %s: %s",
			      buf, pmErrStr(sts));
		    yyerror(mess);
		}
		lp->new_labels->inst = instance;
		lp->flags |= LABEL_NEW;
	    }
	}

	/* Do we need to look for more indoms? */
	if (! current_star_indom)
	    break;
    }

    /* Did we find any indom instances matching the spec? */
    if (! found) {
	pmsprintf(mess, sizeof(mess),
		  "No matching indom instance for new label %s", buf);
	yywarn(mess);
    }
}


#line 877 "gram.tab.c"

# ifndef YY_CAST
#  ifdef __cplusplus
#   define YY_CAST(Type, Val) static_cast<Type> (Val)
#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
#  else
#   define YY_CAST(Type, Val) ((Type) (Val))
#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
#  endif
# endif
# ifndef YY_NULLPTR
#  if defined __cplusplus
#   if 201103L <= __cplusplus
#    define YY_NULLPTR nullptr
#   else
#    define YY_NULLPTR 0
#   endif
#  else
#   define YY_NULLPTR ((void*)0)
#  endif
# endif

#include "gram.tab.h"
/* Symbol kind.  */
enum yysymbol_kind_t
{
  YYSYMBOL_YYEMPTY = -2,
  YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
  YYSYMBOL_YYerror = 1,                    /* error  */
  YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
  YYSYMBOL_TOK_LBRACE = 3,                 /* TOK_LBRACE  */
  YYSYMBOL_TOK_RBRACE = 4,                 /* TOK_RBRACE  */
  YYSYMBOL_TOK_PLUS = 5,                   /* TOK_PLUS  */
  YYSYMBOL_TOK_MINUS = 6,                  /* TOK_MINUS  */
  YYSYMBOL_TOK_COLON = 7,                  /* TOK_COLON  */
  YYSYMBOL_TOK_COMMA = 8,                  /* TOK_COMMA  */
  YYSYMBOL_TOK_LPAREN = 9,                 /* TOK_LPAREN  */
  YYSYMBOL_TOK_RPAREN = 10,                /* TOK_RPAREN  */
  YYSYMBOL_TOK_ASSIGN = 11,                /* TOK_ASSIGN  */
  YYSYMBOL_TOK_GLOBAL = 12,                /* TOK_GLOBAL  */
  YYSYMBOL_TOK_INDOM = 13,                 /* TOK_INDOM  */
  YYSYMBOL_TOK_DUPLICATE = 14,             /* TOK_DUPLICATE  */
  YYSYMBOL_TOK_METRIC = 15,                /* TOK_METRIC  */
  YYSYMBOL_TOK_HOSTNAME = 16,              /* TOK_HOSTNAME  */
  YYSYMBOL_TOK_TIMEZONE = 17,              /* TOK_TIMEZONE  */
  YYSYMBOL_TOK_ZONEINFO = 18,              /* TOK_ZONEINFO  */
  YYSYMBOL_TOK_FEATURES = 19,              /* TOK_FEATURES  */
  YYSYMBOL_TOK_TIME = 20,                  /* TOK_TIME  */
  YYSYMBOL_TOK_NAME = 21,                  /* TOK_NAME  */
  YYSYMBOL_TOK_DUPOK = 22,                 /* TOK_DUPOK  */
  YYSYMBOL_TOK_INST = 23,                  /* TOK_INST  */
  YYSYMBOL_TOK_INAME = 24,                 /* TOK_INAME  */
  YYSYMBOL_TOK_DELETE = 25,                /* TOK_DELETE  */
  YYSYMBOL_TOK_REDACT = 26,                /* TOK_REDACT  */
  YYSYMBOL_TOK_REPLACE = 27,               /* TOK_REPLACE  */
  YYSYMBOL_TOK_PMID = 28,                  /* TOK_PMID  */
  YYSYMBOL_TOK_NULL_INT = 29,              /* TOK_NULL_INT  */
  YYSYMBOL_TOK_TYPE = 30,                  /* TOK_TYPE  */
  YYSYMBOL_TOK_IF = 31,                    /* TOK_IF  */
  YYSYMBOL_TOK_SEM = 32,                   /* TOK_SEM  */
  YYSYMBOL_TOK_UNITS = 33,                 /* TOK_UNITS  */
  YYSYMBOL_TOK_EXTRAUNITS = 34,            /* TOK_EXTRAUNITS  */
  YYSYMBOL_TOK_METRIC_VALUE = 35,          /* TOK_METRIC_VALUE  */
  YYSYMBOL_TOK_OUTPUT = 36,                /* TOK_OUTPUT  */
  YYSYMBOL_TOK_RESCALE = 37,               /* TOK_RESCALE  */
  YYSYMBOL_TOK_TEXT = 38,                  /* TOK_TEXT  */
  YYSYMBOL_TOK_ONELINE = 39,               /* TOK_ONELINE  */
  YYSYMBOL_TOK_HELP = 40,                  /* TOK_HELP  */
  YYSYMBOL_TOK_TEXT_STAR = 41,             /* TOK_TEXT_STAR  */
  YYSYMBOL_TOK_LABEL = 42,                 /* TOK_LABEL  */
  YYSYMBOL_TOK_CONTEXT = 43,               /* TOK_CONTEXT  */
  YYSYMBOL_TOK_LABEL_STAR = 44,            /* TOK_LABEL_STAR  */
  YYSYMBOL_TOK_DOMAIN = 45,                /* TOK_DOMAIN  */
  YYSYMBOL_TOK_CLUSTER = 46,               /* TOK_CLUSTER  */
  YYSYMBOL_TOK_ITEM = 47,                  /* TOK_ITEM  */
  YYSYMBOL_TOK_INSTANCES = 48,             /* TOK_INSTANCES  */
  YYSYMBOL_TOK_INSTANCE = 49,              /* TOK_INSTANCE  */
  YYSYMBOL_TOK_NEW = 50,                   /* TOK_NEW  */
  YYSYMBOL_TOK_VALUE = 51,                 /* TOK_VALUE  */
  YYSYMBOL_TOK_BITS = 52,                  /* TOK_BITS  */
  YYSYMBOL_TOK_GNAME = 53,                 /* TOK_GNAME  */
  YYSYMBOL_TOK_NUMBER = 54,                /* TOK_NUMBER  */
  YYSYMBOL_TOK_STRING = 55,                /* TOK_STRING  */
  YYSYMBOL_TOK_TEXT_STRING = 56,           /* TOK_TEXT_STRING  */
  YYSYMBOL_TOK_HNAME = 57,                 /* TOK_HNAME  */
  YYSYMBOL_TOK_FLOAT = 58,                 /* TOK_FLOAT  */
  YYSYMBOL_TOK_PATTERN = 59,               /* TOK_PATTERN  */
  YYSYMBOL_TOK_MACRO = 60,                 /* TOK_MACRO  */
  YYSYMBOL_TOK_JSON_STRING = 61,           /* TOK_JSON_STRING  */
  YYSYMBOL_TOK_JSON_NUMBER = 62,           /* TOK_JSON_NUMBER  */
  YYSYMBOL_TOK_JSON_TRUE = 63,             /* TOK_JSON_TRUE  */
  YYSYMBOL_TOK_JSON_FALSE = 64,            /* TOK_JSON_FALSE  */
  YYSYMBOL_TOK_JSON_NULL = 65,             /* TOK_JSON_NULL  */
  YYSYMBOL_TOK_INDOM_STAR = 66,            /* TOK_INDOM_STAR  */
  YYSYMBOL_TOK_PMID_INT = 67,              /* TOK_PMID_INT  */
  YYSYMBOL_TOK_PMID_STAR = 68,             /* TOK_PMID_STAR  */
  YYSYMBOL_TOK_TYPE_NAME = 69,             /* TOK_TYPE_NAME  */
  YYSYMBOL_TOK_SEM_NAME = 70,              /* TOK_SEM_NAME  */
  YYSYMBOL_TOK_SPACE_NAME = 71,            /* TOK_SPACE_NAME  */
  YYSYMBOL_TOK_TIME_NAME = 72,             /* TOK_TIME_NAME  */
  YYSYMBOL_TOK_COUNT_NAME = 73,            /* TOK_COUNT_NAME  */
  YYSYMBOL_TOK_OUTPUT_TYPE = 74,           /* TOK_OUTPUT_TYPE  */
  YYSYMBOL_YYACCEPT = 75,                  /* $accept  */
  YYSYMBOL_config = 76,                    /* config  */
  YYSYMBOL_speclist = 77,                  /* speclist  */
  YYSYMBOL_spec = 78,                      /* spec  */
  YYSYMBOL_globalspec = 79,                /* globalspec  */
  YYSYMBOL_globaloptlist = 80,             /* globaloptlist  */
  YYSYMBOL_globalopt = 81,                 /* globalopt  */
  YYSYMBOL_feature_bits = 82,              /* feature_bits  */
  YYSYMBOL_bits_list = 83,                 /* bits_list  */
  YYSYMBOL_hname = 84,                     /* hname  */
  YYSYMBOL_signnumber = 85,                /* signnumber  */
  YYSYMBOL_number = 86,                    /* number  */
  YYSYMBOL_float = 87,                     /* float  */
  YYSYMBOL_signtime = 88,                  /* signtime  */
  YYSYMBOL_time = 89,                      /* time  */
  YYSYMBOL_indomspec = 90,                 /* indomspec  */
  YYSYMBOL_91_1 = 91,                      /* $@1  */
  YYSYMBOL_indom_int = 92,                 /* indom_int  */
  YYSYMBOL_optindomopt = 93,               /* optindomopt  */
  YYSYMBOL_indomoptlist = 94,              /* indomoptlist  */
  YYSYMBOL_indomopt = 95,                  /* indomopt  */
  YYSYMBOL_duplicateopt = 96,              /* duplicateopt  */
  YYSYMBOL_metricspec = 97,                /* metricspec  */
  YYSYMBOL_98_2 = 98,                      /* $@2  */
  YYSYMBOL_pmid_or_name = 99,              /* pmid_or_name  */
  YYSYMBOL_pmid_int = 100,                 /* pmid_int  */
  YYSYMBOL_optmetricoptlist = 101,         /* optmetricoptlist  */
  YYSYMBOL_metricoptlist = 102,            /* metricoptlist  */
  YYSYMBOL_metricopt = 103,                /* metricopt  */
  YYSYMBOL_optreplace = 104,               /* optreplace  */
  YYSYMBOL_null_or_indom = 105,            /* null_or_indom  */
  YYSYMBOL_pick = 106,                     /* pick  */
  YYSYMBOL_rescaleopt = 107,               /* rescaleopt  */
  YYSYMBOL_textspec = 108,                 /* textspec  */
  YYSYMBOL_textmetricorindomspec = 109,    /* textmetricorindomspec  */
  YYSYMBOL_textmetricspec = 110,           /* textmetricspec  */
  YYSYMBOL_111_3 = 111,                    /* $@3  */
  YYSYMBOL_opttexttypes = 112,             /* opttexttypes  */
  YYSYMBOL_texttypes = 113,                /* texttypes  */
  YYSYMBOL_texttype = 114,                 /* texttype  */
  YYSYMBOL_opttextvalue = 115,             /* opttextvalue  */
  YYSYMBOL_opttextmetricoptlist = 116,     /* opttextmetricoptlist  */
  YYSYMBOL_textmetricoptlist = 117,        /* textmetricoptlist  */
  YYSYMBOL_textmetricopt = 118,            /* textmetricopt  */
  YYSYMBOL_textstring = 119,               /* textstring  */
  YYSYMBOL_pattern = 120,                  /* pattern  */
  YYSYMBOL_replacement = 121,              /* replacement  */
  YYSYMBOL_textindomspec = 122,            /* textindomspec  */
  YYSYMBOL_123_4 = 123,                    /* $@4  */
  YYSYMBOL_opttextindomoptlist = 124,      /* opttextindomoptlist  */
  YYSYMBOL_textindomoptlist = 125,         /* textindomoptlist  */
  YYSYMBOL_textindomopt = 126,             /* textindomopt  */
  YYSYMBOL_labelspec = 127,                /* labelspec  */
  YYSYMBOL_labelcontextormetricorindomspec = 128, /* labelcontextormetricorindomspec  */
  YYSYMBOL_labelcontextspec = 129,         /* labelcontextspec  */
  YYSYMBOL_130_5 = 130,                    /* $@5  */
  YYSYMBOL_optlabeldetails = 131,          /* optlabeldetails  */
  YYSYMBOL_jsonname = 132,                 /* jsonname  */
  YYSYMBOL_optlabelvalue = 133,            /* optlabelvalue  */
  YYSYMBOL_jsonvalue = 134,                /* jsonvalue  */
  YYSYMBOL_jsonnumber = 135,               /* jsonnumber  */
  YYSYMBOL_optlabelcontextoptlist = 136,   /* optlabelcontextoptlist  */
  YYSYMBOL_labelcontextoptlist = 137,      /* labelcontextoptlist  */
  YYSYMBOL_labelcontextopt = 138,          /* labelcontextopt  */
  YYSYMBOL_newlabelspec = 139,             /* newlabelspec  */
  YYSYMBOL_labeldomainspec = 140,          /* labeldomainspec  */
  YYSYMBOL_141_6 = 141,                    /* $@6  */
  YYSYMBOL_pmid_domain = 142,              /* pmid_domain  */
  YYSYMBOL_optlabeldomainoptlist = 143,    /* optlabeldomainoptlist  */
  YYSYMBOL_labeldomainoptlist = 144,       /* labeldomainoptlist  */
  YYSYMBOL_labeldomainopt = 145,           /* labeldomainopt  */
  YYSYMBOL_labelclusterspec = 146,         /* labelclusterspec  */
  YYSYMBOL_147_7 = 147,                    /* $@7  */
  YYSYMBOL_pmid_cluster = 148,             /* pmid_cluster  */
  YYSYMBOL_optlabelclusteroptlist = 149,   /* optlabelclusteroptlist  */
  YYSYMBOL_labelclusteroptlist = 150,      /* labelclusteroptlist  */
  YYSYMBOL_labelclusteropt = 151,          /* labelclusteropt  */
  YYSYMBOL_labelitemspec = 152,            /* labelitemspec  */
  YYSYMBOL_153_8 = 153,                    /* $@8  */
  YYSYMBOL_optlabelitemoptlist = 154,      /* optlabelitemoptlist  */
  YYSYMBOL_labelitemoptlist = 155,         /* labelitemoptlist  */
  YYSYMBOL_labelitemopt = 156,             /* labelitemopt  */
  YYSYMBOL_labelindomspec = 157,           /* labelindomspec  */
  YYSYMBOL_158_9 = 158,                    /* $@9  */
  YYSYMBOL_optlabelindomoptlist = 159,     /* optlabelindomoptlist  */
  YYSYMBOL_labelindomoptlist = 160,        /* labelindomoptlist  */
  YYSYMBOL_labelindomopt = 161,            /* labelindomopt  */
  YYSYMBOL_labelinstancesspec = 162,       /* labelinstancesspec  */
  YYSYMBOL_163_10 = 163,                   /* $@10  */
  YYSYMBOL_optinstancelabeldetails = 164,  /* optinstancelabeldetails  */
  YYSYMBOL_optlabelinstancesoptlist = 165, /* optlabelinstancesoptlist  */
  YYSYMBOL_labelinstancesoptlist = 166,    /* labelinstancesoptlist  */
  YYSYMBOL_labelinstancesopt = 167         /* labelinstancesopt  */
};
typedef enum yysymbol_kind_t yysymbol_kind_t;




#ifdef short
# undef short
#endif

/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
   <limits.h> and (if available) <stdint.h> are included
   so that the code can choose integer types of a good width.  */

#ifndef __PTRDIFF_MAX__
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
#  define YY_STDINT_H
# endif
#endif

/* Narrow types that promote to a signed type and that can represent a
   signed or unsigned integer of at least N bits.  In tables they can
   save space and decrease cache pressure.  Promoting to a signed type
   helps avoid bugs in integer arithmetic.  */

#ifdef __INT_LEAST8_MAX__
typedef __INT_LEAST8_TYPE__ yytype_int8;
#elif defined YY_STDINT_H
typedef int_least8_t yytype_int8;
#else
typedef signed char yytype_int8;
#endif

#ifdef __INT_LEAST16_MAX__
typedef __INT_LEAST16_TYPE__ yytype_int16;
#elif defined YY_STDINT_H
typedef int_least16_t yytype_int16;
#else
typedef short yytype_int16;
#endif

/* Work around bug in HP-UX 11.23, which defines these macros
   incorrectly for preprocessor constants.  This workaround can likely
   be removed in 2023, as HPE has promised support for HP-UX 11.23
   (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
   <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>.  */
#ifdef __hpux
# undef UINT_LEAST8_MAX
# undef UINT_LEAST16_MAX
# define UINT_LEAST8_MAX 255
# define UINT_LEAST16_MAX 65535
#endif

#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
       && UINT_LEAST8_MAX <= INT_MAX)
typedef uint_least8_t yytype_uint8;
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
typedef unsigned char yytype_uint8;
#else
typedef short yytype_uint8;
#endif

#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
       && UINT_LEAST16_MAX <= INT_MAX)
typedef uint_least16_t yytype_uint16;
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
typedef unsigned short yytype_uint16;
#else
typedef int yytype_uint16;
#endif

#ifndef YYPTRDIFF_T
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
#  define YYPTRDIFF_T __PTRDIFF_TYPE__
#  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
# elif defined PTRDIFF_MAX
#  ifndef ptrdiff_t
#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  endif
#  define YYPTRDIFF_T ptrdiff_t
#  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
# else
#  define YYPTRDIFF_T long
#  define YYPTRDIFF_MAXIMUM LONG_MAX
# endif
#endif

#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
#  define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
#  define YYSIZE_T size_t
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# else
#  define YYSIZE_T unsigned
# endif
#endif

#define YYSIZE_MAXIMUM                                  \
  YY_CAST (YYPTRDIFF_T,                                 \
           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
            ? YYPTRDIFF_MAXIMUM                         \
            : YY_CAST (YYSIZE_T, -1)))

#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))


/* Stored state numbers (used for stacks). */
typedef yytype_int16 yy_state_t;

/* State numbers in computations.  */
typedef int yy_state_fast_t;

#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
#  if ENABLE_NLS
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
#  endif
# endif
# ifndef YY_
#  define YY_(Msgid) Msgid
# endif
#endif


#ifndef YY_ATTRIBUTE_PURE
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
#  define YY_ATTRIBUTE_PURE
# endif
#endif

#ifndef YY_ATTRIBUTE_UNUSED
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# else
#  define YY_ATTRIBUTE_UNUSED
# endif
#endif

/* Suppress unused-variable warnings by "using" E.  */
#if ! defined lint || defined __GNUC__
# define YY_USE(E) ((void) (E))
#else
# define YY_USE(E) /* empty */
#endif

/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
    _Pragma ("GCC diagnostic push")                                     \
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
# else
#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
    _Pragma ("GCC diagnostic push")                                     \
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# endif
# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
    _Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif

#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
# define YY_IGNORE_USELESS_CAST_BEGIN                          \
    _Pragma ("GCC diagnostic push")                            \
    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END            \
    _Pragma ("GCC diagnostic pop")
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif


#define YY_ASSERT(E) ((void) (0 && (E)))

#if !defined yyoverflow

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# ifdef YYSTACK_USE_ALLOCA
#  if YYSTACK_USE_ALLOCA
#   ifdef __GNUC__
#    define YYSTACK_ALLOC __builtin_alloca
#   elif defined __BUILTIN_VA_ARG_INCR
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
#   elif defined _AIX
#    define YYSTACK_ALLOC __alloca
#   elif defined _MSC_VER
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
#    define alloca _alloca
#   else
#    define YYSTACK_ALLOC alloca
#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
#     ifndef EXIT_SUCCESS
#      define EXIT_SUCCESS 0
#     endif
#    endif
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's 'empty if-body' warning.  */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
#  ifndef YYSTACK_ALLOC_MAXIMUM
    /* The OS might guarantee only one guard page at the bottom of the stack,
       and a page size can be as small as 4096 bytes.  So we cannot safely
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
       to allow for a few compiler-allocated temporary stack slots.  */
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
#  endif
# else
#  define YYSTACK_ALLOC YYMALLOC
#  define YYSTACK_FREE YYFREE
#  ifndef YYSTACK_ALLOC_MAXIMUM
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
#  endif
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
       && ! ((defined YYMALLOC || defined malloc) \
             && (defined YYFREE || defined free)))
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   ifndef EXIT_SUCCESS
#    define EXIT_SUCCESS 0
#   endif
#  endif
#  ifndef YYMALLOC
#   define YYMALLOC malloc
#   if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
#  ifndef YYFREE
#   define YYFREE free
#   if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
# endif
#endif /* !defined yyoverflow */

#if (! defined yyoverflow \
     && (! defined __cplusplus \
         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  yy_state_t yyss_alloc;
  YYSTYPE yyvs_alloc;
};

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# define YYSTACK_BYTES(N) \
     ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
      + YYSTACK_GAP_MAXIMUM)

# define YYCOPY_NEEDED 1

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
    do                                                                  \
      {                                                                 \
        YYPTRDIFF_T yynewbytes;                                         \
        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
        Stack = &yyptr->Stack_alloc;                                    \
        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
      }                                                                 \
    while (0)

#endif

#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if defined __GNUC__ && 1 < __GNUC__
#   define YYCOPY(Dst, Src, Count) \
      __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
#  else
#   define YYCOPY(Dst, Src, Count)              \
      do                                        \
        {                                       \
          YYPTRDIFF_T yyi;                      \
          for (yyi = 0; yyi < (Count); yyi++)   \
            (Dst)[yyi] = (Src)[yyi];            \
        }                                       \
      while (0)
#  endif
# endif
#endif /* !YYCOPY_NEEDED */

/* YYFINAL -- State number of the termination state.  */
#define YYFINAL  41
/* YYLAST -- Last index in YYTABLE.  */
#define YYLAST   377

/* YYNTOKENS -- Number of terminals.  */
#define YYNTOKENS  75
/* YYNNTS -- Number of nonterminals.  */
#define YYNNTS  93
/* YYNRULES -- Number of rules.  */
#define YYNRULES  264
/* YYNSTATES -- Number of states.  */
#define YYNSTATES  395

/* YYMAXUTOK -- Last valid token kind.  */
#define YYMAXUTOK   329


/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
   as returned by yylex, with out-of-bounds checking.  */
#define YYTRANSLATE(YYX)                                \
  (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
   ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
   : YYSYMBOL_YYUNDEF)

/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
   as returned by yylex.  */
static const yytype_int8 yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
      55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
      65,    66,    67,    68,    69,    70,    71,    72,    73,    74
};

#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
static const yytype_int16 yyrline[] =
{
       0,   903,   903,   906,   907,   910,   911,   912,   913,   914,
     917,   918,   921,   922,   925,   944,   963,   986,  1008,  1024,
    1029,  1034,  1039,  1044,  1049,  1054,  1059,  1064,  1069,  1076,
    1082,  1086,  1091,  1096,  1103,  1114,  1134,  1135,  1136,  1137,
    1138,  1141,  1146,  1151,  1158,  1165,  1172,  1173,  1174,  1177,
    1190,  1202,  1215,  1227,  1236,  1248,  1247,  1280,  1287,  1305,
    1320,  1321,  1324,  1325,  1328,  1353,  1363,  1372,  1380,  1406,
    1414,  1422,  1427,  1432,  1437,  1442,  1447,  1452,  1457,  1462,
    1467,  1472,  1480,  1481,  1485,  1484,  1527,  1534,  1535,  1553,
    1580,  1616,  1617,  1620,  1621,  1624,  1648,  1676,  1697,  1725,
    1756,  1830,  1847,  1893,  1957,  1995,  2002,  2007,  2012,  2017,
    2022,  2027,  2032,  2037,  2042,  2047,  2052,  2057,  2062,  2067,
    2074,  2075,  2078,  2079,  2085,  2091,  2097,  2101,  2106,  2109,
    2111,  2114,  2117,  2118,  2122,  2121,  2221,  2224,  2227,  2229,
    2233,  2235,  2237,  2241,  2244,  2247,  2249,  2257,  2258,  2261,
    2268,  2297,  2346,  2348,  2352,  2354,  2358,  2360,  2365,  2364,
    2457,  2459,  2467,  2468,  2471,  2478,  2507,  2535,  2538,  2539,
    2540,  2541,  2542,  2543,  2547,  2546,  2601,  2603,  2606,  2612,
    2614,  2621,  2623,  2626,  2629,  2631,  2633,  2635,  2637,  2641,
    2646,  2648,  2653,  2657,  2659,  2664,  2665,  2668,  2675,  2699,
    2724,  2729,  2745,  2744,  2804,  2823,  2825,  2830,  2831,  2834,
    2841,  2870,  2894,  2918,  2925,  2924,  3003,  3025,  3044,  3046,
    3051,  3052,  3055,  3062,  3088,  3111,  3134,  3141,  3140,  3230,
    3232,  3237,  3238,  3241,  3248,  3276,  3299,  3322,  3329,  3328,
    3411,  3413,  3418,  3419,  3422,  3429,  3455,  3478,  3501,  3508,
    3507,  3592,  3597,  3603,  3609,  3617,  3619,  3624,  3625,  3628,
    3635,  3661,  3686,  3709,  3732
};
#endif

/** Accessing symbol of state STATE.  */
#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])

#if YYDEBUG || 0
/* The user-facing name of the symbol whose (internal) number is
   YYSYMBOL.  No bounds checking.  */
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;

/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
static const char *const yytname[] =
{
  "\"end of file\"", "error", "\"invalid token\"", "TOK_LBRACE",
  "TOK_RBRACE", "TOK_PLUS", "TOK_MINUS", "TOK_COLON", "TOK_COMMA",
  "TOK_LPAREN", "TOK_RPAREN", "TOK_ASSIGN", "TOK_GLOBAL", "TOK_INDOM",
  "TOK_DUPLICATE", "TOK_METRIC", "TOK_HOSTNAME", "TOK_TIMEZONE",
  "TOK_ZONEINFO", "TOK_FEATURES", "TOK_TIME", "TOK_NAME", "TOK_DUPOK",
  "TOK_INST", "TOK_INAME", "TOK_DELETE", "TOK_REDACT", "TOK_REPLACE",
  "TOK_PMID", "TOK_NULL_INT", "TOK_TYPE", "TOK_IF", "TOK_SEM", "TOK_UNITS",
  "TOK_EXTRAUNITS", "TOK_METRIC_VALUE", "TOK_OUTPUT", "TOK_RESCALE",
  "TOK_TEXT", "TOK_ONELINE", "TOK_HELP", "TOK_TEXT_STAR", "TOK_LABEL",
  "TOK_CONTEXT", "TOK_LABEL_STAR", "TOK_DOMAIN", "TOK_CLUSTER", "TOK_ITEM",
  "TOK_INSTANCES", "TOK_INSTANCE", "TOK_NEW", "TOK_VALUE", "TOK_BITS",
  "TOK_GNAME", "TOK_NUMBER", "TOK_STRING", "TOK_TEXT_STRING", "TOK_HNAME",
  "TOK_FLOAT", "TOK_PATTERN", "TOK_MACRO", "TOK_JSON_STRING",
  "TOK_JSON_NUMBER", "TOK_JSON_TRUE", "TOK_JSON_FALSE", "TOK_JSON_NULL",
  "TOK_INDOM_STAR", "TOK_PMID_INT", "TOK_PMID_STAR", "TOK_TYPE_NAME",
  "TOK_SEM_NAME", "TOK_SPACE_NAME", "TOK_TIME_NAME", "TOK_COUNT_NAME",
  "TOK_OUTPUT_TYPE", "$accept", "config", "speclist", "spec", "globalspec",
  "globaloptlist", "globalopt", "feature_bits", "bits_list", "hname",
  "signnumber", "number", "float", "signtime", "time", "indomspec", "$@1",
  "indom_int", "optindomopt", "indomoptlist", "indomopt", "duplicateopt",
  "metricspec", "$@2", "pmid_or_name", "pmid_int", "optmetricoptlist",
  "metricoptlist", "metricopt", "optreplace", "null_or_indom", "pick",
  "rescaleopt", "textspec", "textmetricorindomspec", "textmetricspec",
  "$@3", "opttexttypes", "texttypes", "texttype", "opttextvalue",
  "opttextmetricoptlist", "textmetricoptlist", "textmetricopt",
  "textstring", "pattern", "replacement", "textindomspec", "$@4",
  "opttextindomoptlist", "textindomoptlist", "textindomopt", "labelspec",
  "labelcontextormetricorindomspec", "labelcontextspec", "$@5",
  "optlabeldetails", "jsonname", "optlabelvalue", "jsonvalue",
  "jsonnumber", "optlabelcontextoptlist", "labelcontextoptlist",
  "labelcontextopt", "newlabelspec", "labeldomainspec", "$@6",
  "pmid_domain", "optlabeldomainoptlist", "labeldomainoptlist",
  "labeldomainopt", "labelclusterspec", "$@7", "pmid_cluster",
  "optlabelclusteroptlist", "labelclusteroptlist", "labelclusteropt",
  "labelitemspec", "$@8", "optlabelitemoptlist", "labelitemoptlist",
  "labelitemopt", "labelindomspec", "$@9", "optlabelindomoptlist",
  "labelindomoptlist", "labelindomopt", "labelinstancesspec", "$@10",
  "optinstancelabeldetails", "optlabelinstancesoptlist",
  "labelinstancesoptlist", "labelinstancesopt", YY_NULLPTR
};

static const char *
yysymbol_name (yysymbol_kind_t yysymbol)
{
  return yytname[yysymbol];
}
#endif

#define YYPACT_NINF (-227)

#define yypact_value_is_default(Yyn) \
  ((Yyn) == YYPACT_NINF)

#define YYTABLE_NINF (-84)

#define yytable_value_is_error(Yyn) \
  0

/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
   STATE-NUM.  */
static const yytype_int16 yypact[] =
{
     119,    49,   -33,    86,   104,    82,    57,  -227,   119,  -227,
    -227,  -227,  -227,  -227,   181,  -227,  -227,  -227,  -227,  -227,
    -227,  -227,  -227,   -33,    86,  -227,  -227,  -227,   -33,   -29,
      32,     2,    86,   -33,  -227,  -227,  -227,  -227,  -227,  -227,
    -227,  -227,  -227,  -227,    90,    99,   115,   135,   145,   100,
     197,   165,   177,   179,   179,   -29,    44,  -227,  -227,  -227,
      44,  -227,   -29,  -227,  -227,   -29,   -29,    15,   152,   141,
     153,   170,     8,  -227,  -227,   169,   156,  -227,  -227,  -227,
     147,  -227,   179,   147,  -227,    31,  -227,  -227,  -227,  -227,
    -227,  -227,  -227,  -227,  -227,  -227,   208,  -227,  -227,  -227,
    -227,   -29,   -29,   -29,  -227,  -227,  -227,  -227,  -227,  -227,
    -227,  -227,  -227,   218,  -227,  -227,   -18,   -18,  -227,  -227,
     221,  -227,  -227,  -227,   219,   175,    17,   227,  -227,   169,
     222,   223,  -227,   224,    20,   225,   226,   228,   205,   234,
    -227,   156,  -227,  -227,  -227,  -227,  -227,  -227,   237,  -227,
    -227,   123,   238,   239,   240,  -227,  -227,  -227,   241,   191,
    -227,  -227,   -18,    -5,   235,  -227,    78,   236,  -227,  -227,
     -17,   195,    -4,   180,   182,   183,    23,    23,  -227,    78,
    -227,  -227,   247,   249,     5,  -227,   243,    36,   244,   252,
    -227,   123,  -227,   113,   120,   125,    93,  -227,   213,   250,
    -227,  -227,   -33,    -6,  -227,  -227,   248,    -1,  -227,  -227,
     229,   242,  -227,  -227,   251,  -227,   204,   206,  -227,   253,
     255,   256,    65,    77,   257,  -227,   258,   259,  -227,   262,
    -227,     5,    36,    59,    59,  -227,  -227,  -227,   260,   261,
     263,  -227,   271,  -227,   113,  -227,   265,   267,   268,  -227,
     277,  -227,   120,  -227,   272,   273,   275,  -227,   278,  -227,
     125,  -227,   276,   280,   281,   282,  -227,   284,  -227,    93,
     245,  -227,   -18,  -227,  -227,  -227,    81,  -227,  -227,    -7,
    -227,  -227,   220,  -227,  -227,    23,    23,    81,   283,  -227,
     285,   293,  -227,    65,   287,  -227,   289,   298,  -227,    77,
     -33,    36,    59,  -227,  -227,  -227,  -227,  -227,    36,   254,
      59,  -227,  -227,    36,     2,    59,  -227,  -227,    36,    -4,
      59,  -227,  -227,    36,   -33,   264,    59,  -227,  -227,  -227,
    -227,  -227,  -227,  -227,  -227,   175,   266,  -227,  -227,   295,
     296,  -227,   -33,   147,  -227,  -227,    -4,   147,  -227,  -227,
    -227,  -227,  -227,  -227,  -227,  -227,  -227,  -227,  -227,  -227,
    -227,  -227,  -227,  -227,  -227,  -227,  -227,  -227,    23,    23,
    -227,  -227,  -227,  -227,   297,   299,   246,   269,   301,   302,
     270,   274,   303,   304,   233,   279,   286,   305,  -227,  -227,
     288,   306,   290,   286,  -227
};

/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
   Performed when YYTABLE does not specify something else to do.  Zero
   means the default is an error.  */
static const yytype_int16 yydefact[] =
{
       0,     0,    57,    86,     0,     0,     0,     2,     3,     5,
       6,     7,     8,     9,     0,    58,    59,    55,    88,    89,
      90,    84,    87,     0,     0,   131,   132,   133,     0,   178,
       0,     0,     0,     0,   167,   168,   169,   170,   171,   172,
     173,     1,     4,    11,    20,    22,    24,    26,    28,     0,
      12,     0,     0,   137,   137,   178,   183,   180,   179,   174,
     183,   204,   178,   216,   217,   178,   178,   254,    19,    21,
      23,    25,    27,    10,    13,    61,    92,   142,   141,   140,
     144,   136,   138,   144,   238,     0,   182,   190,   192,   186,
     187,   188,   184,   177,   181,   185,     0,   176,   202,   214,
     227,   178,   178,   178,   249,    37,    38,    40,    36,    39,
      14,    15,    16,    33,    29,    17,     0,     0,    44,    45,
      54,    53,    18,    48,    72,    78,    75,     0,    60,    62,
       0,     0,   105,     0,     0,     0,     0,     0,   121,     0,
      91,    93,   152,   153,   158,   143,   139,   134,     0,   189,
     191,   194,     0,     0,     0,   253,   252,   251,     0,    32,
      46,    47,     0,    71,    77,    67,    81,    74,    56,    63,
     111,   107,   106,   108,   109,   112,   113,     0,   120,   119,
      85,    94,     0,     0,   241,   197,     0,     0,     0,     0,
     193,   195,   200,   206,   219,   230,   256,    34,    31,    52,
      51,    82,     0,    76,   155,   154,    80,    73,   123,   122,
     128,    96,    95,    98,     0,   101,     0,     0,    43,     0,
       0,   118,   161,   146,     0,   244,     0,     0,   248,     0,
     240,   242,     0,     0,     0,   175,   196,   209,     0,     0,
       0,   213,     0,   205,   207,   222,     0,     0,     0,   226,
       0,   218,   220,   233,     0,     0,     0,   237,     0,   229,
     231,   259,     0,     0,     0,     0,   264,     0,   255,   257,
       0,    30,     0,    64,    70,    69,    79,    66,    65,   127,
     100,    97,   110,    41,    42,     0,     0,   117,     0,   164,
       0,     0,   160,   162,     0,   149,     0,     0,   145,   147,
       0,     0,     0,   239,   243,   198,   201,   199,     0,     0,
       0,   203,   208,     0,     0,     0,   215,   221,     0,     0,
       0,   228,   232,     0,     0,     0,     0,   250,   258,    35,
      50,    49,   156,   157,    68,     0,     0,   126,    99,     0,
       0,   104,     0,     0,   159,   163,     0,     0,   135,   148,
     245,   246,   247,   211,   210,   212,   224,   223,   225,   235,
     234,   236,   262,   260,   261,   263,   124,   125,     0,     0,
     166,   165,   151,   150,     0,     0,   114,     0,     0,     0,
     115,     0,     0,     0,   116,     0,   130,     0,   129,   102,
       0,     0,     0,   130,   103
};

/* YYPGOTO[NTERM-NUM].  */
static const yytype_int16 yypgoto[] =
{
    -227,  -227,   307,  -227,  -227,   291,  -227,  -227,  -227,  -227,
    -174,  -123,  -156,  -227,   109,  -227,  -227,   -23,  -227,   187,
    -227,  -227,  -227,  -227,   128,  -168,  -227,   184,  -227,  -227,
    -227,  -227,   -73,  -227,  -227,  -227,  -227,   300,   292,  -227,
     294,  -227,    25,  -227,  -160,   143,    39,  -227,  -227,  -227,
      34,  -227,  -227,  -227,  -227,  -227,   -20,   -28,   308,  -226,
    -227,  -227,   137,  -227,  -173,  -227,  -227,  -227,  -227,    85,
    -227,  -227,  -227,    16,  -227,    79,  -227,  -227,  -227,  -227,
      72,  -227,  -227,  -227,  -227,   102,  -227,  -227,  -227,  -227,
    -227,    66,  -227
};

/* YYDEFGOTO[NTERM-NUM].  */
static const yytype_int16 yydefgoto[] =
{
       0,     6,     7,     8,     9,    49,    50,   115,   198,   110,
     219,   120,   121,   122,   123,    10,    51,    17,   127,   128,
     129,   202,    11,    52,    21,    22,   139,   140,   141,   179,
     210,   280,   389,    12,    25,    26,   183,    80,    81,    82,
     144,   297,   298,   299,   145,   206,   334,    27,   182,   291,
     292,   293,    13,    34,    35,    96,    59,    92,    93,    94,
      95,   189,   190,   191,   192,    36,   152,    62,   242,   243,
     244,    37,   153,    65,   250,   251,   252,    38,   154,   258,
     259,   260,    39,   148,   229,   230,   231,    40,   158,   104,
     267,   268,   269
};

/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
   positive, shift that token.  If negative, reduce the rule whose
   number is the opposite.  If YYTABLE_NINF, syntax error.  */
static const yytype_int16 yytable[] =
{
      53,    60,   164,   220,   212,    55,   200,   306,   307,   201,
      67,   228,   208,   116,   117,    56,   335,   336,   224,   274,
     241,   249,   257,   266,   277,    15,    57,    60,   216,   217,
     225,   173,    58,    16,    60,    84,   118,    60,    60,   199,
     119,    15,    98,   165,   166,    99,   100,   226,   118,    16,
      85,   174,    14,   -83,   278,   187,   227,    41,   228,   101,
      63,   -83,   118,    19,    20,    85,   119,   337,    64,   102,
     103,   241,   167,    60,    60,    60,   352,   218,   288,   249,
     275,   155,   156,   157,   355,   149,    61,   257,    86,   358,
     289,    57,   294,   150,   361,    28,   266,    58,    87,    57,
     365,    68,   295,   290,    73,    58,    88,    89,    90,    91,
      69,   339,   340,    87,    57,   296,   331,    23,   261,    24,
      58,    88,    89,    90,    91,    29,    70,    30,    31,    32,
      33,     1,     2,   204,     3,   262,   332,   205,   237,    18,
     333,   263,   264,   187,   265,   245,    71,   209,   185,   330,
     253,   360,    54,    19,    20,   238,    72,     4,   239,   233,
      66,     5,   246,   187,   240,   186,   247,   254,    75,   130,
     187,   248,   255,   187,   188,   187,   256,   131,   372,   273,
      76,   132,   124,   371,   133,    43,   134,   373,   135,   136,
     137,   138,   125,   126,   374,   375,   111,    44,    45,    46,
      47,    48,   142,   143,   305,   105,   106,   107,   112,   108,
     109,   151,   366,    44,    45,    46,    47,    48,    77,    78,
      79,   270,   113,   271,   114,   160,   161,   159,   162,   118,
     163,   168,   178,   170,   171,   172,   175,   176,   180,   177,
     184,   193,   194,   195,   196,   197,   203,   207,   211,   213,
     222,   214,   223,   215,   232,   234,   235,   272,   283,   276,
     284,   285,   282,   286,   281,   279,   303,   287,   300,   301,
     302,   308,   309,   351,   310,   311,   313,   350,   314,   315,
     353,   316,   321,   318,   319,   356,   320,   323,   327,   338,
     359,   324,   325,   326,   342,   362,   343,   344,   346,   329,
     347,   363,   348,   368,   369,   376,   386,   377,   354,   380,
     381,   384,   385,   390,   392,    42,   169,   378,   364,   370,
     394,   367,   221,   388,   349,   181,   341,   345,   236,   312,
     357,   317,   322,   304,     0,   328,     0,     0,     0,     0,
     379,    74,   382,     0,     0,     0,   383,     0,   391,     0,
     393,     0,   387,     0,    83,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,    97,     0,
       0,     0,     0,     0,   146,     0,     0,   147
};

static const yytype_int16 yycheck[] =
{
      23,    29,   125,   177,   172,    28,   162,   233,   234,    14,
      33,   184,    29,     5,     6,    44,    23,    24,    13,    25,
     193,   194,   195,   196,    25,    58,    55,    55,     5,     6,
      25,    11,    61,    66,    62,    55,    54,    65,    66,   162,
      58,    58,    62,    26,    27,    65,    66,    42,    54,    66,
       6,    31,     3,    58,    55,    50,    51,     0,   231,    44,
      58,    66,    54,    67,    68,     6,    58,    74,    66,    54,
      55,   244,    55,   101,   102,   103,   302,    54,    13,   252,
     203,   101,   102,   103,   310,    54,    54,   260,    44,   315,
      25,    55,    15,    62,   320,    13,   269,    61,    54,    55,
     326,    11,    25,    38,     4,    61,    62,    63,    64,    65,
      11,   285,   286,    54,    55,    38,   272,    13,    25,    15,
      61,    62,    63,    64,    65,    43,    11,    45,    46,    47,
      48,    12,    13,    55,    15,    42,    55,    59,    25,    53,
      59,    48,    49,    50,    51,    25,    11,   170,    25,   272,
      25,   319,    24,    67,    68,    42,    11,    38,    45,   187,
      32,    42,    42,    50,    51,    42,    46,    42,     3,    13,
      50,    51,    47,    50,    51,    50,    51,    21,   346,   202,
       3,    25,    13,   343,    28,     4,    30,   347,    32,    33,
      34,    35,    23,    24,   368,   369,    55,    16,    17,    18,
      19,    20,    55,    56,   232,    53,    54,    55,    55,    57,
      58,     3,   335,    16,    17,    18,    19,    20,    39,    40,
      41,     8,    52,    10,    54,   116,   117,     9,     7,    54,
      11,     4,    27,    11,    11,    11,    11,    11,     4,    11,
       3,     3,     3,     3,     3,    54,    11,    11,    53,    69,
       3,    69,     3,    70,    11,    11,     4,     7,    54,    11,
      54,     8,    11,     8,    22,    36,     4,    11,    11,    11,
      11,    11,    11,   301,    11,     4,    11,   300,    11,    11,
     308,     4,     4,    11,    11,   313,    11,    11,     4,    69,
     318,    11,    11,    11,    11,   323,    11,     4,    11,    54,
      11,   324,     4,     8,     8,     8,    73,     8,    54,     8,
       8,     8,     8,     8,     8,     8,   129,    71,    54,   342,
     393,    55,   179,    37,   299,   141,   287,   293,   191,   244,
     314,   252,   260,   231,    -1,   269,    -1,    -1,    -1,    -1,
      71,    50,    72,    -1,    -1,    -1,    72,    -1,    60,    -1,
      60,    -1,    73,    -1,    54,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    60,    -1,
      -1,    -1,    -1,    -1,    82,    -1,    -1,    83
};

/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
   state STATE-NUM.  */
static const yytype_uint8 yystos[] =
{
       0,    12,    13,    15,    38,    42,    76,    77,    78,    79,
      90,    97,   108,   127,     3,    58,    66,    92,    53,    67,
      68,    99,   100,    13,    15,   109,   110,   122,    13,    43,
      45,    46,    47,    48,   128,   129,   140,   146,   152,   157,
     162,     0,    77,     4,    16,    17,    18,    19,    20,    80,
      81,    91,    98,    92,    99,    92,    44,    55,    61,   131,
     132,    54,   142,    58,    66,   148,    99,    92,    11,    11,
      11,    11,    11,     4,    80,     3,     3,    39,    40,    41,
     112,   113,   114,   112,   131,     6,    44,    54,    62,    63,
      64,    65,   132,   133,   134,   135,   130,   133,   131,   131,
     131,    44,    54,    55,   164,    53,    54,    55,    57,    58,
      84,    55,    55,    52,    54,    82,     5,     6,    54,    58,
      86,    87,    88,    89,    13,    23,    24,    93,    94,    95,
      13,    21,    25,    28,    30,    32,    33,    34,    35,   101,
     102,   103,    55,    56,   115,   119,   113,   115,   158,    54,
      62,     3,   141,   147,   153,   131,   131,   131,   163,     9,
      89,    89,     7,    11,    86,    26,    27,    55,     4,    94,
      11,    11,    11,    11,    31,    11,    11,    11,    27,   104,
       4,   102,   123,   111,     3,    25,    42,    50,    51,   136,
     137,   138,   139,     3,     3,     3,     3,    54,    83,    86,
      87,    14,    96,    11,    55,    59,   120,    11,    29,    92,
     105,    53,   100,    69,    69,    70,     5,     6,    54,    85,
      85,   120,     3,     3,    13,    25,    42,    51,   139,   159,
     160,   161,    11,   132,    11,     4,   137,    25,    42,    45,
      51,   139,   143,   144,   145,    25,    42,    46,    51,   139,
     149,   150,   151,    25,    42,    47,    51,   139,   154,   155,
     156,    25,    42,    48,    49,    51,   139,   165,   166,   167,
       8,    10,     7,    92,    25,    86,    11,    25,    55,    36,
     106,    22,    11,    54,    54,     8,     8,    11,    13,    25,
      38,   124,   125,   126,    15,    25,    38,   116,   117,   118,
      11,    11,    11,     4,   160,   132,   134,   134,    11,    11,
      11,     4,   144,    11,    11,    11,     4,   150,    11,    11,
      11,     4,   155,    11,    11,    11,    11,     4,   166,    54,
      86,    87,    55,    59,   121,    23,    24,    74,    69,    85,
      85,   121,    11,    11,     4,   125,    11,    11,     4,   117,
      92,   132,   134,   132,    54,   134,   132,   148,   134,   132,
     100,   134,   132,    92,    54,   134,    86,    55,     8,     8,
      92,   119,   100,   119,    85,    85,     8,     8,    71,    71,
       8,     8,    72,    72,     8,     8,    73,    73,    37,   107,
       8,    60,     8,    60,   107
};

/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
static const yytype_uint8 yyr1[] =
{
       0,    75,    76,    77,    77,    78,    78,    78,    78,    78,
      79,    79,    80,    80,    81,    81,    81,    81,    81,    81,
      81,    81,    81,    81,    81,    81,    81,    81,    81,    82,
      82,    82,    82,    82,    83,    83,    84,    84,    84,    84,
      84,    85,    85,    85,    86,    87,    88,    88,    88,    89,
      89,    89,    89,    89,    89,    91,    90,    90,    92,    92,
      93,    93,    94,    94,    95,    95,    95,    95,    95,    95,
      95,    95,    95,    95,    95,    95,    95,    95,    95,    95,
      95,    95,    96,    96,    98,    97,    97,    99,    99,   100,
     100,   101,   101,   102,   102,   103,   103,   103,   103,   103,
     103,   103,   103,   103,   103,   103,   103,   103,   103,   103,
     103,   103,   103,   103,   103,   103,   103,   103,   103,   103,
     104,   104,   105,   105,   106,   106,   106,   106,   106,   107,
     107,   108,   109,   109,   111,   110,   112,   112,   113,   113,
     114,   114,   114,   115,   115,   116,   116,   117,   117,   118,
     118,   118,   119,   119,   120,   120,   121,   121,   123,   122,
     124,   124,   125,   125,   126,   126,   126,   127,   128,   128,
     128,   128,   128,   128,   130,   129,   131,   131,   131,   132,
     132,   133,   133,   133,   134,   134,   134,   134,   134,   135,
     135,   135,   135,   136,   136,   137,   137,   138,   138,   138,
     138,   139,   141,   140,   142,   143,   143,   144,   144,   145,
     145,   145,   145,   145,   147,   146,   148,   148,   149,   149,
     150,   150,   151,   151,   151,   151,   151,   153,   152,   154,
     154,   155,   155,   156,   156,   156,   156,   156,   158,   157,
     159,   159,   160,   160,   161,   161,   161,   161,   161,   163,
     162,   164,   164,   164,   164,   165,   165,   166,   166,   167,
     167,   167,   167,   167,   167
};

/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
static const yytype_int8 yyr2[] =
{
       0,     2,     1,     1,     2,     1,     1,     1,     1,     1,
       4,     3,     1,     2,     3,     3,     3,     3,     3,     2,
       1,     2,     1,     2,     1,     2,     1,     2,     1,     1,
       4,     3,     2,     1,     1,     3,     1,     1,     1,     1,
       1,     2,     2,     1,     1,     1,     2,     2,     1,     5,
       5,     3,     3,     1,     1,     0,     6,     1,     1,     1,
       1,     0,     1,     2,     4,     4,     4,     2,     5,     4,
       4,     2,     1,     3,     2,     1,     3,     2,     1,     4,
       3,     2,     1,     0,     0,     6,     1,     1,     1,     1,
       1,     1,     0,     1,     2,     3,     3,     4,     3,     5,
       4,     3,    14,    18,     5,     1,     2,     2,     2,     2,
       4,     2,     2,     2,     8,    10,    12,     4,     3,     2,
       1,     0,     1,     1,     3,     3,     2,     1,     0,     1,
       0,     2,     1,     1,     0,     8,     1,     0,     1,     2,
       1,     1,     1,     1,     0,     1,     0,     1,     2,     1,
       3,     3,     1,     1,     1,     1,     1,     1,     0,     8,
       1,     0,     1,     2,     1,     3,     3,     2,     1,     1,
       1,     1,     1,     1,     0,     6,     2,     2,     0,     1,
       1,     1,     1,     0,     1,     1,     1,     1,     1,     2,
       1,     2,     1,     1,     0,     1,     2,     1,     3,     3,
       1,     3,     0,     7,     1,     1,     0,     1,     2,     1,
       3,     3,     3,     1,     0,     7,     1,     1,     1,     0,
       1,     2,     1,     3,     3,     3,     1,     0,     7,     1,
       0,     1,     2,     1,     3,     3,     3,     1,     0,     7,
       1,     0,     1,     2,     1,     3,     3,     3,     1,     0,
       7,     2,     2,     2,     0,     1,     0,     1,     2,     1,
       3,     3,     3,     3,     1
};


enum { YYENOMEM = -2 };

#define yyerrok         (yyerrstatus = 0)
#define yyclearin       (yychar = YYEMPTY)

#define YYACCEPT        goto yyacceptlab
#define YYABORT         goto yyabortlab
#define YYERROR         goto yyerrorlab
#define YYNOMEM         goto yyexhaustedlab


#define YYRECOVERING()  (!!yyerrstatus)

#define YYBACKUP(Token, Value)                                    \
  do                                                              \
    if (yychar == YYEMPTY)                                        \
      {                                                           \
        yychar = (Token);                                         \
        yylval = (Value);                                         \
        YYPOPSTACK (yylen);                                       \
        yystate = *yyssp;                                         \
        goto yybackup;                                            \
      }                                                           \
    else                                                          \
      {                                                           \
        yyerror (YY_("syntax error: cannot back up")); \
        YYERROR;                                                  \
      }                                                           \
  while (0)

/* Backward compatibility with an undocumented macro.
   Use YYerror or YYUNDEF. */
#define YYERRCODE YYUNDEF


/* Enable debugging if requested.  */
#if YYDEBUG

# ifndef YYFPRINTF
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
#  define YYFPRINTF fprintf
# endif

# define YYDPRINTF(Args)                        \
do {                                            \
  if (yydebug)                                  \
    YYFPRINTF Args;                             \
} while (0)




# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
do {                                                                      \
  if (yydebug)                                                            \
    {                                                                     \
      YYFPRINTF (stderr, "%s ", Title);                                   \
      yy_symbol_print (stderr,                                            \
                  Kind, Value); \
      YYFPRINTF (stderr, "\n");                                           \
    }                                                                     \
} while (0)


/*-----------------------------------.
| Print this symbol's value on YYO.  |
`-----------------------------------*/

static void
yy_symbol_value_print (FILE *yyo,
                       yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
{
  FILE *yyoutput = yyo;
  YY_USE (yyoutput);
  if (!yyvaluep)
    return;
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  YY_USE (yykind);
  YY_IGNORE_MAYBE_UNINITIALIZED_END
}


/*---------------------------.
| Print this symbol on YYO.  |
`---------------------------*/

static void
yy_symbol_print (FILE *yyo,
                 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
{
  YYFPRINTF (yyo, "%s %s (",
             yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));

  yy_symbol_value_print (yyo, yykind, yyvaluep);
  YYFPRINTF (yyo, ")");
}

/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included).                                                   |
`------------------------------------------------------------------*/

static void
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
{
  YYFPRINTF (stderr, "Stack now");
  for (; yybottom <= yytop; yybottom++)
    {
      int yybot = *yybottom;
      YYFPRINTF (stderr, " %d", yybot);
    }
  YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top)                            \
do {                                                            \
  if (yydebug)                                                  \
    yy_stack_print ((Bottom), (Top));                           \
} while (0)


/*------------------------------------------------.
| Report that the YYRULE is going to be reduced.  |
`------------------------------------------------*/

static void
yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
                 int yyrule)
{
  int yylno = yyrline[yyrule];
  int yynrhs = yyr2[yyrule];
  int yyi;
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
             yyrule - 1, yylno);
  /* The symbols being reduced.  */
  for (yyi = 0; yyi < yynrhs; yyi++)
    {
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
      yy_symbol_print (stderr,
                       YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
                       &yyvsp[(yyi + 1) - (yynrhs)]);
      YYFPRINTF (stderr, "\n");
    }
}

# define YY_REDUCE_PRINT(Rule)          \
do {                                    \
  if (yydebug)                          \
    yy_reduce_print (yyssp, yyvsp, Rule); \
} while (0)

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args) ((void) 0)
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */


/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif

/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).

   Do not make this value too large; the results are undefined if
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif






/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

static void
yydestruct (const char *yymsg,
            yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
{
  YY_USE (yyvaluep);
  if (!yymsg)
    yymsg = "Deleting";
  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);

  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  YY_USE (yykind);
  YY_IGNORE_MAYBE_UNINITIALIZED_END
}


/* Lookahead token kind.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;
/* Number of syntax errors so far.  */
int yynerrs;




/*----------.
| yyparse.  |
`----------*/

int
yyparse (void)
{
    yy_state_fast_t yystate = 0;
    /* Number of tokens to shift before error messages enabled.  */
    int yyerrstatus = 0;

    /* Refer to the stacks through separate pointers, to allow yyoverflow
       to reallocate them elsewhere.  */

    /* Their size.  */
    YYPTRDIFF_T yystacksize = YYINITDEPTH;

    /* The state stack: array, bottom, top.  */
    yy_state_t yyssa[YYINITDEPTH];
    yy_state_t *yyss = yyssa;
    yy_state_t *yyssp = yyss;

    /* The semantic value stack: array, bottom, top.  */
    YYSTYPE yyvsa[YYINITDEPTH];
    YYSTYPE *yyvs = yyvsa;
    YYSTYPE *yyvsp = yyvs;

  int yyn;
  /* The return value of yyparse.  */
  int yyresult;
  /* Lookahead symbol kind.  */
  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;



#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))

  /* The number of symbols on the RHS of the reduced rule.
     Keep to zero when no symbol should be popped.  */
  int yylen = 0;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yychar = YYEMPTY; /* Cause a token to be read.  */

  goto yysetstate;


/*------------------------------------------------------------.
| yynewstate -- push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed.  So pushing a state here evens the stacks.  */
  yyssp++;


/*--------------------------------------------------------------------.
| yysetstate -- set current state (the top of the stack) to yystate.  |
`--------------------------------------------------------------------*/
yysetstate:
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
  YY_IGNORE_USELESS_CAST_BEGIN
  *yyssp = YY_CAST (yy_state_t, yystate);
  YY_IGNORE_USELESS_CAST_END
  YY_STACK_PRINT (yyss, yyssp);

  if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
    YYNOMEM;
#else
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYPTRDIFF_T yysize = yyssp - yyss + 1;

# if defined yyoverflow
      {
        /* Give user a chance to reallocate the stack.  Use copies of
           these so that the &'s don't force the real ones into
           memory.  */
        yy_state_t *yyss1 = yyss;
        YYSTYPE *yyvs1 = yyvs;

        /* Each stack pointer address is followed by the size of the
           data in use in that stack, in bytes.  This used to be a
           conditional around just the two extra args, but that might
           be undefined if yyoverflow is a macro.  */
        yyoverflow (YY_("memory exhausted"),
                    &yyss1, yysize * YYSIZEOF (*yyssp),
                    &yyvs1, yysize * YYSIZEOF (*yyvsp),
                    &yystacksize);
        yyss = yyss1;
        yyvs = yyvs1;
      }
# else /* defined YYSTACK_RELOCATE */
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
        YYNOMEM;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
        yystacksize = YYMAXDEPTH;

      {
        yy_state_t *yyss1 = yyss;
        union yyalloc *yyptr =
          YY_CAST (union yyalloc *,
                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
        if (! yyptr)
          YYNOMEM;
        YYSTACK_RELOCATE (yyss_alloc, yyss);
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
#  undef YYSTACK_RELOCATE
        if (yyss1 != yyssa)
          YYSTACK_FREE (yyss1);
      }
# endif

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;

      YY_IGNORE_USELESS_CAST_BEGIN
      YYDPRINTF ((stderr, "Stack size increased to %ld\n",
                  YY_CAST (long, yystacksize)));
      YY_IGNORE_USELESS_CAST_END

      if (yyss + yystacksize - 1 <= yyssp)
        YYABORT;
    }
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */


  if (yystate == YYFINAL)
    YYACCEPT;

  goto yybackup;


/*-----------.
| yybackup.  |
`-----------*/
yybackup:
  /* Do appropriate processing given the current state.  Read a
     lookahead token if we need one and don't already have one.  */

  /* First try to decide what to do without reference to lookahead token.  */
  yyn = yypact[yystate];
  if (yypact_value_is_default (yyn))
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token\n"));
      yychar = yylex ();
    }

  if (yychar <= YYEOF)
    {
      yychar = YYEOF;
      yytoken = YYSYMBOL_YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else if (yychar == YYerror)
    {
      /* The scanner already issued an error message, process directly
         to error recovery.  But do not keep the error token as
         lookahead, it is too special and may lead us to an endless
         loop in error recovery. */
      yychar = YYUNDEF;
      yytoken = YYSYMBOL_YYerror;
      goto yyerrlab1;
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yytable_value_is_error (yyn))
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  /* Shift the lookahead token.  */
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  yystate = yyn;
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  *++yyvsp = yylval;
  YY_IGNORE_MAYBE_UNINITIALIZED_END

  /* Discard the shifted token.  */
  yychar = YYEMPTY;
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     '$$ = $1'.

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
  case 14: /* globalopt: TOK_HOSTNAME TOK_ASSIGN hname  */
#line 926 "gram.y"
                    {
			if (global.flags & GLOBAL_CHANGE_HOSTNAME) {
			    pmsprintf(mess, sizeof(mess), "Duplicate global hostname clause");
			    yyerror(mess);
			}
			if (inarch.label.hostname != NULL && strcmp(inarch.label.hostname, (yyvsp[0].str)) == 0) {
			    /* no change ... */
			    if (wflag) {
				pmsprintf(mess, sizeof(mess), "Global hostname (%s): No change", inarch.label.hostname);
				yywarn(mess);
			    }
			    free((yyvsp[0].str));
			}
			else {
			    global.hostname = (yyvsp[0].str);
			    global.flags |= GLOBAL_CHANGE_HOSTNAME;
			}
		    }
#line 2365 "gram.tab.c"
    break;

  case 15: /* globalopt: TOK_TIMEZONE TOK_ASSIGN TOK_STRING  */
#line 945 "gram.y"
                    {
			if (global.flags & GLOBAL_CHANGE_TIMEZONE) {
			    pmsprintf(mess, sizeof(mess), "Duplicate global timezone clause");
			    yyerror(mess);
			}
			if (inarch.label.timezone != NULL && strcmp(inarch.label.timezone, (yyvsp[0].str)) == 0) {
			    /* no change ... */
			    if (wflag) {
				pmsprintf(mess, sizeof(mess), "Global timezone (%s): No change", inarch.label.timezone);
				yywarn(mess);
			    }
			    free((yyvsp[0].str));
			}
			else {
			    global.timezone =  (yyvsp[0].str);
			    global.flags |= GLOBAL_CHANGE_TIMEZONE;
			}
		    }
#line 2388 "gram.tab.c"
    break;

  case 16: /* globalopt: TOK_ZONEINFO TOK_ASSIGN TOK_STRING  */
#line 964 "gram.y"
                    {
			if (global.flags & GLOBAL_CHANGE_ZONEINFO) {
			    pmsprintf(mess, sizeof(mess), "Duplicate global zoneinfo clause");
			    yyerror(mess);
			}
			if (outarch.version < PM_LOG_VERS03) {
			    pmsprintf(mess, sizeof(mess), "Global zoneinfo clause requires output archive version of 3 or greater");
			    yyerror(mess);
			}
			if (inarch.label.zoneinfo != NULL && strcmp(inarch.label.zoneinfo, (yyvsp[0].str)) == 0) {
			    /* no change ... */
			    if (wflag) {
				pmsprintf(mess, sizeof(mess), "Global zoneinfo (%s): No change", inarch.label.zoneinfo);
				yywarn(mess);
			    }
			    free((yyvsp[0].str));
			}
			else {
			    global.zoneinfo = (yyvsp[0].str);
			    global.flags |= GLOBAL_CHANGE_ZONEINFO;
			}
		    }
#line 2415 "gram.tab.c"
    break;

  case 17: /* globalopt: TOK_FEATURES TOK_ASSIGN feature_bits  */
#line 987 "gram.y"
                    {
			if (global.flags & GLOBAL_CHANGE_FEATURES) {
			    pmsprintf(mess, sizeof(mess), "Duplicate global features clause");
			    yyerror(mess);
			}
			if (outarch.version < PM_LOG_VERS03) {
			    pmsprintf(mess, sizeof(mess), "Global features clause requires output archive version of 3 or greater");
			    yyerror(mess);
			}
			if (inarch.label.features == (yyvsp[0].uival)) {
			    /* no change ... */
			    if (wflag) {
				pmsprintf(mess, sizeof(mess), "Global features (%d): No change", inarch.label.features);
				yywarn(mess);
			    }
			}
			else {
			    global.features = (yyvsp[0].uival);
			    global.flags |= GLOBAL_CHANGE_FEATURES;
			}
		    }
#line 2441 "gram.tab.c"
    break;

  case 18: /* globalopt: TOK_TIME TOK_ASSIGN signtime  */
#line 1009 "gram.y"
                    {
			if (global.flags & GLOBAL_CHANGE_TIME) {
			    pmsprintf(mess, sizeof(mess), "Duplicate global time clause");
			    yyerror(mess);
			}
			if (global.time.sec == 0 && global.time.nsec == 0) {
			    /* no change ... */
			    if (wflag) {
				pmsprintf(mess, sizeof(mess), "Global time: No change");
				yywarn(mess);
			    }
			}
			else
			    global.flags |= GLOBAL_CHANGE_TIME;
		    }
#line 2461 "gram.tab.c"
    break;

  case 19: /* globalopt: TOK_HOSTNAME TOK_ASSIGN  */
#line 1025 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <hostname> in hostname clause");
			yyerror(mess);
		    }
#line 2470 "gram.tab.c"
    break;

  case 20: /* globalopt: TOK_HOSTNAME  */
#line 1030 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in hostname clause");
			yyerror(mess);
		    }
#line 2479 "gram.tab.c"
    break;

  case 21: /* globalopt: TOK_TIMEZONE TOK_ASSIGN  */
#line 1035 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <timezone_string> in timezone clause");
			yyerror(mess);
		    }
#line 2488 "gram.tab.c"
    break;

  case 22: /* globalopt: TOK_TIMEZONE  */
#line 1040 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in timezone clause");
			yyerror(mess);
		    }
#line 2497 "gram.tab.c"
    break;

  case 23: /* globalopt: TOK_ZONEINFO TOK_ASSIGN  */
#line 1045 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <zoneinfo_string> in zoneinfo clause");
			yyerror(mess);
		    }
#line 2506 "gram.tab.c"
    break;

  case 24: /* globalopt: TOK_ZONEINFO  */
#line 1050 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in zoneinfo clause");
			yyerror(mess);
		    }
#line 2515 "gram.tab.c"
    break;

  case 25: /* globalopt: TOK_FEATURES TOK_ASSIGN  */
#line 1055 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <features_value> in features clause");
			yyerror(mess);
		    }
#line 2524 "gram.tab.c"
    break;

  case 26: /* globalopt: TOK_FEATURES  */
#line 1060 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in features clause");
			yyerror(mess);
		    }
#line 2533 "gram.tab.c"
    break;

  case 27: /* globalopt: TOK_TIME TOK_ASSIGN  */
#line 1065 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <delta> of the form [+-][HH:[MM:]]SS[.d...] in time clause");
			yyerror(mess);
		    }
#line 2542 "gram.tab.c"
    break;

  case 28: /* globalopt: TOK_TIME  */
#line 1070 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in time clause");
			yyerror(mess);
		    }
#line 2551 "gram.tab.c"
    break;

  case 29: /* feature_bits: TOK_NUMBER  */
#line 1077 "gram.y"
                    {
			char	*q;
			(yyval.uival) = (unsigned int)strtoul((yyvsp[0].str), &q, 10);
			free((yyvsp[0].str));
		    }
#line 2561 "gram.tab.c"
    break;

  case 30: /* feature_bits: TOK_BITS TOK_LPAREN bits_list TOK_RPAREN  */
#line 1083 "gram.y"
                    {
			(yyval.uival) = (yyvsp[-1].uival);
		    }
#line 2569 "gram.tab.c"
    break;

  case 31: /* feature_bits: TOK_BITS TOK_LPAREN bits_list  */
#line 1087 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting ) after \"bits(\" in features clause");
			yyerror(mess);
		    }
#line 2578 "gram.tab.c"
    break;

  case 32: /* feature_bits: TOK_BITS TOK_LPAREN  */
#line 1092 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <list_of_bit_numbers> after \"bits(\" in features clause");
			yyerror(mess);
		    }
#line 2587 "gram.tab.c"
    break;

  case 33: /* feature_bits: TOK_BITS  */
#line 1097 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting ( after \"bits\" in features clause");
			yyerror(mess);
		    }
#line 2596 "gram.tab.c"
    break;

  case 34: /* bits_list: TOK_NUMBER  */
#line 1104 "gram.y"
                    {
			int	b;
			b = atoi((yyvsp[0].str));
			if (b < 0 || b > 31) {
			    pmsprintf(mess, sizeof(mess), "Bit \"%s\" not in the range 0..31", (yyvsp[0].str));
			    yyerror(mess);
			}
			(yyval.uival) = (unsigned int)1 << b;
			free((yyvsp[0].str));
		    }
#line 2611 "gram.tab.c"
    break;

  case 35: /* bits_list: bits_list TOK_COMMA TOK_NUMBER  */
#line 1115 "gram.y"
                    {
			int	b;
			b = atoi((yyvsp[0].str));
			if (b < 0 || b > 31) {
			    pmsprintf(mess, sizeof(mess), "Bit \"%s\" not in the range 0..31", (yyvsp[0].str));
			    yyerror(mess);
			}
			(yyval.uival) = (unsigned int)(yyvsp[-2].uival) | ((unsigned int)1 << b);
			free((yyvsp[0].str));
		    }
#line 2626 "gram.tab.c"
    break;

  case 41: /* signnumber: TOK_PLUS TOK_NUMBER  */
#line 1142 "gram.y"
                    {
			(yyval.ival) = atoi((yyvsp[0].str));
			free((yyvsp[0].str));
		    }
#line 2635 "gram.tab.c"
    break;

  case 42: /* signnumber: TOK_MINUS TOK_NUMBER  */
#line 1147 "gram.y"
                    {
			(yyval.ival) = -atoi((yyvsp[0].str));
			free((yyvsp[0].str));
		    }
#line 2644 "gram.tab.c"
    break;

  case 43: /* signnumber: TOK_NUMBER  */
#line 1152 "gram.y"
                    {
			(yyval.ival) = atoi((yyvsp[0].str));
			free((yyvsp[0].str));
		    }
#line 2653 "gram.tab.c"
    break;

  case 44: /* number: TOK_NUMBER  */
#line 1159 "gram.y"
                    {
			(yyval.ival) = atoi((yyvsp[0].str));
			free((yyvsp[0].str));
		    }
#line 2662 "gram.tab.c"
    break;

  case 45: /* float: TOK_FLOAT  */
#line 1166 "gram.y"
                    {
			(yyval.dval) = atof((yyvsp[0].str));
			free((yyvsp[0].str));
		    }
#line 2671 "gram.tab.c"
    break;

  case 47: /* signtime: TOK_MINUS time  */
#line 1173 "gram.y"
                                 { global.time.sec = -global.time.sec; }
#line 2677 "gram.tab.c"
    break;

  case 49: /* time: number TOK_COLON number TOK_COLON float  */
#line 1178 "gram.y"
                    { 
			if ((yyvsp[-2].ival) > 59) {
			    pmsprintf(mess, sizeof(mess), "Minutes (%d) in time clause more than 59", (yyvsp[-2].ival));
			    yywarn(mess);
			}
			if ((yyvsp[0].dval) > 59) {
			    pmsprintf(mess, sizeof(mess), "Seconds (%.6f) in time clause more than 59", (yyvsp[0].dval));
			    yywarn(mess);
			}
			global.time.sec = (yyvsp[-4].ival) * 3600 + (yyvsp[-2].ival) * 60 + (int)(yyvsp[0].dval);
			global.time.nsec = (int)(1000000000*(((yyvsp[0].dval) - (int)(yyvsp[0].dval)))+0.5);
		    }
#line 2694 "gram.tab.c"
    break;

  case 50: /* time: number TOK_COLON number TOK_COLON number  */
#line 1191 "gram.y"
                    { 
			if ((yyvsp[-2].ival) > 59) {
			    pmsprintf(mess, sizeof(mess), "Minutes (%d) in time clause more than 59", (yyvsp[-2].ival));
			    yywarn(mess);
			}
			if ((yyvsp[0].ival) > 59) {
			    pmsprintf(mess, sizeof(mess), "Seconds (%d) in time clause more than 59", (yyvsp[0].ival));
			    yywarn(mess);
			}
			global.time.sec = (yyvsp[-4].ival) * 3600 + (yyvsp[-2].ival) * 60 + (yyvsp[0].ival);
		    }
#line 2710 "gram.tab.c"
    break;

  case 51: /* time: number TOK_COLON float  */
#line 1203 "gram.y"
                    { 
			if ((yyvsp[-2].ival) > 59) {
			    pmsprintf(mess, sizeof(mess), "Minutes (%d) in time clause more than 59", (yyvsp[-2].ival));
			    yywarn(mess);
			}
			if ((yyvsp[0].dval) > 59) {
			    pmsprintf(mess, sizeof(mess), "Seconds (%.6f) in time clause more than 59", (yyvsp[0].dval));
			    yywarn(mess);
			}
			global.time.sec = (yyvsp[-2].ival) * 60 + (int)(yyvsp[0].dval);
			global.time.nsec = (int)(1000000000*(((yyvsp[0].dval) - (int)(yyvsp[0].dval)))+0.5);
		    }
#line 2727 "gram.tab.c"
    break;

  case 52: /* time: number TOK_COLON number  */
#line 1216 "gram.y"
                    { 
			if ((yyvsp[-2].ival) > 59) {
			    pmsprintf(mess, sizeof(mess), "Minutes (%d) in time clause more than 59", (yyvsp[-2].ival));
			    yywarn(mess);
			}
			if ((yyvsp[0].ival) > 59) {
			    pmsprintf(mess, sizeof(mess), "Seconds (%d) in time clause more than 59", (yyvsp[0].ival));
			    yywarn(mess);
			}
			global.time.sec = (yyvsp[-2].ival) * 60 + (yyvsp[0].ival);
		    }
#line 2743 "gram.tab.c"
    break;

  case 53: /* time: float  */
#line 1228 "gram.y"
                    {
			if ((yyvsp[0].dval) > 59) {
			    pmsprintf(mess, sizeof(mess), "Seconds (%.6f) in time clause more than 59", (yyvsp[0].dval));
			    yywarn(mess);
			}
			global.time.sec = (int)(yyvsp[0].dval);
			global.time.nsec = (int)(1000000000*(((yyvsp[0].dval) - (int)(yyvsp[0].dval)))+0.5);
		    }
#line 2756 "gram.tab.c"
    break;

  case 54: /* time: number  */
#line 1237 "gram.y"
                    {
			if ((yyvsp[0].ival) > 59) {
			    pmsprintf(mess, sizeof(mess), "Seconds (%d) in time clause more than 59", (yyvsp[0].ival));
			    yywarn(mess);
			}
			global.time.sec = (yyvsp[0].ival);
			global.time.nsec = 0;
		    }
#line 2769 "gram.tab.c"
    break;

  case 55: /* $@1: %empty  */
#line 1248 "gram.y"
                    {
			if (current_star_indom) {
			    __pmContext		*ctxp;
			    __pmHashCtl		*hcp;
			    __pmHashNode	*node;

			    ctxp = __pmHandleToPtr(pmWhichContext());
			    assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			    PM_UNLOCK(ctxp->c_lock);
			    hcp = &ctxp->c_archctl->ac_log->hashindom;
			    star_domain = pmInDom_domain((yyvsp[0].indom));
			    for (node = __pmHashWalk(hcp, PM_HASH_WALK_START);
				 node != NULL;
				 node = __pmHashWalk(hcp, PM_HASH_WALK_NEXT)) {
				if (pmInDom_domain((pmInDom)(node->key)) == star_domain)
				    current_indomspec = start_indom((pmInDom)(node->key), 0);
			    }
			    do_walk_indom = 1;
			}
			else {
			    current_indomspec = start_indom((yyvsp[0].indom), 0);
			    do_walk_indom = 0;
			}
		    }
#line 2805 "gram.tab.c"
    break;

  case 57: /* indomspec: TOK_INDOM  */
#line 1281 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <domain>.<serial> or <domain>.* in indom rule");
			yyerror(mess);
		    }
#line 2814 "gram.tab.c"
    break;

  case 58: /* indom_int: TOK_FLOAT  */
#line 1288 "gram.y"
                    {
			int		domain;
			int		serial;
			/* TOK_FLOAT => domain >= 0 && serial >= 0 after sscanf */
			sscanf((yyvsp[0].str), "%d.%d", &domain, &serial);
			if (domain >= DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Illegal domain field (%d) for indom", domain);
			    yyerror(mess);
			}
			if (serial >= 4194304) {
			    pmsprintf(mess, sizeof(mess), "Illegal serial field (%d) for indom", serial);
			    yyerror(mess);
			}
			current_star_indom = 0;
			free((yyvsp[0].str));
			(yyval.indom) = pmInDom_build(domain, serial);
		    }
#line 2836 "gram.tab.c"
    break;

  case 59: /* indom_int: TOK_INDOM_STAR  */
#line 1306 "gram.y"
                    {
			int		domain;
			/* TOK_INDOM_STAR => domain >= 0 after sscanf */
			sscanf((yyvsp[0].str), "%d.", &domain);
			if (domain >= DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Illegal domain field (%d) for indom", domain);
			    yyerror(mess);
			}
			current_star_indom = 1;
			free((yyvsp[0].str));
			(yyval.indom) = pmInDom_build(domain, 0);
		    }
#line 2853 "gram.tab.c"
    break;

  case 64: /* indomopt: TOK_INDOM TOK_ASSIGN duplicateopt indom_int  */
#line 1329 "gram.y"
                    {
			indomspec_t	*ip;
			for (ip = walk_indom(W_START); ip != NULL; ip = walk_indom(W_NEXT)) {
			    pmInDom	indom;
			    if (indom_root->new_indom != indom_root->old_indom) {
				pmsprintf(mess, sizeof(mess), "Duplicate indom clause for indom %s", pmInDomStr(indom_root->old_indom));
				yyerror(mess);
			    }
			    if (current_star_indom)
				indom = pmInDom_build(pmInDom_domain((yyvsp[0].indom)), pmInDom_serial(ip->old_indom));
			    else
				indom = (yyvsp[0].indom);
			    if (indom != ip->old_indom)
				ip->new_indom = indom;
			    else {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Instance domain %s: indom: No change", pmInDomStr(ip->old_indom));
				    yywarn(mess);
				}
			    }
			    ip->indom_flags |= (yyvsp[-1].ival);
			}
		    }
#line 2882 "gram.tab.c"
    break;

  case 65: /* indomopt: TOK_INAME TOK_STRING TOK_ASSIGN TOK_STRING  */
#line 1354 "gram.y"
                    {
			indomspec_t	*ip;
			for (ip = walk_indom(W_START); ip != NULL; ip = walk_indom(W_NEXT)) {
			    if (change_inst_by_name(ip->old_indom, (yyvsp[-2].str), (yyvsp[0].str)) < 0)
				yyerror(mess);
			}
			free((yyvsp[-2].str));
			/* Note: $4 referenced from new_iname[] */
		    }
#line 2896 "gram.tab.c"
    break;

  case 66: /* indomopt: TOK_INAME TOK_STRING TOK_ASSIGN TOK_DELETE  */
#line 1364 "gram.y"
                    {
			indomspec_t	*ip;
			for (ip = walk_indom(W_START); ip != NULL; ip = walk_indom(W_NEXT)) {
			    if (change_inst_by_name(ip->old_indom, (yyvsp[-2].str), NULL) < 0)
			    	yyerror(mess);
			}
			free((yyvsp[-2].str));
		    }
#line 2909 "gram.tab.c"
    break;

  case 67: /* indomopt: TOK_INAME TOK_REDACT  */
#line 1373 "gram.y"
                    {
			indomspec_t	*ip;
			for (ip = walk_indom(W_START); ip != NULL; ip = walk_indom(W_NEXT)) {
			    if (redact_indom(ip->old_indom) < 0)
			    	yyerror(mess);
			}
		    }
#line 2921 "gram.tab.c"
    break;

  case 68: /* indomopt: TOK_INAME TOK_REPLACE pattern TOK_ASSIGN replacement  */
#line 1381 "gram.y"
                    {
			int		sts;
			indomspec_t	*ip;
			value_change_t	vc;
			vc.pat = (yyvsp[-2].str);
			if (pmDebugOptions.appl5)
			    fprintf(stderr, "compiling iname regex /%s/\n", vc.pat);
			if ((sts = regcomp(&vc.regex, vc.pat, REG_EXTENDED)) != 0) {
			    size_t	pfx;
			    pmstrncat(mess, sizeof(mess), "regcomp error: ");
			    pfx = strlen(mess);
			    regerror(sts, &vc.regex, &mess[pfx], sizeof(mess)-pfx-1);
			    yyerror(mess);
			}
			vc.replace = (yyvsp[0].str);
			for (ip = walk_indom(W_START); ip != NULL; ip = walk_indom(W_NEXT)) {
			    if (replace_indom(ip->old_indom, &vc) < 0) {
				/* mess[] set in replace_indom() for errors */
			    	yyerror(mess);
			    }
			}
			regfree(&vc.regex);
			free((yyvsp[-2].str));
			free((yyvsp[0].str));
		    }
#line 2951 "gram.tab.c"
    break;

  case 69: /* indomopt: TOK_INST number TOK_ASSIGN number  */
#line 1407 "gram.y"
                    {
			indomspec_t	*ip;
			for (ip = walk_indom(W_START); ip != NULL; ip = walk_indom(W_NEXT)) {
			    if (change_inst_by_inst(ip->old_indom, (yyvsp[-2].ival), (yyvsp[0].ival)) < 0)
				yyerror(mess);
			}
		    }
#line 2963 "gram.tab.c"
    break;

  case 70: /* indomopt: TOK_INST number TOK_ASSIGN TOK_DELETE  */
#line 1415 "gram.y"
                    {
			indomspec_t	*ip;
			for (ip = walk_indom(W_START); ip != NULL; ip = walk_indom(W_NEXT)) {
			    if (change_inst_by_inst(ip->old_indom, (yyvsp[-2].ival), PM_IN_NULL) < 0)
				yyerror(mess);
			}
		    }
#line 2975 "gram.tab.c"
    break;

  case 71: /* indomopt: TOK_INDOM TOK_ASSIGN  */
#line 1423 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <domain>.<serial> or <domain>.* in indom clause");
			yyerror(mess);
		    }
#line 2984 "gram.tab.c"
    break;

  case 72: /* indomopt: TOK_INDOM  */
#line 1428 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in indom clause");
			yyerror(mess);
		    }
#line 2993 "gram.tab.c"
    break;

  case 73: /* indomopt: TOK_INAME TOK_STRING TOK_ASSIGN  */
#line 1433 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting new <external_instance_name> or DELETE in iname clause");
			yyerror(mess);
		    }
#line 3002 "gram.tab.c"
    break;

  case 74: /* indomopt: TOK_INAME TOK_STRING  */
#line 1438 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in iname clause");
			yyerror(mess);
		    }
#line 3011 "gram.tab.c"
    break;

  case 75: /* indomopt: TOK_INAME  */
#line 1443 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting old <external_instance_name> or REDACT or REPLACE in iname clause");
			yyerror(mess);
		    }
#line 3020 "gram.tab.c"
    break;

  case 76: /* indomopt: TOK_INST number TOK_ASSIGN  */
#line 1448 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting new <internal_instance_identifier> or DELETE in inst clause");
			yyerror(mess);
		    }
#line 3029 "gram.tab.c"
    break;

  case 77: /* indomopt: TOK_INST number  */
#line 1453 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in inst clause");
			yyerror(mess);
		    }
#line 3038 "gram.tab.c"
    break;

  case 78: /* indomopt: TOK_INST  */
#line 1458 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting old <internal_instance_identifier> in inst clause");
			yyerror(mess);
		    }
#line 3047 "gram.tab.c"
    break;

  case 79: /* indomopt: TOK_INAME TOK_REPLACE pattern TOK_ASSIGN  */
#line 1463 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <replacement> in iname clause");
			yyerror(mess);
		    }
#line 3056 "gram.tab.c"
    break;

  case 80: /* indomopt: TOK_INAME TOK_REPLACE pattern  */
#line 1468 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in iname clause");
			yyerror(mess);
		    }
#line 3065 "gram.tab.c"
    break;

  case 81: /* indomopt: TOK_INAME TOK_REPLACE  */
#line 1473 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <regular expression> in iname clause");
			yyerror(mess);
		    }
#line 3074 "gram.tab.c"
    break;

  case 82: /* duplicateopt: TOK_DUPLICATE  */
#line 1480 "gram.y"
                                        { (yyval.ival) = INDOM_DUPLICATE; }
#line 3080 "gram.tab.c"
    break;

  case 83: /* duplicateopt: %empty  */
#line 1481 "gram.y"
                                        { (yyval.ival) = 0; }
#line 3086 "gram.tab.c"
    break;

  case 84: /* $@2: %empty  */
#line 1485 "gram.y"
                    {
			if (current_star_metric) {
			    __pmContext		*ctxp;
			    __pmHashCtl		*hcp;
			    __pmHashNode	*node;

			    ctxp = __pmHandleToPtr(pmWhichContext());
			    assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			    PM_UNLOCK(ctxp->c_lock);
			    hcp = &ctxp->c_archctl->ac_log->hashpmid;
			    star_domain = pmID_domain((yyvsp[0].pmid));
			    if (current_star_metric == 1)
				star_cluster = pmID_cluster((yyvsp[0].pmid));
			    else
				star_cluster = PM_ID_NULL;
			    for (node = __pmHashWalk(hcp, PM_HASH_WALK_START);
				 node != NULL;
				 node = __pmHashWalk(hcp, PM_HASH_WALK_NEXT)) {
				if (pmID_domain((pmID)(node->key)) == star_domain &&
				    (star_cluster == PM_ID_NULL ||
				     star_cluster == pmID_cluster((pmID)(node->key))))
				    current_metricspec = start_metric((pmID)(node->key));
			    }
			    do_walk_metric = 1;
			}
			else {
			    if ((yyvsp[0].pmid) == PM_ID_NULL)
				/* metric not in archive */
				current_metricspec = NULL;
			    else
				current_metricspec = start_metric((yyvsp[0].pmid));
			    do_walk_metric = 0;
			}
		    }
#line 3132 "gram.tab.c"
    break;

  case 86: /* metricspec: TOK_METRIC  */
#line 1528 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <metric_name> or <domain>.<cluster>.<item> or <domain>.<cluster>.* or <domain>.*.* in metric rule");
			yyerror(mess);
		    }
#line 3141 "gram.tab.c"
    break;

  case 88: /* pmid_or_name: TOK_GNAME  */
#line 1536 "gram.y"
                    {
			int	sts;
			pmID	pmid;
			sts = pmLookupName(1, (const char **)&(yyvsp[0].str), &pmid);
			if (sts < 0) {
			    if (wflag) {
				pmsprintf(mess, sizeof(mess), "Metric: %s: %s", (yyvsp[0].str), pmErrStr(sts));
				yywarn(mess);
			    }
			    pmid = PM_ID_NULL;
			}
			current_star_metric = 0;
			free((yyvsp[0].str));
			(yyval.pmid) = pmid;
		    }
#line 3161 "gram.tab.c"
    break;

  case 89: /* pmid_int: TOK_PMID_INT  */
#line 1554 "gram.y"
                    {
			int	domain;
			int	cluster;
			int	item;
			/* TOK_PMID_INT => domain >= 0 && cluster >=0 && item >= 0 after sscanf */
			sscanf((yyvsp[0].str), "%d.%d.%d", &domain, &cluster, &item);
			if (domain > DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Illegal domain field (%d) for pmid", domain);
			    yyerror(mess);
			}
			else if (domain == DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Dynamic metric domain field (%d) for pmid", domain);
			    yywarn(mess);
			}
			if (cluster >= 4096) {
			    pmsprintf(mess, sizeof(mess), "Illegal cluster field (%d) for pmid", cluster);
			    yyerror(mess);
			}
			if (item >= 1024) {
			    pmsprintf(mess, sizeof(mess), "Illegal item field (%d) for pmid", item);
			    yyerror(mess);
			}
			current_star_metric = 0;
			free((yyvsp[0].str));
			(yyval.pmid) = pmID_build(domain, cluster, item);
		    }
#line 3192 "gram.tab.c"
    break;

  case 90: /* pmid_int: TOK_PMID_STAR  */
#line 1581 "gram.y"
                    {
			int	domain;
			int	cluster;
			int	sts;
			/*
			 * TOK_PMID_STAR matches <n>.<n>.* or <n>.*.*
			 * => domain >= 0, but cluster may be undefined after sscanf
			 */
			sts = sscanf((yyvsp[0].str), "%d.%d.", &domain, &cluster);
			if (domain > DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Illegal domain field (%d) for pmid", domain);
			    yyerror(mess);
			}
			else if (domain == DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Dynamic metric domain field (%d) for pmid", domain);
			    yywarn(mess);
			}
			if (sts == 2) {
			    /* cluster is <n> */
			    if (cluster >= 4096) {
				pmsprintf(mess, sizeof(mess), "Illegal cluster field (%d) for pmid", cluster);
				yyerror(mess);
			    }
			    current_star_metric = 1;
			}
			else {
			    /* cluster is "*" */
			    cluster = 0;
			    current_star_metric = 2;
			}
			free((yyvsp[0].str));
			(yyval.pmid) = pmID_build(domain, cluster, 0);
		    }
#line 3230 "gram.tab.c"
    break;

  case 95: /* metricopt: TOK_PMID TOK_ASSIGN pmid_int  */
#line 1625 "gram.y"
                    {
			metricspec_t	*mp;
			pmID		pmid;
			for (mp = walk_metric(W_START, METRIC_CHANGE_PMID, "pmid", 0); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_PMID, "pmid", 0)) {
			    if (current_star_metric == 1)
				pmid = pmID_build(pmID_domain((yyvsp[0].pmid)), pmID_cluster((yyvsp[0].pmid)), pmID_item(mp->old_desc.pmid));
			    else if (current_star_metric == 2)
				pmid = pmID_build(pmID_domain((yyvsp[0].pmid)), pmID_cluster(mp->old_desc.pmid), pmID_item(mp->old_desc.pmid));
			    else
				pmid = (yyvsp[0].pmid);
			    if (pmid == mp->old_desc.pmid) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): pmid: No change", mp->old_name, pmIDStr(mp->old_desc.pmid));
				    yywarn(mess);
				}
			    }
			    else {
				mp->new_desc.pmid = pmid;
				mp->flags |= METRIC_CHANGE_PMID;
			    }
			}
		    }
#line 3258 "gram.tab.c"
    break;

  case 96: /* metricopt: TOK_NAME TOK_ASSIGN TOK_GNAME  */
#line 1649 "gram.y"
                    {
			metricspec_t	*mp;
			int		picked = 0;
			for (mp = walk_metric(W_START, METRIC_CHANGE_NAME, "name", 0); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_NAME,  "name", 0)) {
			    if (strcmp((yyvsp[0].str), mp->old_name) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): name: No change", mp->old_name, pmIDStr(mp->old_desc.pmid));
				    yywarn(mess);
				}
			    }
			    else {
				int	sts;
				pmID	pmid;
				sts = pmLookupName(1, (const char **)&(yyvsp[0].str), &pmid);
				if (sts >= 0) {
				    pmsprintf(mess, sizeof(mess), "Metric name %s already assigned for PMID %s", (yyvsp[0].str), pmIDStr(pmid));
				    yyerror(mess);
				}
				mp->new_name = (yyvsp[0].str);
				mp->flags |= METRIC_CHANGE_NAME;
				picked = 1;
			    }
			}
			if (!picked)
			    free((yyvsp[0].str));
		    }
#line 3290 "gram.tab.c"
    break;

  case 97: /* metricopt: TOK_NAME TOK_ASSIGN TOK_GNAME TOK_DUPOK  */
#line 1677 "gram.y"
                    {
			metricspec_t	*mp;
			int		picked = 0;
			for (mp = walk_metric(W_START, METRIC_CHANGE_NAME, "name", 0); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_NAME, "name", 0)) {
			    if (strcmp((yyvsp[-1].str), mp->old_name) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): name: No change", mp->old_name, pmIDStr(mp->old_desc.pmid));
				    yywarn(mess);
				}
			    }
			    else {
				mp->new_name = (yyvsp[-1].str);
				mp->flags |= METRIC_CHANGE_NAME;
				picked = 1;
			    }
			}
			if (!picked)
			    free((yyvsp[-1].str));
		    }
#line 3315 "gram.tab.c"
    break;

  case 98: /* metricopt: TOK_TYPE TOK_ASSIGN TOK_TYPE_NAME  */
#line 1698 "gram.y"
                    {
			metricspec_t	*mp;
			for (mp = walk_metric(W_START, METRIC_CHANGE_TYPE, "type", 0); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_TYPE, "type", 0)) {
			    if ((yyvsp[0].ival) == mp->old_desc.type) {
				/* old == new, so no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): type: PM_TYPE_%s: No change", mp->old_name, pmIDStr(mp->old_desc.pmid), pmTypeStr(mp->old_desc.type));
				    yywarn(mess);
				}
			    }
			    else {
				if (mp->old_desc.type == PM_TYPE_32 ||
				    mp->old_desc.type == PM_TYPE_U32 ||
				    mp->old_desc.type == PM_TYPE_64 ||
				    mp->old_desc.type == PM_TYPE_U64 ||
				    mp->old_desc.type == PM_TYPE_FLOAT ||
				    mp->old_desc.type == PM_TYPE_DOUBLE) {
				    mp->new_desc.type = (yyvsp[0].ival);
				    mp->flags |= METRIC_CHANGE_TYPE;
				}
				else {
				    pmsprintf(mess, sizeof(mess), "Old type (PM_TYPE_%s) must be numeric", pmTypeStr(mp->old_desc.type));
				    yyerror(mess);
				}
			    }
			}
		    }
#line 3347 "gram.tab.c"
    break;

  case 99: /* metricopt: TOK_TYPE TOK_IF TOK_TYPE_NAME TOK_ASSIGN TOK_TYPE_NAME  */
#line 1726 "gram.y"
                    {
			metricspec_t	*mp;
			for (mp = walk_metric(W_START, METRIC_CHANGE_TYPE, "type", 1); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_TYPE, "type", 1)) {
			    if (mp->old_desc.type != (yyvsp[-2].ival)) {
				if (wflag) {
				    char	tbuf0[20];
				    char	tbuf1[20];
				    pmTypeStr_r(mp->old_desc.type, tbuf0, sizeof(tbuf0));
				    pmTypeStr_r((yyvsp[0].ival), tbuf1, sizeof(tbuf1));
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): type: PM_TYPE_%s: No conditional change to PM_TYPE_%s", mp->old_name, pmIDStr(mp->old_desc.pmid), tbuf0, tbuf1);
				    yywarn(mess);
				}
			    }
			    else {
				if (mp->old_desc.type == PM_TYPE_32 ||
				    mp->old_desc.type == PM_TYPE_U32 ||
				    mp->old_desc.type == PM_TYPE_64 ||
				    mp->old_desc.type == PM_TYPE_U64 ||
				    mp->old_desc.type == PM_TYPE_FLOAT ||
				    mp->old_desc.type == PM_TYPE_DOUBLE) {
				    mp->new_desc.type = (yyvsp[0].ival);
				    mp->flags |= METRIC_CHANGE_TYPE;
				}
				else {
				    pmsprintf(mess, sizeof(mess), "Old type (PM_TYPE_%s) must be numeric", pmTypeStr(mp->old_desc.type));
				    yyerror(mess);
				}
			    }
			}
		    }
#line 3382 "gram.tab.c"
    break;

  case 100: /* metricopt: TOK_INDOM TOK_ASSIGN null_or_indom pick  */
#line 1757 "gram.y"
                    {
			metricspec_t	*mp;
			pmInDom		indom;
			for (mp = walk_metric(W_START, METRIC_CHANGE_INDOM, "indom", 0); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_INDOM, "indom", 0)) {
			    if (current_star_indom)
				indom = pmInDom_build(pmInDom_domain((yyvsp[-1].indom)), pmInDom_serial(mp->old_desc.indom));
			    else
				indom = (yyvsp[-1].indom);
			    if (indom == mp->old_desc.indom) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): indom: %s: No change", mp->old_name, pmIDStr(mp->old_desc.pmid), pmInDomStr(mp->old_desc.indom));
				    yywarn(mess);
				}
			    }
			    else {
				if ((output == OUTPUT_MIN ||
					  output == OUTPUT_MAX ||
					  output == OUTPUT_SUM ||
					  output == OUTPUT_AVG) &&
					 mp->old_desc.type != PM_TYPE_32 &&
					 mp->old_desc.type != PM_TYPE_U32 &&
					 mp->old_desc.type != PM_TYPE_64 &&
					 mp->old_desc.type != PM_TYPE_U64 &&
					 mp->old_desc.type != PM_TYPE_FLOAT &&
					 mp->old_desc.type != PM_TYPE_DOUBLE) {
				    pmsprintf(mess, sizeof(mess), "OUTPUT option MIN, MAX, AVG or SUM requires type to be numeric, not PM_TYPE_%s", pmTypeStr(mp->old_desc.type));
				    yyerror(mess);
				}
				mp->new_desc.indom = indom;
				mp->flags |= METRIC_CHANGE_INDOM;
				mp->output = output;
				if (output == OUTPUT_ONE) {
				    mp->one_name = one_name;
				    mp->one_inst = one_inst;
				    if (mp->old_desc.indom == PM_INDOM_NULL)
					/*
					 * singular input, pick first (only)
					 * value, not one_inst matching ...
					 * one_inst used for output instance
					 * id
					 */
					mp->output = OUTPUT_FIRST;
				}
				if (output == OUTPUT_ALL) {
				    /*
				     * No OUTPUT clause, set up the defaults
				     * based on indom types:
				     * non-NULL -> NULL
				     *		OUTPUT_FIRST, inst PM_IN_NULL
				     * NULL -> non-NULL
				     *		OUTPUT_FIRST, inst 0
				     * non-NULL -> non-NULL
				     * 		all instances selected
				     *		(nothing to do for defaults)
				     * NULL -> NULL
				     *		caught above in no change case
				     */
				    if (mp->old_desc.indom != PM_INDOM_NULL &&
				        mp->new_desc.indom == PM_INDOM_NULL) {
					mp->output = OUTPUT_FIRST;
					mp->one_inst = PM_IN_NULL;
				    }
				    else if (mp->old_desc.indom == PM_INDOM_NULL &&
				             mp->new_desc.indom != PM_INDOM_NULL) {
					mp->output = OUTPUT_FIRST;
					mp->one_inst = 0;
				    }
				}
			    }
			}
			output = OUTPUT_ALL;	/* for next time */
		    }
#line 3460 "gram.tab.c"
    break;

  case 101: /* metricopt: TOK_SEM TOK_ASSIGN TOK_SEM_NAME  */
#line 1831 "gram.y"
                    {
			metricspec_t	*mp;
			for (mp = walk_metric(W_START, METRIC_CHANGE_SEM, "sem", 0); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_SEM, "sem", 0)) {
			    if ((yyvsp[0].ival) == mp->old_desc.sem) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): sem: %s: No change", mp->old_name, pmIDStr(mp->old_desc.pmid), SemStr(mp->old_desc.sem));
				    yywarn(mess);
				}
			    }
			    else {
				mp->new_desc.sem = (yyvsp[0].ival);
				mp->flags |= METRIC_CHANGE_SEM;
			    }
			}
		    }
#line 3481 "gram.tab.c"
    break;

  case 102: /* metricopt: TOK_UNITS TOK_ASSIGN signnumber TOK_COMMA signnumber TOK_COMMA signnumber TOK_COMMA TOK_SPACE_NAME TOK_COMMA TOK_TIME_NAME TOK_COMMA TOK_COUNT_NAME rescaleopt  */
#line 1848 "gram.y"
                    {
			metricspec_t	*mp;
			for (mp = walk_metric(W_START, METRIC_CHANGE_UNITS, "units", 0); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_UNITS, "units", 0)) {
			    if ((yyvsp[-11].ival) == mp->old_desc.units.dimSpace &&
			        (yyvsp[-9].ival) == mp->old_desc.units.dimTime &&
			        (yyvsp[-7].ival) == mp->old_desc.units.dimCount &&
			        (yyvsp[-5].ival) == mp->old_desc.units.scaleSpace &&
			        (yyvsp[-3].ival) == mp->old_desc.units.scaleTime &&
			        (yyvsp[-1].ival) == mp->old_desc.units.scaleCount) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): units: %s: No change", mp->old_name, pmIDStr(mp->old_desc.pmid), pmUnitsStr(&mp->old_desc.units));
				    yywarn(mess);
				}
			    }
			    else {
				mp->new_desc.units.dimSpace = (yyvsp[-11].ival);
				mp->new_desc.units.dimTime = (yyvsp[-9].ival);
				mp->new_desc.units.dimCount = (yyvsp[-7].ival);
				mp->new_desc.units.scaleSpace = (yyvsp[-5].ival);
				mp->new_desc.units.scaleTime = (yyvsp[-3].ival);
				mp->new_desc.units.scaleCount = (yyvsp[-1].ival);
				mp->flags |= METRIC_CHANGE_UNITS;
				if ((yyvsp[0].ival) == 1) {
				    if ((yyvsp[-11].ival) == mp->old_desc.units.dimSpace &&
					(yyvsp[-9].ival) == mp->old_desc.units.dimTime &&
					(yyvsp[-7].ival) == mp->old_desc.units.dimCount)
					/* OK, no dim changes */
					mp->flags |= METRIC_RESCALE;
				    else {
					if (wflag) {
					    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): Dimension changed, cannot rescale", mp->old_name, pmIDStr(mp->old_desc.pmid));
					    yywarn(mess);
					}
				    }
				}
				else if (sflag) {
				    if ((yyvsp[-11].ival) == mp->old_desc.units.dimSpace &&
					(yyvsp[-9].ival) == mp->old_desc.units.dimTime &&
					(yyvsp[-7].ival) == mp->old_desc.units.dimCount)
					mp->flags |= METRIC_RESCALE;
				}
			    }
			}
		    }
#line 3531 "gram.tab.c"
    break;

  case 103: /* metricopt: TOK_EXTRAUNITS TOK_ASSIGN signnumber TOK_COMMA signnumber TOK_COMMA signnumber TOK_COMMA TOK_SPACE_NAME TOK_COMMA TOK_TIME_NAME TOK_COMMA TOK_COUNT_NAME TOK_COMMA TOK_MACRO TOK_COMMA TOK_MACRO rescaleopt  */
#line 1894 "gram.y"
                    {
			int		extraUnit = __pmLookupExtraUnit((yyvsp[-3].str));
			int		extraScale;
			metricspec_t	*mp;

			if (extraUnit < 0) {
			    pmsprintf(mess, sizeof(mess), "Unknown extra unit type \"%s\"", (yyvsp[-3].str));
			    yyerror(mess);
			}
			extraScale = __pmLookupExtraScale(extraUnit, (yyvsp[-1].str));
			if (extraScale < 0) {
			    pmsprintf(mess, sizeof(mess), "Unknown extra unit scale \"%s\" for type \"%s\"", (yyvsp[-1].str), (yyvsp[-3].str));
			    yyerror(mess);
			}
			free((yyvsp[-3].str));
			free((yyvsp[-1].str));
			for (mp = walk_metric(W_START, METRIC_CHANGE_UNITS, "units", 0); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_UNITS, "units", 0)) {
			    if ((yyvsp[-15].ival) == mp->old_desc.units.dimSpace &&
			        (yyvsp[-13].ival) == mp->old_desc.units.dimTime &&
			        (yyvsp[-11].ival) == mp->old_desc.units.dimCount &&
			        (yyvsp[-9].ival) == mp->old_desc.units.scaleSpace &&
			        (yyvsp[-7].ival) == mp->old_desc.units.scaleTime &&
			        (yyvsp[-5].ival) == mp->old_desc.units.scaleCount &&
				extraUnit == mp->old_desc.units.extraUnit &&
				extraScale == mp->old_desc.units.extraScale) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): units: %s: No change", mp->old_name, pmIDStr(mp->old_desc.pmid), pmUnitsStr(&mp->old_desc.units));
				    yywarn(mess);
				}
			    }
			    else {
				mp->new_desc.units.dimSpace = (yyvsp[-15].ival);
				mp->new_desc.units.dimTime = (yyvsp[-13].ival);
				mp->new_desc.units.dimCount = (yyvsp[-11].ival);
				mp->new_desc.units.scaleSpace = (yyvsp[-9].ival);
				mp->new_desc.units.scaleTime = (yyvsp[-7].ival);
				mp->new_desc.units.scaleCount = (yyvsp[-5].ival);
				mp->new_desc.units.extraUnit = extraUnit;
				mp->new_desc.units.extraScale = extraScale;
				mp->flags |= METRIC_CHANGE_UNITS;
				if ((yyvsp[0].ival) == 1) {
				    if ((yyvsp[-15].ival) == mp->old_desc.units.dimSpace &&
					(yyvsp[-13].ival) == mp->old_desc.units.dimTime &&
					(yyvsp[-11].ival) == mp->old_desc.units.dimCount)
					/* OK, no dim changes */
					mp->flags |= METRIC_RESCALE;
				    else {
					if (wflag) {
					    pmsprintf(mess, sizeof(mess), "Metric: %s (%s): Dimension changed, cannot rescale", mp->old_name, pmIDStr(mp->old_desc.pmid));
					    yywarn(mess);
					}
				    }
				}
				else if (sflag) {
				    if ((yyvsp[-15].ival) == mp->old_desc.units.dimSpace &&
					(yyvsp[-13].ival) == mp->old_desc.units.dimTime &&
					(yyvsp[-11].ival) == mp->old_desc.units.dimCount)
					mp->flags |= METRIC_RESCALE;
				}
			    }
			}
		    }
#line 3599 "gram.tab.c"
    break;

  case 104: /* metricopt: TOK_METRIC_VALUE optreplace pattern TOK_ASSIGN replacement  */
#line 1958 "gram.y"
                    {
			metricspec_t	*mp;
			for (mp = walk_metric(W_START, METRIC_CHANGE_VALUE, "value", 1); mp != NULL; mp = walk_metric(W_NEXT, METRIC_CHANGE_VALUE, "value", 1)) {
			    value_change_t	*vc_tmp;
			    value_change_t	*vcp;
			    int			sts;

			    if (mp->old_desc.type != PM_TYPE_STRING) {
				pmsprintf(mess, sizeof(mess), "Metric: %s (%s): Type %s not STRING, cannot change value", mp->old_name, pmIDStr(mp->old_desc.pmid), pmTypeStr(mp->old_desc.type));
				free((yyvsp[-2].str));
				free((yyvsp[0].str));
				yywarn(mess);
				continue;
			    }
			    mp->flags |= METRIC_CHANGE_VALUE;
			    mp->nvc++;
			    vc_tmp = (value_change_t *)realloc(mp->vc, mp->nvc * sizeof(value_change_t));
			    if (vc_tmp == NULL) {
				pmsprintf(mess, sizeof(mess), "value_change realloc(%d) failed: %s\n", (int)(mp->nvc * sizeof(value_change_t)), strerror(errno));
				yyerror(mess);
			    }
			    else
				mp->vc = vc_tmp;
			    vcp = &mp->vc[mp->nvc-1];
			    vcp->pat = (yyvsp[-2].str);
			    vcp->replace = (yyvsp[0].str);
			    if (pmDebugOptions.appl5)
				fprintf(stderr, "compiling value regex /%s/\n", vcp->pat);
			    if ((sts = regcomp(&vcp->regex, vcp->pat, REG_EXTENDED)) != 0) {
				size_t	pfx;
				pmstrncat(mess, sizeof(mess), "regcomp error: ");
				pfx = strlen(mess);
				regerror(sts, &vcp->regex, &mess[pfx], sizeof(mess)-pfx-1);
				yyerror(mess);
			    }
			}
		    }
#line 3641 "gram.tab.c"
    break;

  case 105: /* metricopt: TOK_DELETE  */
#line 1996 "gram.y"
                    {
			metricspec_t	*mp;
			for (mp = walk_metric(W_START, METRIC_DELETE, "delete", 1); mp != NULL; mp = walk_metric(W_NEXT, METRIC_DELETE, "delete", 0)) {
			    mp->flags |= METRIC_DELETE;
			}
		    }
#line 3652 "gram.tab.c"
    break;

  case 106: /* metricopt: TOK_PMID TOK_ASSIGN  */
#line 2003 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <domain>.<cluster>.<item> or <domain>.<cluster>.* or <domain>.*.* in pmid clause");
			yyerror(mess);
		    }
#line 3661 "gram.tab.c"
    break;

  case 107: /* metricopt: TOK_NAME TOK_ASSIGN  */
#line 2008 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <metric_name> in iname clause");
			yyerror(mess);
		    }
#line 3670 "gram.tab.c"
    break;

  case 108: /* metricopt: TOK_TYPE TOK_ASSIGN  */
#line 2013 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting XXX (from PM_TYPE_XXX) in type clause");
			yyerror(mess);
		    }
#line 3679 "gram.tab.c"
    break;

  case 109: /* metricopt: TOK_TYPE TOK_IF  */
#line 2018 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting XXX (from PM_TYPE_XXX) after if in type clause");
			yyerror(mess);
		    }
#line 3688 "gram.tab.c"
    break;

  case 110: /* metricopt: TOK_TYPE TOK_IF TOK_TYPE_NAME TOK_ASSIGN  */
#line 2023 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting XXX (from PM_TYPE_XXX) in type clause");
			yyerror(mess);
		    }
#line 3697 "gram.tab.c"
    break;

  case 111: /* metricopt: TOK_INDOM TOK_ASSIGN  */
#line 2028 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <domain>.<serial> or NULL in indom clause");
			yyerror(mess);
		    }
#line 3706 "gram.tab.c"
    break;

  case 112: /* metricopt: TOK_SEM TOK_ASSIGN  */
#line 2033 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting XXX (from PM_SEM_XXX) in sem clause");
			yyerror(mess);
		    }
#line 3715 "gram.tab.c"
    break;

  case 113: /* metricopt: TOK_UNITS TOK_ASSIGN  */
#line 2038 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting 3 numeric values for dim* fields of units");
			yyerror(mess);
		    }
#line 3724 "gram.tab.c"
    break;

  case 114: /* metricopt: TOK_UNITS TOK_ASSIGN signnumber TOK_COMMA signnumber TOK_COMMA signnumber TOK_COMMA  */
#line 2043 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting 0 or XXX (from PM_SPACE_XXX) for scaleSpace field of units");
			yyerror(mess);
		    }
#line 3733 "gram.tab.c"
    break;

  case 115: /* metricopt: TOK_UNITS TOK_ASSIGN signnumber TOK_COMMA signnumber TOK_COMMA signnumber TOK_COMMA TOK_SPACE_NAME TOK_COMMA  */
#line 2048 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting 0 or XXX (from PM_TIME_XXX) for scaleTime field of units");
			yyerror(mess);
		    }
#line 3742 "gram.tab.c"
    break;

  case 116: /* metricopt: TOK_UNITS TOK_ASSIGN signnumber TOK_COMMA signnumber TOK_COMMA signnumber TOK_COMMA TOK_SPACE_NAME TOK_COMMA TOK_TIME_NAME TOK_COMMA  */
#line 2053 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting 0 or ONE for scaleCount field of units");
			yyerror(mess);
		    }
#line 3751 "gram.tab.c"
    break;

  case 117: /* metricopt: TOK_METRIC_VALUE optreplace pattern TOK_ASSIGN  */
#line 2058 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <replacement> in metric value clause");
			yyerror(mess);
		    }
#line 3760 "gram.tab.c"
    break;

  case 118: /* metricopt: TOK_METRIC_VALUE optreplace pattern  */
#line 2063 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting -> in metric value clause");
			yyerror(mess);
		    }
#line 3769 "gram.tab.c"
    break;

  case 119: /* metricopt: TOK_METRIC_VALUE optreplace  */
#line 2068 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting <regular expression> in metric value clause");
			yyerror(mess);
		    }
#line 3778 "gram.tab.c"
    break;

  case 123: /* null_or_indom: TOK_NULL_INT  */
#line 2080 "gram.y"
                    {
			(yyval.indom) = PM_INDOM_NULL;
		    }
#line 3786 "gram.tab.c"
    break;

  case 124: /* pick: TOK_OUTPUT TOK_INST number  */
#line 2086 "gram.y"
                    {
			output = OUTPUT_ONE;
			one_inst = (yyvsp[0].ival);
			one_name = NULL;
		    }
#line 3796 "gram.tab.c"
    break;

  case 125: /* pick: TOK_OUTPUT TOK_INAME TOK_STRING  */
#line 2092 "gram.y"
                    {
			output = OUTPUT_ONE;
			one_inst = PM_IN_NULL;
			one_name = (yyvsp[0].str);
		    }
#line 3806 "gram.tab.c"
    break;

  case 126: /* pick: TOK_OUTPUT TOK_OUTPUT_TYPE  */
#line 2098 "gram.y"
                    {
			output = (yyvsp[0].ival);
		    }
#line 3814 "gram.tab.c"
    break;

  case 127: /* pick: TOK_OUTPUT  */
#line 2102 "gram.y"
                    {
			pmsprintf(mess, sizeof(mess), "Expecting FIRST or LAST or INST or INAME or MIN or MAX or AVG for OUTPUT instance option");
			yyerror(mess);
		    }
#line 3823 "gram.tab.c"
    break;

  case 129: /* rescaleopt: TOK_RESCALE  */
#line 2109 "gram.y"
                              { (yyval.ival) = 1; }
#line 3829 "gram.tab.c"
    break;

  case 130: /* rescaleopt: %empty  */
#line 2111 "gram.y"
                    { (yyval.ival) = 0; }
#line 3835 "gram.tab.c"
    break;

  case 134: /* $@3: %empty  */
#line 2122 "gram.y"
                    {
			__pmContext	*ctxp;
			__pmHashCtl	*hcp1;
			__pmHashNode	*node1;
			int		target_types;
			int		this_type;
			int		type;

			ctxp = __pmHandleToPtr(pmWhichContext());
			assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp,
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			PM_UNLOCK(ctxp->c_lock);
			
			current_textspec = NULL;
			if ((yyvsp[-2].pmid) == PM_ID_NULL) {
			    /* Metric referenced by name is not in the archive */
			    do_walk_text = 0;
			}
			else {
			    int found = 0;
			    
			    if (current_star_metric) {
				/* Set up for metrics specified using globbing. */
				star_domain = pmID_domain((yyvsp[-2].pmid));
				if (current_star_metric == 1)
				    star_cluster = pmID_cluster((yyvsp[-2].pmid));
				else
				    star_cluster = PM_ID_NULL;
			    }

			    /* We're looking for text of the specified type(s) for metric(s). */
			    target_types = PM_TEXT_PMID | (yyvsp[-1].ival);
			    hcp1 = &ctxp->c_archctl->ac_log->hashtext;
			    for (node1 = __pmHashWalk(hcp1, PM_HASH_WALK_START);
				 node1 != NULL;
				 node1 = __pmHashWalk(hcp1, PM_HASH_WALK_NEXT)) {
				__pmHashCtl	*hcp2;
				__pmHashNode	*node2;

				/* Was this object type selected? */
				this_type = (int)(node1->key);
				if ((this_type & target_types) != this_type)
				    continue;

				/*
				 * Collect the text records associated with the specified
				 * metric(s).
				 */
				hcp2 = (__pmHashCtl *)(node1->data);
				for (node2 = __pmHashWalk(hcp2, PM_HASH_WALK_START);
				     node2 != NULL;
				     node2 = __pmHashWalk(hcp2, PM_HASH_WALK_NEXT)) {
				    if (current_star_metric) {
					/* Match the globbed metric spec and keep looking. */
					if (pmID_domain((pmID)(node2->key)) == star_domain &&
					    (star_cluster == PM_ID_NULL ||
					     star_cluster == pmID_cluster((pmID)(node2->key)))) {
					    current_textspec = start_text(this_type, (pmID)(node2->key), (yyvsp[0].str));
					    if (current_textspec) {
						current_textspec->flags |= TEXT_ACTIVE;
						++found;
					    }

					}
				    }
				    else {
					/* Match the exact metric PMID. */
					if ((pmID)(node2->key) == (yyvsp[-2].pmid)) {
					    current_textspec = start_text(this_type, (pmID)(node2->key), (yyvsp[0].str));
					    if (current_textspec) {
						current_textspec->flags |= TEXT_ACTIVE;
						++found;
					    }
					    /*
					     * Stop looking if we have found all of the specified
					     * types.
					     */
					    type = this_type & PM_TEXT_TYPE_MASK;
					    target_types ^= type;
					    if ((target_types & PM_TEXT_TYPE_MASK) == 0)
						break;
					}
				    }
				}
				if ((target_types & PM_TEXT_TYPE_MASK) == 0)
				    break;
			    }
			    do_walk_text = (found > 1);
			}
		    }
#line 3936 "gram.tab.c"
    break;

  case 136: /* opttexttypes: texttypes  */
#line 2222 "gram.y"
                    { (yyval.ival) = (yyvsp[0].ival); }
#line 3942 "gram.tab.c"
    break;

  case 137: /* opttexttypes: %empty  */
#line 2224 "gram.y"
                    { (yyval.ival) = PM_TEXT_ONELINE; }
#line 3948 "gram.tab.c"
    break;

  case 138: /* texttypes: texttype  */
#line 2228 "gram.y"
                    { (yyval.ival) = (yyvsp[0].ival); }
#line 3954 "gram.tab.c"
    break;

  case 139: /* texttypes: texttype texttypes  */
#line 2230 "gram.y"
                    { (yyval.ival) = (yyvsp[-1].ival) | (yyvsp[0].ival); }
#line 3960 "gram.tab.c"
    break;

  case 140: /* texttype: TOK_TEXT_STAR  */
#line 2234 "gram.y"
                    { (yyval.ival) = PM_TEXT_ONELINE | PM_TEXT_HELP; }
#line 3966 "gram.tab.c"
    break;

  case 141: /* texttype: TOK_HELP  */
#line 2236 "gram.y"
                    { (yyval.ival) = PM_TEXT_HELP; }
#line 3972 "gram.tab.c"
    break;

  case 142: /* texttype: TOK_ONELINE  */
#line 2238 "gram.y"
                    { (yyval.ival) = PM_TEXT_ONELINE; }
#line 3978 "gram.tab.c"
    break;

  case 143: /* opttextvalue: textstring  */
#line 2242 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 3984 "gram.tab.c"
    break;

  case 144: /* opttextvalue: %empty  */
#line 2244 "gram.y"
                    { (yyval.str) = NULL; }
#line 3990 "gram.tab.c"
    break;

  case 146: /* opttextmetricoptlist: %empty  */
#line 2249 "gram.y"
                    {
			textspec_t	*tp;
			for (tp = walk_text(W_START, TEXT_ACTIVE, "active", 0); tp != NULL; tp = walk_text(W_NEXT, 0, "", 0)) {
			    tp->flags &= ~TEXT_ACTIVE;
			}
		    }
#line 4001 "gram.tab.c"
    break;

  case 149: /* textmetricopt: TOK_DELETE  */
#line 2262 "gram.y"
                    {
			textspec_t	*tp;
			for (tp = walk_text(W_START, TEXT_DELETE, "delete", 0); tp != NULL; tp = walk_text(W_NEXT, TEXT_DELETE, "delete", 0)) {
			    tp->flags |= TEXT_DELETE;
			}
		    }
#line 4012 "gram.tab.c"
    break;

  case 150: /* textmetricopt: TOK_TEXT TOK_ASSIGN textstring  */
#line 2269 "gram.y"
                    {
			textspec_t	*tp;
			for (tp = walk_text(W_START, TEXT_CHANGE_TEXT, "text", 0); tp != NULL; tp = walk_text(W_NEXT, TEXT_CHANGE_TEXT, "text", 0)) {
			    if (tp->new_text) {
				if (strcmp(tp->new_text, (yyvsp[0].str)) == 0) {
				    pmsprintf(mess, sizeof(mess), "Duplicate text change clause");
				    yyerror(mess);
				}
				else {
				    pmsprintf(mess, sizeof(mess), "Conflicting text change clause");
				    yyerror(mess);
				}
				free((yyvsp[0].str));
			    }
			    else if (strcmp(tp->old_text, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Help text: No change");
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				tp->new_text = (yyvsp[0].str);
				tp->flags |= TEXT_CHANGE_TEXT;
			    }
			}
		    }
#line 4045 "gram.tab.c"
    break;

  case 151: /* textmetricopt: TOK_METRIC TOK_ASSIGN pmid_int  */
#line 2298 "gram.y"
                    {
			textspec_t	*tp;
			pmID		pmid;
			for (tp = walk_text(W_START, TEXT_CHANGE_ID, "id", 0); tp != NULL; tp = walk_text(W_NEXT, TEXT_CHANGE_ID, "id", 0)) {
			    if (current_star_metric == 1)
				pmid = pmID_build(pmID_domain((yyvsp[0].pmid)), pmID_cluster((yyvsp[0].pmid)), pmID_item(tp->old_id));
			    else if (current_star_metric == 2)
				pmid = pmID_build(pmID_domain((yyvsp[0].pmid)), pmID_cluster(tp->old_id), pmID_item(tp->old_id));
			    else
				pmid = (yyvsp[0].pmid);
			    if (pmid == tp->old_id) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Text for metric: %s: metric: No change", pmIDStr(tp->old_id));
				    yywarn(mess);
				}
			    }
			    else {
				const textspec_t *tp1;
				/* Warn if the target metric already has text of this type. */
				/*
				 * Search all of the change specs for others targeting
				 * the same metric.
				 */
				for (tp1 = text_root; tp1 != NULL; tp1 = tp1->t_next) {
				    if (! (tp1->flags & TEXT_CHANGE_ID))
					continue; /* not an id change spec */
				    if (tp1->new_type != tp->new_type)
					continue; /* target is a different type */
				    if (tp1 == tp)
					continue; /* same spec */
				    if (tp1->new_id == pmid) {
					/* conflict with another change spec. */
					pmsprintf(mess, sizeof(mess), "Text for metric: %s: metric: Conflicting metric change", pmIDStr(tp->old_id));
					yyerror(mess);
					break;
				    }
				}
				if (tp1 == NULL) {
				    /* No conflict */
				    tp->new_id = pmid;
				    tp->flags |= TEXT_CHANGE_ID;
				}
			    }
			}
		    }
#line 4096 "gram.tab.c"
    break;

  case 152: /* textstring: TOK_STRING  */
#line 2347 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4102 "gram.tab.c"
    break;

  case 153: /* textstring: TOK_TEXT_STRING  */
#line 2349 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4108 "gram.tab.c"
    break;

  case 154: /* pattern: TOK_PATTERN  */
#line 2353 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4114 "gram.tab.c"
    break;

  case 155: /* pattern: TOK_STRING  */
#line 2355 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4120 "gram.tab.c"
    break;

  case 156: /* replacement: TOK_STRING  */
#line 2359 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4126 "gram.tab.c"
    break;

  case 157: /* replacement: TOK_PATTERN  */
#line 2361 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4132 "gram.tab.c"
    break;

  case 158: /* $@4: %empty  */
#line 2365 "gram.y"
                    {
			__pmContext	*ctxp;
			__pmHashCtl	*hcp1;
			__pmHashNode	*node1;
			int		target_types;
			int		this_type;
			int		type;

			ctxp = __pmHandleToPtr(pmWhichContext());
			assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp,
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			PM_UNLOCK(ctxp->c_lock);
			
			current_textspec = NULL;
			if ((yyvsp[-2].indom) == PM_ID_NULL) {
			    /* Indom is not in the archive */
			    do_walk_text = 0;
			}
			else {
			    int found = 0;
			    
			    if (current_star_indom) {
				/* Set up for indoms specified using globbing. */
				star_domain = pmInDom_domain((yyvsp[-2].indom));
			    }

			    /* We're looking for text of the specified type(s) for indom(s). */
			    target_types = PM_TEXT_INDOM | (yyvsp[-1].ival);
			    hcp1 = &ctxp->c_archctl->ac_log->hashtext;
			    for (node1 = __pmHashWalk(hcp1, PM_HASH_WALK_START);
				 node1 != NULL;
				 node1 = __pmHashWalk(hcp1, PM_HASH_WALK_NEXT)) {
				__pmHashCtl	*hcp2;
				__pmHashNode	*node2;

				/* Was this object type selected? */
				this_type = (int)(node1->key);
				if ((this_type & target_types) != this_type)
				    continue;

				/*
				 * Collect the text records associated with the specified
				 * metric(s).
				 */
				hcp2 = (__pmHashCtl *)(node1->data);
				for (node2 = __pmHashWalk(hcp2, PM_HASH_WALK_START);
				     node2 != NULL;
				     node2 = __pmHashWalk(hcp2, PM_HASH_WALK_NEXT)) {
				    if (current_star_indom) {
					/* Match the globbed metric spec and keep looking. */
					if (pmInDom_domain((pmID)(node2->key)) == star_domain) {
					    current_textspec = start_text(this_type, (pmID)(node2->key), (yyvsp[0].str));
					    if (current_textspec) {
						current_textspec->flags |= TEXT_ACTIVE;
						++found;
					    }
					}
				    }
				    else {
					/* Match the exact indom id. */
					if ((pmID)(node2->key) == (yyvsp[-2].indom)) {
					    current_textspec = start_text(this_type, (pmID)(node2->key), (yyvsp[0].str));
					    if (current_textspec) {
						current_textspec->flags |= TEXT_ACTIVE;
						++found;
					    }
					    /*
					     * Stop looking if we have found all of the specified
					     * types.
					     */
					    type = this_type & PM_TEXT_TYPE_MASK;
					    target_types ^= type;
					    if ((target_types & PM_TEXT_TYPE_MASK) == 0)
						break;
					}
				    }
				}
				if ((target_types & PM_TEXT_TYPE_MASK) == 0)
				    break;
			    }
			    do_walk_text = (found > 1);
			}
		    }
#line 4226 "gram.tab.c"
    break;

  case 161: /* opttextindomoptlist: %empty  */
#line 2459 "gram.y"
                    {
			textspec_t	*tp;
			for (tp = walk_text(W_START, TEXT_ACTIVE, "active", 0); tp != NULL; tp = walk_text(W_NEXT, 0, "", 0)) {
			    tp->flags &= ~TEXT_ACTIVE;
			}
		    }
#line 4237 "gram.tab.c"
    break;

  case 164: /* textindomopt: TOK_DELETE  */
#line 2472 "gram.y"
                    {
			textspec_t	*tp;
			for (tp = walk_text(W_START, TEXT_DELETE, "delete", 0); tp != NULL; tp = walk_text(W_NEXT, TEXT_DELETE, "delete", 0)) {
			    tp->flags |= TEXT_DELETE;
			}
		    }
#line 4248 "gram.tab.c"
    break;

  case 165: /* textindomopt: TOK_TEXT TOK_ASSIGN textstring  */
#line 2479 "gram.y"
                    {
			textspec_t	*tp;
			for (tp = walk_text(W_START, TEXT_CHANGE_TEXT, "text", 0); tp != NULL; tp = walk_text(W_NEXT, TEXT_CHANGE_TEXT, "text", 0)) {
			    if (tp->new_text) {
				if (strcmp(tp->new_text, (yyvsp[0].str)) == 0) {
				    pmsprintf(mess, sizeof(mess), "Duplicate text change clause");
				    yyerror(mess);
				}
				else {
				    pmsprintf(mess, sizeof(mess), "Conflicting text change clause");
				    yyerror(mess);
				}
				free((yyvsp[0].str));
			    }
			    else if (strcmp(tp->old_text, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Help text: No change");
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				tp->new_text = (yyvsp[0].str);
				tp->flags |= TEXT_CHANGE_TEXT;
			    }
			}
		    }
#line 4281 "gram.tab.c"
    break;

  case 166: /* textindomopt: TOK_INDOM TOK_ASSIGN indom_int  */
#line 2508 "gram.y"
                    {
			textspec_t	*tp;
			for (tp = walk_text(W_START, TEXT_CHANGE_ID, "id", 0); tp != NULL; tp = walk_text(W_NEXT, TEXT_CHANGE_ID, "id", 0)) {
			    pmInDom	indom;
			    if (tp->new_id != tp->old_id) {
				pmsprintf(mess, sizeof(mess), "Duplicate text clause for indom %s", pmInDomStr(tp->old_id));
				yyerror(mess);
			    }
			    if (current_star_indom)
				indom = pmInDom_build(pmInDom_domain((yyvsp[0].indom)), pmInDom_serial(tp->old_id));
			    else
				indom = (yyvsp[0].indom);
			    if (indom != tp->old_id) {
				tp->new_id = indom;
				tp->flags |= TEXT_CHANGE_ID;
			    }
			    else {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Text for instance domain %s: indom: No change", pmInDomStr(tp->old_id));
				    yywarn(mess);
				}
			    }
			}
		    }
#line 4311 "gram.tab.c"
    break;

  case 174: /* $@5: %empty  */
#line 2547 "gram.y"
                    {
			__pmContext	*ctxp;
			__pmHashCtl	*hcp1;
			__pmHashNode	*node1;
			int		found = 0;

			ctxp = __pmHandleToPtr(pmWhichContext());
			assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp,
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			PM_UNLOCK(ctxp->c_lock);
			
			/* We're looking for context labels. */
			current_labelspec = NULL;
			hcp1 = &ctxp->c_archctl->ac_log->hashlabels;
			for (node1 = __pmHashWalk(hcp1, PM_HASH_WALK_START);
			     node1 != NULL;
			     node1 = __pmHashWalk(hcp1, PM_HASH_WALK_NEXT)) {
			    __pmHashCtl	*hcp2;
			    __pmHashNode	*node2;
			    int		this_type;

			    /* Was this object type selected? */
			    this_type = (int)(node1->key);
			    if (this_type != PM_LABEL_CONTEXT)
				continue;

			    /*
			     * Collect the label records associated with the specified
			     * metric(s).
			     */
			    hcp2 = (__pmHashCtl *)(node1->data);
			    for (node2 = __pmHashWalk(hcp2, PM_HASH_WALK_START);
				 node2 != NULL;
				 node2 = __pmHashWalk(hcp2, PM_HASH_WALK_NEXT)) {
				/* We want all of the context labels. */
				current_labelspec = start_label(this_type, (pmID)(node2->key), 0, NULL,
								current_label_name, current_label_value);
				if (current_labelspec) {
				    current_labelspec->flags |= LABEL_ACTIVE;
				    ++found;
				}
			    }
			}
			do_walk_label = found;
		    }
#line 4367 "gram.tab.c"
    break;

  case 176: /* optlabeldetails: jsonname optlabelvalue  */
#line 2602 "gram.y"
                    { current_label_name = (yyvsp[-1].str); }
#line 4373 "gram.tab.c"
    break;

  case 177: /* optlabeldetails: TOK_LABEL_STAR optlabelvalue  */
#line 2604 "gram.y"
                    { current_label_name = NULL; }
#line 4379 "gram.tab.c"
    break;

  case 178: /* optlabeldetails: %empty  */
#line 2606 "gram.y"
                    {
			current_label_name = NULL;
			current_label_value = NULL;
		    }
#line 4388 "gram.tab.c"
    break;

  case 179: /* jsonname: TOK_JSON_STRING  */
#line 2613 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4394 "gram.tab.c"
    break;

  case 180: /* jsonname: TOK_STRING  */
#line 2615 "gram.y"
                    {
			(yyval.str) = add_quotes((yyvsp[0].str));
			free((yyvsp[0].str));
		    }
#line 4403 "gram.tab.c"
    break;

  case 181: /* optlabelvalue: jsonvalue  */
#line 2622 "gram.y"
                    { current_label_value = (yyvsp[0].str); }
#line 4409 "gram.tab.c"
    break;

  case 182: /* optlabelvalue: TOK_LABEL_STAR  */
#line 2624 "gram.y"
                    { current_label_value = NULL; }
#line 4415 "gram.tab.c"
    break;

  case 183: /* optlabelvalue: %empty  */
#line 2626 "gram.y"
                    { current_label_value = NULL; }
#line 4421 "gram.tab.c"
    break;

  case 184: /* jsonvalue: jsonname  */
#line 2630 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4427 "gram.tab.c"
    break;

  case 185: /* jsonvalue: jsonnumber  */
#line 2632 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4433 "gram.tab.c"
    break;

  case 186: /* jsonvalue: TOK_JSON_TRUE  */
#line 2634 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4439 "gram.tab.c"
    break;

  case 187: /* jsonvalue: TOK_JSON_FALSE  */
#line 2636 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4445 "gram.tab.c"
    break;

  case 188: /* jsonvalue: TOK_JSON_NULL  */
#line 2638 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4451 "gram.tab.c"
    break;

  case 189: /* jsonnumber: TOK_MINUS TOK_NUMBER  */
#line 2642 "gram.y"
                    {
			(yyval.str) = dupcat("-", (yyvsp[0].str));
			free((yyvsp[0].str));
		    }
#line 4460 "gram.tab.c"
    break;

  case 190: /* jsonnumber: TOK_NUMBER  */
#line 2647 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4466 "gram.tab.c"
    break;

  case 191: /* jsonnumber: TOK_MINUS TOK_JSON_NUMBER  */
#line 2649 "gram.y"
                    {
			(yyval.str) = dupcat("-", (yyvsp[0].str));
			free((yyvsp[0].str));
		    }
#line 4475 "gram.tab.c"
    break;

  case 192: /* jsonnumber: TOK_JSON_NUMBER  */
#line 2654 "gram.y"
                    { (yyval.str) = (yyvsp[0].str); }
#line 4481 "gram.tab.c"
    break;

  case 194: /* optlabelcontextoptlist: %empty  */
#line 2659 "gram.y"
                    {
			deactivate_labels();
		    }
#line 4489 "gram.tab.c"
    break;

  case 197: /* labelcontextopt: TOK_DELETE  */
#line 2669 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_DELETE, "delete", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_DELETE, "delete", 0)) {
			    lp->flags |= LABEL_DELETE;
			}
		    }
#line 4500 "gram.tab.c"
    break;

  case 198: /* labelcontextopt: TOK_LABEL TOK_ASSIGN jsonname  */
#line 2676 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_LABEL, "label", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_LABEL, "label", 0)) {
			    if (lp->new_label != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for context");
				yyerror(mess);
			    }
			    if (lp->old_label != NULL &&
				strcmp(lp->old_label, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for context: label: No change");
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_label = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_LABEL;
			    }
			}
		    }
#line 4527 "gram.tab.c"
    break;

  case 199: /* labelcontextopt: TOK_VALUE TOK_ASSIGN jsonvalue  */
#line 2700 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_VALUE, "value", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_VALUE, "value", 0)) {
			    if (lp->new_value != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label value clause for cluster %d.%d", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_value != NULL &&
				strcmp(lp->old_value, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for cluster %d.%d: value: No change", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_label = lp->old_label;
				lp->new_value = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_VALUE;
			    }
			}
		    }
#line 4555 "gram.tab.c"
    break;

  case 200: /* labelcontextopt: newlabelspec  */
#line 2725 "gram.y"
                    {
			new_context_label();
		    }
#line 4563 "gram.tab.c"
    break;

  case 201: /* newlabelspec: TOK_NEW jsonname jsonvalue  */
#line 2730 "gram.y"
                    {
			/* The current label name and value must both NOT be specified. */
			if (current_label_name || current_label_value) {
			    pmsprintf(mess, sizeof(mess), "The target label name and value must both not be specified for a NEW label and will be ignored");
			    yywarn(mess);
			    if (current_label_name)
				free(current_label_name);
			    if (current_label_value)
				free(current_label_value);
			}
			current_label_name = (yyvsp[-1].str);
			current_label_value = (yyvsp[0].str);
		    }
#line 4581 "gram.tab.c"
    break;

  case 202: /* $@6: %empty  */
#line 2745 "gram.y"
                    {
			__pmContext	*ctxp;
			__pmHashCtl	*hcp1;
			__pmHashNode	*node1;
			int		 found = 0;

			ctxp = __pmHandleToPtr(pmWhichContext());
			assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp,
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			PM_UNLOCK(ctxp->c_lock);
			
			current_labelspec = NULL;
			assert ((yyvsp[-1].ival) != PM_ID_NULL);
			current_label_id = (yyvsp[-1].ival);
			    
			/* We're looking for domain labels. */
			hcp1 = &ctxp->c_archctl->ac_log->hashlabels;
			for (node1 = __pmHashWalk(hcp1, PM_HASH_WALK_START);
			     node1 != NULL;
			     node1 = __pmHashWalk(hcp1, PM_HASH_WALK_NEXT)) {
			    __pmHashCtl	*hcp2;
			    __pmHashNode	*node2;
			    int		this_type;

			    /* Was this object type selected? */
			    this_type = (int)(node1->key);
			    if (this_type != PM_LABEL_DOMAIN)
				continue;

			    /*
			     * Collect the label records associated with the specified
			     * metric domain.
			     */
			    hcp2 = (__pmHashCtl *)(node1->data);
			    for (node2 = __pmHashWalk(hcp2, PM_HASH_WALK_START);
				 node2 != NULL;
				 node2 = __pmHashWalk(hcp2, PM_HASH_WALK_NEXT)) {
				/* Match the exact metric domain. */
				if ((pmID)(node2->key) == (yyvsp[-1].ival)) {
				    current_labelspec = start_label(this_type, (pmID)(node2->key), 0, NULL,
								    current_label_name, current_label_value);
				    if (current_labelspec) {
					current_labelspec->flags |= LABEL_ACTIVE;
					++found;
				    }
				}
			    }
			}
			do_walk_label = found;
		    }
#line 4642 "gram.tab.c"
    break;

  case 204: /* pmid_domain: TOK_NUMBER  */
#line 2805 "gram.y"
                    {
			int	domain;
			/* TOK_NUMBER => domain >= 0 after sscanf */
			sscanf((yyvsp[0].str), "%d", &domain);
			if (domain > DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Illegal domain field (%d) for pmid", domain);
			    yyerror(mess);
			}
			else if (domain == DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Dynamic metric domain field (%d) for pmid", domain);
			    yywarn(mess);
			}
			current_star_metric = 0;
			free((yyvsp[0].str));
			(yyval.ival) = domain;
		    }
#line 4663 "gram.tab.c"
    break;

  case 206: /* optlabeldomainoptlist: %empty  */
#line 2825 "gram.y"
                    {
			deactivate_labels();
		    }
#line 4671 "gram.tab.c"
    break;

  case 209: /* labeldomainopt: TOK_DELETE  */
#line 2835 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_DELETE, "delete", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_DELETE, "delete", 0)) {
			    lp->flags |= LABEL_DELETE;
			}
		    }
#line 4682 "gram.tab.c"
    break;

  case 210: /* labeldomainopt: TOK_DOMAIN TOK_ASSIGN TOK_NUMBER  */
#line 2842 "gram.y"
                    {
			labelspec_t	*lp;
			int		domain;
			/* TOK_NUMBER => domain >= 0 after sscanf */
			sscanf((yyvsp[0].str), "%d", &domain);
			if (domain >= DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Illegal domain field (%d) for label", domain);
			    yyerror(mess);
			}
			free((yyvsp[0].str));
			for (lp = walk_label(W_START, LABEL_CHANGE_ID, "id", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_ID, "id", 0)) {
			    if (domain == lp->old_id) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for metric domain: %d: No change", lp->old_id);
				    yywarn(mess);
				}
			    }
			    else {
				/*
				 * No need to check for conflicts. Multiple label set records for
				 * the same domain are ok.
				 */
				lp->new_id = domain;
				lp->flags |= LABEL_CHANGE_ID;
			    }
			}
		    }
#line 4715 "gram.tab.c"
    break;

  case 211: /* labeldomainopt: TOK_LABEL TOK_ASSIGN jsonname  */
#line 2871 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_LABEL, "label", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_LABEL, "label", 0)) {
			    if (lp->new_label != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for domain %d", lp->old_id);
				yyerror(mess);
			    }
			    if (lp->old_label != NULL &&
				strcmp(lp->old_label, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for domain %d: label: No change", lp->old_id);
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_label = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_LABEL;
			    }
			}
		    }
#line 4742 "gram.tab.c"
    break;

  case 212: /* labeldomainopt: TOK_VALUE TOK_ASSIGN jsonvalue  */
#line 2895 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_VALUE, "value", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_VALUE, "value", 0)) {
			    if (lp->new_value != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label value clause for cluster %d.%d", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_value != NULL &&
				strcmp(lp->old_value, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for cluster %d.%d: value: No change", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_value = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_VALUE;
			    }
			}
		    }
#line 4769 "gram.tab.c"
    break;

  case 213: /* labeldomainopt: newlabelspec  */
#line 2919 "gram.y"
                    {
			new_domain_label(current_label_id);
		    }
#line 4777 "gram.tab.c"
    break;

  case 214: /* $@7: %empty  */
#line 2925 "gram.y"
                    {
			__pmContext	*ctxp;
			__pmHashCtl	*hcp1;
			__pmHashNode	*node1;
			int		found = 0;

			ctxp = __pmHandleToPtr(pmWhichContext());
			assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp,
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			PM_UNLOCK(ctxp->c_lock);
			
			current_labelspec = NULL;
			assert ((yyvsp[-1].ival) != PM_ID_NULL);
			current_label_id = (yyvsp[-1].ival);
			    
			if (current_star_metric) {
			    /* Set up for metrics specified using globbing. */
			    star_domain = pmID_domain((yyvsp[-1].ival));
			    star_cluster = PM_ID_NULL;
			}

			/* We're looking for cluster labels. */
			hcp1 = &ctxp->c_archctl->ac_log->hashlabels;
			for (node1 = __pmHashWalk(hcp1, PM_HASH_WALK_START);
			     node1 != NULL;
			     node1 = __pmHashWalk(hcp1, PM_HASH_WALK_NEXT)) {
			    __pmHashCtl		*hcp2;
			    __pmHashNode	*node2;
			    int			this_type;

			    /* Was this object type selected? */
			    this_type = (int)(node1->key);
			    if (this_type != PM_LABEL_CLUSTER)
				continue;

			    /*
			     * Collect the label records associated with the specified
			     * metric(s).
			     */
			    hcp2 = (__pmHashCtl *)(node1->data);
			    for (node2 = __pmHashWalk(hcp2, PM_HASH_WALK_START);
				 node2 != NULL;
				 node2 = __pmHashWalk(hcp2, PM_HASH_WALK_NEXT)) {
				if (current_star_metric) {
				    /* Match the globbed cluster spec and keep looking. */
				    if (pmID_domain((pmID)(node2->key)) == star_domain) {
					current_labelspec = start_label(this_type, (pmID)(node2->key), 0, NULL,
									current_label_name, current_label_value);
					if (current_labelspec) {
					    current_labelspec->flags |= LABEL_ACTIVE;
					    ++found;
					}
				    }
				}
				else {
				    /* Match the exact cluster spec. */
				    if ((pmID)(node2->key) == (yyvsp[-1].ival)) {
					current_labelspec = start_label(this_type, (pmID)(node2->key), 0, NULL,
									current_label_name, current_label_value);
					if (current_labelspec) {
					    current_labelspec->flags |= LABEL_ACTIVE;
					    ++found;
					}
				    }
				}
			    }
			}
			do_walk_label = found;
		    }
#line 4857 "gram.tab.c"
    break;

  case 216: /* pmid_cluster: TOK_FLOAT  */
#line 3004 "gram.y"
                    {
			int	domain;
			int	cluster;
			/* TOK_FLOAT => domain >= 0 && serial >= 0 after sscanf */
			sscanf((yyvsp[0].str), "%d.%d", &domain, &cluster);
			if (domain > DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Illegal domain field (%d) for pmid", domain);
			    yyerror(mess);
			}
			else if (domain == DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Dynamic metric domain field (%d) for pmid", domain);
			    yywarn(mess);
			}
			if (cluster >= 4096) {
			    pmsprintf(mess, sizeof(mess), "Illegal cluster field (%d) for pmid", cluster);
			    yyerror(mess);
			}
			current_star_metric = 0;
			free((yyvsp[0].str));
			(yyval.ival) = pmID_build(domain, cluster, 0);
		    }
#line 4883 "gram.tab.c"
    break;

  case 217: /* pmid_cluster: TOK_INDOM_STAR  */
#line 3026 "gram.y"
                    {
			int	domain;
			/* TOK_INDOM_STAR => domain >= 0 after sscanf */
			sscanf((yyvsp[0].str), "%d.", &domain);
			if (domain > DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Illegal domain field (%d) for pmid", domain);
			    yyerror(mess);
			}
			else if (domain == DYNAMIC_PMID) {
			    pmsprintf(mess, sizeof(mess), "Dynamic metric domain field (%d) for pmid", domain);
			    yywarn(mess);
			}
			current_star_metric = 1;
			free((yyvsp[0].str));
			(yyval.ival) = pmID_build(domain, 0, 0);
		    }
#line 4904 "gram.tab.c"
    break;

  case 219: /* optlabelclusteroptlist: %empty  */
#line 3046 "gram.y"
                    {
			deactivate_labels();
		    }
#line 4912 "gram.tab.c"
    break;

  case 222: /* labelclusteropt: TOK_DELETE  */
#line 3056 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_DELETE, "delete", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_DELETE, "delete", 0)) {
			    lp->flags |= LABEL_DELETE;
			}
		    }
#line 4923 "gram.tab.c"
    break;

  case 223: /* labelclusteropt: TOK_CLUSTER TOK_ASSIGN pmid_cluster  */
#line 3063 "gram.y"
                    {
			labelspec_t	*lp;
			int		cluster;
			for (lp = walk_label(W_START, LABEL_CHANGE_ID, "id", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_ID, "id", 0)) {
			    if (current_star_metric)
				cluster = pmID_build(pmID_domain((yyvsp[0].ival)), pmID_cluster(lp->old_id), PM_ID_NULL);
			    else
				cluster = pmID_build(pmID_domain((yyvsp[0].ival)), pmID_cluster((yyvsp[0].ival)), PM_ID_NULL);
			    if (cluster == lp->old_id) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for cluster: %d.%d: No change", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				    yywarn(mess);
				}
			    }
			    else {
				/*
				 * No need to check for conflicts. Multiple label set records for
				 * the same cluster are ok.
				 */
				lp->new_id = cluster;
				lp->flags |= LABEL_CHANGE_ID;
			    }
			}
		    }
#line 4953 "gram.tab.c"
    break;

  case 224: /* labelclusteropt: TOK_LABEL TOK_ASSIGN jsonname  */
#line 3089 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_LABEL, "label", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_LABEL, "label", 0)) {
			    if (lp->new_label != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for cluster %d.%d", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_label != NULL &&
				strcmp(lp->old_label, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for cluster %d.%d: label: No change", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_label = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_LABEL;
			    }
			}
		    }
#line 4980 "gram.tab.c"
    break;

  case 225: /* labelclusteropt: TOK_VALUE TOK_ASSIGN jsonvalue  */
#line 3112 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_VALUE, "value", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_VALUE, "value", 0)) {
			    if (lp->new_value != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label value clause for cluster %d.%d", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_value != NULL &&
				strcmp(lp->old_value, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for cluster %d.%d: value: No change", pmID_domain(lp->old_id), pmID_cluster(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_value = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_VALUE;
			    }
			}
		    }
#line 5007 "gram.tab.c"
    break;

  case 226: /* labelclusteropt: newlabelspec  */
#line 3135 "gram.y"
                    {
			new_cluster_label(current_label_id);
		    }
#line 5015 "gram.tab.c"
    break;

  case 227: /* $@8: %empty  */
#line 3141 "gram.y"
                    {
			__pmContext	*ctxp;
			__pmHashCtl	*hcp1;
			__pmHashNode	*node1;

			ctxp = __pmHandleToPtr(pmWhichContext());
			assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp,
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			PM_UNLOCK(ctxp->c_lock);
			
			current_labelspec = NULL;
			current_label_id = (yyvsp[-1].pmid);
			if ((yyvsp[-1].pmid) == PM_ID_NULL) {
			    /* Metric referenced by name is not in the archive */
			    do_walk_label = 0;
			}
			else {
			    int found = 0;
			    
			    if (current_star_metric) {
				/* Set up for metrics specified using globbing. */
				star_domain = pmID_domain((yyvsp[-1].pmid));
				if (current_star_metric == 1)
				    star_cluster = pmID_cluster((yyvsp[-1].pmid));
				else
				    star_cluster = PM_ID_NULL;
			    }

			    /* We're looking for item labels. */
			    hcp1 = &ctxp->c_archctl->ac_log->hashlabels;
			    for (node1 = __pmHashWalk(hcp1, PM_HASH_WALK_START);
				 node1 != NULL;
				 node1 = __pmHashWalk(hcp1, PM_HASH_WALK_NEXT)) {
				__pmHashCtl	*hcp2;
				__pmHashNode	*node2;
				int		this_type;

				/* Was this object type selected? */
				this_type = (int)(node1->key);
				if (this_type != PM_LABEL_ITEM)
				    continue;

				/*
				 * Collect the label records associated with the specified
				 * metric(s).
				 */
				hcp2 = (__pmHashCtl *)(node1->data);
				for (node2 = __pmHashWalk(hcp2, PM_HASH_WALK_START);
				     node2 != NULL;
				     node2 = __pmHashWalk(hcp2, PM_HASH_WALK_NEXT)) {
				    if (current_star_metric) {
					/* Match the globbed metric spec and keep looking. */
					if (pmID_domain((pmID)(node2->key)) == star_domain &&
					    (star_cluster == PM_ID_NULL ||
					     star_cluster == pmID_cluster((pmID)(node2->key)))) {
					    current_labelspec = start_label(this_type, (pmID)(node2->key), 0, NULL,
									    current_label_name, current_label_value);
					    if (current_labelspec) {
						current_labelspec->flags |= LABEL_ACTIVE;
						++found;
					    }

					}
				    }
				    else {
					/* Match the exact metric PMID. */
					if ((pmID)(node2->key) == (yyvsp[-1].pmid)) {
					    current_labelspec = start_label(this_type, (pmID)(node2->key), 0, NULL,
									    current_label_name, current_label_value);
					    if (current_labelspec) {
						current_labelspec->flags |= LABEL_ACTIVE;
						++found;
					    }
					}
				    }
				}
			    }
			    do_walk_label = found;
			}
		    }
#line 5106 "gram.tab.c"
    break;

  case 230: /* optlabelitemoptlist: %empty  */
#line 3232 "gram.y"
                    {
			deactivate_labels();
		    }
#line 5114 "gram.tab.c"
    break;

  case 233: /* labelitemopt: TOK_DELETE  */
#line 3242 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_DELETE, "delete", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_DELETE, "delete", 0)) {
			    lp->flags |= LABEL_DELETE;
			}
		    }
#line 5125 "gram.tab.c"
    break;

  case 234: /* labelitemopt: TOK_ITEM TOK_ASSIGN pmid_int  */
#line 3249 "gram.y"
                    {
			labelspec_t	*lp;
			pmID		pmid;
			for (lp = walk_label(W_START, LABEL_CHANGE_ID, "id", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_ID, "id", 0)) {
			    if (current_star_metric == 1)
				pmid = pmID_build(pmID_domain((yyvsp[0].pmid)), pmID_cluster((yyvsp[0].pmid)), pmID_item(lp->old_id));
			    else if (current_star_metric == 2)
				pmid = pmID_build(pmID_domain((yyvsp[0].pmid)), pmID_cluster(lp->old_id), pmID_item(lp->old_id));
			    else
				pmid = (yyvsp[0].pmid);
			    if (pmid == lp->old_id) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for metric: %s: item: No change", pmIDStr(lp->old_id));
				    yywarn(mess);
				}
			    }
			    else {
				/*
				 * No need to check for conflicts. Multiple label set records for
				 * the same pmid are ok.
				 */
				lp->new_id = pmid;
				lp->flags |= LABEL_CHANGE_ID;
			    }
			}
		    }
#line 5157 "gram.tab.c"
    break;

  case 235: /* labelitemopt: TOK_LABEL TOK_ASSIGN jsonname  */
#line 3277 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_LABEL, "label", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_LABEL, "label", 0)) {
			    if (lp->new_label != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for metric %s", pmIDStr(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_label != NULL &&
				strcmp(lp->old_label, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for metric %s: label: No change", pmIDStr(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_label = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_LABEL;
			    }
			}
		    }
#line 5184 "gram.tab.c"
    break;

  case 236: /* labelitemopt: TOK_VALUE TOK_ASSIGN jsonvalue  */
#line 3300 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_VALUE, "value", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_VALUE, "value", 0)) {
			    if (lp->new_value != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label value clause for metric %s", pmIDStr(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_value != NULL &&
				strcmp(lp->old_value, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for metric %s: value: No change", pmIDStr(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_value = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_VALUE;
			    }
			}
		    }
#line 5211 "gram.tab.c"
    break;

  case 237: /* labelitemopt: newlabelspec  */
#line 3323 "gram.y"
                    {
			new_item_label(current_label_id);
		    }
#line 5219 "gram.tab.c"
    break;

  case 238: /* $@9: %empty  */
#line 3329 "gram.y"
                    {
			__pmContext	*ctxp;
			__pmHashCtl	*hcp1;
			__pmHashNode	*node1;

			ctxp = __pmHandleToPtr(pmWhichContext());
			assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp,
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			PM_UNLOCK(ctxp->c_lock);
			
			current_labelspec = NULL;
			current_label_id = (yyvsp[-1].indom);
			if ((yyvsp[-1].indom) == PM_ID_NULL) {
			    /* Indom is not in the archive */
			    do_walk_label = 0;
			}
			else {
			    int found = 0;
			    
			    if (current_star_indom) {
				/* Set up for indoms specified using globbing. */
				star_domain = pmInDom_domain((yyvsp[-1].indom));
			    }

			    /* We're looking for label sets for indom(s). */
			    hcp1 = &ctxp->c_archctl->ac_log->hashlabels;
			    for (node1 = __pmHashWalk(hcp1, PM_HASH_WALK_START);
				 node1 != NULL;
				 node1 = __pmHashWalk(hcp1, PM_HASH_WALK_NEXT)) {
				__pmHashCtl	*hcp2;
				__pmHashNode	*node2;
				int		this_type;

				/* Was this object type selected? */
				this_type = (int)(node1->key);
				if (this_type != PM_LABEL_INDOM)
				    continue;

				/*
				 * Collect the label records associated with the specified
				 * imdom(s).
				 */
				hcp2 = (__pmHashCtl *)(node1->data);
				for (node2 = __pmHashWalk(hcp2, PM_HASH_WALK_START);
				     node2 != NULL;
				     node2 = __pmHashWalk(hcp2, PM_HASH_WALK_NEXT)) {
				    if (current_star_indom) {
					/* Match the globbed indom spec and keep looking. */
					if (pmInDom_domain((pmID)(node2->key)) == star_domain) {
					    current_labelspec = start_label(this_type, (pmID)(node2->key), 0, NULL,
									    current_label_name, current_label_value);
					    if (current_labelspec) {
						current_labelspec->flags |= LABEL_ACTIVE;
						++found;
					    }
					}
				    }
				    else {
					/* Match the exact indom id. */
					if ((pmID)(node2->key) == (yyvsp[-1].indom)) {
					    current_labelspec = start_label(this_type, (pmID)(node2->key), 0, NULL,
									    current_label_name, current_label_value);
					    if (current_labelspec) {
						current_labelspec->flags |= LABEL_ACTIVE;
						++found;
					    }
					}
				    }
				}
			    }
			    do_walk_label = found;
			}
		    }
#line 5303 "gram.tab.c"
    break;

  case 241: /* optlabelindomoptlist: %empty  */
#line 3413 "gram.y"
                    {
			deactivate_labels();
		    }
#line 5311 "gram.tab.c"
    break;

  case 244: /* labelindomopt: TOK_DELETE  */
#line 3423 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_DELETE, "delete", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_DELETE, "delete", 0)) {
			    lp->flags |= LABEL_DELETE;
			}
		    }
#line 5322 "gram.tab.c"
    break;

  case 245: /* labelindomopt: TOK_INDOM TOK_ASSIGN indom_int  */
#line 3430 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_ID, "id", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_ID, "id", 0)) {
			    pmInDom	indom;
			    if (lp->new_id != lp->old_id) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for indom %s", pmInDomStr(lp->old_id));
				yyerror(mess);
			    }
			    if (current_star_indom)
				indom = pmInDom_build(pmInDom_domain((yyvsp[0].indom)), pmInDom_serial(lp->old_id));
			    else
				indom = (yyvsp[0].indom);
			    if (indom != lp->old_id) {
				lp->new_id = indom;
				lp->flags |= LABEL_CHANGE_ID;
			    }
			    else {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for instance domain %s: indom: No change", pmInDomStr(lp->old_id));
				    yywarn(mess);
				}
			    }
			}
		    }
#line 5352 "gram.tab.c"
    break;

  case 246: /* labelindomopt: TOK_LABEL TOK_ASSIGN jsonname  */
#line 3456 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_LABEL, "label", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_LABEL, "label", 0)) {
			    if (lp->new_label != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for indom %s", pmInDomStr(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_label != NULL &&
				strcmp(lp->old_label, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for instance domain %s: label: No change", pmInDomStr(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_label = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_LABEL;
			    }
			}
		    }
#line 5379 "gram.tab.c"
    break;

  case 247: /* labelindomopt: TOK_VALUE TOK_ASSIGN jsonvalue  */
#line 3479 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_VALUE, "value", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_VALUE, "value", 0)) {
			    if (lp->new_value != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label value clause for indom %s", pmInDomStr(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_value != NULL &&
				strcmp(lp->old_value, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for instance domain %s: value: No change", pmInDomStr(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_value = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_VALUE;
			    }
			}
		    }
#line 5406 "gram.tab.c"
    break;

  case 248: /* labelindomopt: newlabelspec  */
#line 3502 "gram.y"
                    {
			new_indom_label(current_label_id);
		    }
#line 5414 "gram.tab.c"
    break;

  case 249: /* $@10: %empty  */
#line 3508 "gram.y"
                    {
			__pmContext	*ctxp;
			__pmHashCtl	*hcp1;
			__pmHashNode	*node1;

			ctxp = __pmHandleToPtr(pmWhichContext());
			assert(ctxp != NULL);
    /*
     * Note: This application is single threaded, and once we have ctxp,
     *	     the associated __pmContext will not move and will only be
     *	     accessed or modified synchronously either here or in libpcp.
     *	     We unlock the context so that it can be locked as required
     *	     within libpcp.
     */
			PM_UNLOCK(ctxp->c_lock);
			
			current_labelspec = NULL;
			current_label_id = (yyvsp[-1].indom);
			if ((yyvsp[-1].indom) == PM_ID_NULL) {
			    /* Indom is not in the archive */
			    do_walk_label = 0;
			}
			else {
			    int found = 0;
			    
			    if (current_star_indom) {
				/* Set up for indoms specified using globbing. */
				star_domain = pmInDom_domain((yyvsp[-1].indom));
			    }

			    /* We're looking for label sets for the instances of the indom(s). */
			    hcp1 = &ctxp->c_archctl->ac_log->hashlabels;
			    for (node1 = __pmHashWalk(hcp1, PM_HASH_WALK_START);
				 node1 != NULL;
				 node1 = __pmHashWalk(hcp1, PM_HASH_WALK_NEXT)) {
				__pmHashCtl	*hcp2;
				__pmHashNode	*node2;
				int		this_type;

				/* Was this object type selected? */
				this_type = (int)(node1->key);
				if (this_type != PM_LABEL_INSTANCES)
				    continue;

				/*
				 * Collect the label records associated with the specified
				 * indom instance(s).
				 */
				hcp2 = (__pmHashCtl *)(node1->data);
				for (node2 = __pmHashWalk(hcp2, PM_HASH_WALK_START);
				     node2 != NULL;
				     node2 = __pmHashWalk(hcp2, PM_HASH_WALK_NEXT)) {
				    if (current_star_indom) {
					/* Match the globbed indom spec and keep looking. */
					if (pmInDom_domain((pmID)(node2->key)) == star_domain) {
					    current_labelspec = start_label(this_type, (pmID)(node2->key),
									    current_label_instance, current_label_instance_name,
									    current_label_name, current_label_value);
					    if (current_labelspec) {
						current_labelspec->flags |= LABEL_ACTIVE;
						++found;
					    }
					}
				    }
				    else {
					/* Match the exact indom id. */
					if ((pmID)(node2->key) == (yyvsp[-1].indom)) {
					    current_labelspec = start_label(this_type, (pmID)(node2->key),
									    current_label_instance, current_label_instance_name,
									    current_label_name, current_label_value);
					    if (current_labelspec) {
						current_labelspec->flags |= LABEL_ACTIVE;
						++found;
					    }
					}
				    }
				}
			    }
			    do_walk_label = found;
			}
		    }
#line 5500 "gram.tab.c"
    break;

  case 251: /* optinstancelabeldetails: TOK_STRING optlabeldetails  */
#line 3593 "gram.y"
                    {
			current_label_instance = -1;
			current_label_instance_name = (yyvsp[-1].str);
		    }
#line 5509 "gram.tab.c"
    break;

  case 252: /* optinstancelabeldetails: TOK_NUMBER optlabeldetails  */
#line 3598 "gram.y"
                    {
			current_label_instance = atoi((yyvsp[-1].str));
			free((yyvsp[-1].str));
			current_label_instance_name = NULL;
		    }
#line 5519 "gram.tab.c"
    break;

  case 253: /* optinstancelabeldetails: TOK_LABEL_STAR optlabeldetails  */
#line 3604 "gram.y"
                    {
			current_label_instance = -1;
			current_label_instance_name = NULL;
		    }
#line 5528 "gram.tab.c"
    break;

  case 254: /* optinstancelabeldetails: %empty  */
#line 3609 "gram.y"
                    {
			current_label_instance = -1;
			current_label_instance_name = NULL;
			current_label_name = NULL;
			current_label_value = NULL;
		    }
#line 5539 "gram.tab.c"
    break;

  case 256: /* optlabelinstancesoptlist: %empty  */
#line 3619 "gram.y"
                    {
			deactivate_labels();
		    }
#line 5547 "gram.tab.c"
    break;

  case 259: /* labelinstancesopt: TOK_DELETE  */
#line 3629 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_DELETE, "delete", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_DELETE, "delete", 0)) {
			    lp->flags |= LABEL_DELETE;
			}
		    }
#line 5558 "gram.tab.c"
    break;

  case 260: /* labelinstancesopt: TOK_INSTANCES TOK_ASSIGN indom_int  */
#line 3636 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_ID, "id", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_ID, "id", 0)) {
			    pmInDom	indom;
			    if (lp->new_id != lp->old_id) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for instances of indom %s", pmInDomStr(lp->old_id));
				yyerror(mess);
			    }
			    if (current_star_indom)
				indom = pmInDom_build(pmInDom_domain((yyvsp[0].indom)), pmInDom_serial(lp->old_id));
			    else
				indom = (yyvsp[0].indom);
			    if (indom != lp->old_id) {
				lp->new_id = indom;
				lp->flags |= LABEL_CHANGE_ID;
			    }
			    else {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for instance domain %s: indom: No change", pmInDomStr(lp->old_id));
				    yywarn(mess);
				}
			    }
			}
		    }
#line 5588 "gram.tab.c"
    break;

  case 261: /* labelinstancesopt: TOK_INSTANCE TOK_ASSIGN TOK_NUMBER  */
#line 3662 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_ID, "id", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_ID, "id", 0)) {
			    int	instance;
			    if (lp->new_instance != lp->old_instance) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for instances of indom %s", pmInDomStr(lp->old_id));
				yyerror(mess);
			    }
			    instance = atoi((yyvsp[0].str));
			    free((yyvsp[0].str));
			    if (instance != lp->old_instance) {
				lp->new_instance = instance;
				lp->flags |= LABEL_CHANGE_INSTANCE;
			    }
			    else {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for instance domain %s instance %d: instance: No change", pmInDomStr(lp->old_id), lp->old_instance);
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			}
		    }
#line 5617 "gram.tab.c"
    break;

  case 262: /* labelinstancesopt: TOK_LABEL TOK_ASSIGN jsonname  */
#line 3687 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_LABEL, "label", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_LABEL, "label", 0)) {
			    if (lp->new_label != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label clause for instances of indom %s", pmInDomStr(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_label != NULL &&
				strcmp(lp->old_label, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for instances of instance domain %s: label: No change", pmInDomStr(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_label = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_LABEL;
			    }
			}
		    }
#line 5644 "gram.tab.c"
    break;

  case 263: /* labelinstancesopt: TOK_VALUE TOK_ASSIGN jsonvalue  */
#line 3710 "gram.y"
                    {
			labelspec_t	*lp;
			for (lp = walk_label(W_START, LABEL_CHANGE_VALUE, "value", 0); lp != NULL; lp = walk_label(W_NEXT, LABEL_CHANGE_VALUE, "value", 0)) {
			    if (lp->new_value != NULL) {
				pmsprintf(mess, sizeof(mess), "Duplicate label value clause for instances of indom %s", pmInDomStr(lp->old_id));
				yyerror(mess);
			    }
			    if (lp->old_value != NULL &&
				strcmp(lp->old_value, (yyvsp[0].str)) == 0) {
				/* no change ... */
				if (wflag) {
				    pmsprintf(mess, sizeof(mess), "Label for instances of instance domain %s: value: No change", pmInDomStr(lp->old_id));
				    yywarn(mess);
				}
				free((yyvsp[0].str));
			    }
			    else {
				lp->new_value = (yyvsp[0].str);
				lp->flags |= LABEL_CHANGE_VALUE;
			    }
			}
		    }
#line 5671 "gram.tab.c"
    break;

  case 264: /* labelinstancesopt: newlabelspec  */
#line 3733 "gram.y"
                    {
			new_indom_instance_label(current_label_id);
		    }
#line 5679 "gram.tab.c"
    break;


#line 5683 "gram.tab.c"

      default: break;
    }
  /* User semantic actions sometimes alter yychar, and that requires
     that yytoken be updated with the new translation.  We take the
     approach of translating immediately before every use of yytoken.
     One alternative is translating here after every semantic action,
     but that translation would be missed if the semantic action invokes
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
     incorrect destructor might then be invoked immediately.  In the
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
     to an incorrect destructor call or verbose syntax error message
     before the lookahead is translated.  */
  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);

  YYPOPSTACK (yylen);
  yylen = 0;

  *++yyvsp = yyval;

  /* Now 'shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */
  {
    const int yylhs = yyr1[yyn] - YYNTOKENS;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }

  goto yynewstate;


/*--------------------------------------.
| yyerrlab -- here on detecting error.  |
`--------------------------------------*/
yyerrlab:
  /* Make sure we have latest lookahead translation.  See comments at
     user semantic actions for why this is necessary.  */
  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror (YY_("syntax error"));
    }

  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
         error, discard it.  */

      if (yychar <= YYEOF)
        {
          /* Return failure if at end of input.  */
          if (yychar == YYEOF)
            YYABORT;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = YYEMPTY;
        }
    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:
  /* Pacify compilers when the user code never invokes YYERROR and the
     label yyerrorlab therefore never appears in user code.  */
  if (0)
    YYERROR;
  ++yynerrs;

  /* Do not reclaim the symbols of the rule whose action triggered
     this YYERROR.  */
  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);
  yystate = *yyssp;
  goto yyerrlab1;


/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
`-------------------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */

  /* Pop stack until we find a state that shifts the error token.  */
  for (;;)
    {
      yyn = yypact[yystate];
      if (!yypact_value_is_default (yyn))
        {
          yyn += YYSYMBOL_YYerror;
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
        YYABORT;


      yydestruct ("Error: popping",
                  YY_ACCESSING_SYMBOL (yystate), yyvsp);
      YYPOPSTACK (1);
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
    }

  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  *++yyvsp = yylval;
  YY_IGNORE_MAYBE_UNINITIALIZED_END


  /* Shift the error token.  */
  YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);

  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturnlab;


/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturnlab;


/*-----------------------------------------------------------.
| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |
`-----------------------------------------------------------*/
yyexhaustedlab:
  yyerror (YY_("memory exhausted"));
  yyresult = 2;
  goto yyreturnlab;


/*----------------------------------------------------------.
| yyreturnlab -- parsing is finished, clean up and return.  |
`----------------------------------------------------------*/
yyreturnlab:
  if (yychar != YYEMPTY)
    {
      /* Make sure we have latest lookahead translation.  See comments at
         user semantic actions for why this is necessary.  */
      yytoken = YYTRANSLATE (yychar);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  /* Do not reclaim the symbols of the rule whose action triggered
     this YYABORT or YYACCEPT.  */
  YYPOPSTACK (yylen);
  YY_STACK_PRINT (yyss, yyssp);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
      YYPOPSTACK (1);
    }
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif

  return yyresult;
}

#line 3738 "gram.y"

