/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* tree.h -- public definitions for tree module
*
* the parse tree is made up of struct node's. the struct is
* a "variant record" with a type, the filename and line number
* related to the node, and then type-specific node data.
*/
#ifndef _ESC_COMMON_TREE_H
#define _ESC_COMMON_TREE_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
struct node {
enum nodetype {
} t:8;
/*
* regardless of the type of node, filename and line number
* information from the original .esc file is tracked here.
*/
const char *file;
/*
* the variant part of a struct node...
*/
union {
struct {
/*
* info kept for T_NAME, used in several ways:
*
* 1 for simple variable names.
* example: j
*
* 2 for event class names, with component
* names chained together via the "next"
* pointers.
* example: fault.fan.broken
*
* 3 for component pathnames, with component
* names chained together via the "next"
* pointers and iterators or instance numbers
* attached via the "child" pointers.
* example: sysboard[0]/cpu[n]
*
* case 3 is the most interesting.
* - if child is set, there's an iterator
* - if child is a T_NAME, it is x[j] or x<j> and
* iterator type tells you vertical or horizontal
* - if child is a T_NUM, it is x[0] or x<0> or
* x0 and iterator type tells you which one
* - if cp pointer is set, then we recently
* matched it to a config cache entry and one
* can ignore child for now because it still
* represents the *pattern* you're matching.
* cp represents what you matched. ptree()
* knows that if cp is set, to print that number
* instead of following child.
*
* when T_NAME nodes are chained:
* the "last" pointer takes you to the end of the
* chain, but only the first component's last pointer
* is kept up to date. it is used to determine
* where to append newly-created T_NAME nodes (see
* tree_name_append()).
*/
const char *s; /* the name itself */
/* opaque pointer used during config matching */
/*
* note nametype is also declared as a three bit enum
* in itree.h, so if this ever needs expanding that
* will need changing too.
*/
enum nametype {
} t:3;
enum itertype {
} name;
struct {
/*
* info kept for T_GLOBID
*/
const char *s; /* the name itself */
} globid;
/*
* info kept for T_TIMEVAL and T_NUM
*
* timevals are kept in nanoseconds.
*/
unsigned long long ull;
struct {
/*
* info kept for T_QUOTE
*/
const char *s; /* the quoted string */
} quote;
struct {
/*
* info kept for T_FUNC
*/
const char *s; /* name of function */
} func;
struct {
/*
* info kept for T_PROP and T_MASK statements
* as well as declarations for:
* T_FAULT
* T_UPSET
* T_DEFECT
* T_ERROR
* T_EREPORT
* T_ASRU
* T_FRU
* T_CONFIG
*/
struct {
/*
* info kept for T_EVENT
*/
} event;
struct {
/*
* info kept for T_ARROW
*/
int needed;
} arrow;
struct {
/*
* info kept for everything else (T_ADD, T_LIST, etc.)
*/
int temp;
} expr;
} u;
/*
* Note to save memory the nodesize() function trims the end of this
* structure, so best not to add anything after this point
*/
};
/* flags we keep with stmts */
void tree_init(void);
void tree_fini(void);
struct node *tree_nothing(void);
void tree_report();
#ifdef __cplusplus
}
#endif
#endif /* _ESC_COMMON_TREE_H */