%{
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* escparse.y -- parser for esc
*
* this is the yacc-based parser for Eversholt. the syntax is simple
* and is defined by the LALR(1) grammar described by this file. there
* file.
*
* as the input is parsed, a parse tree is built by calling the
* tree_X() functions defined in tree.c. any syntax errors cause
* us to skip to the next semicolon, achieved via the "error" clause
* in the stmt rule below. the yacc state machine code will call
* yyerror() in esclex.c and that will keep count of the errors and
* display the filename, line number, and current input stream of tokens
* to help the user figure out the problem. the -Y flag to this program
* turns on the yacc debugging output which is quite large. you probably
* only need to do that if you're debugging the grammar below.
*
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include "out.h"
#include "stable.h"
#include "literals.h"
#include "lut.h"
#include "esclex.h"
#include "tree.h"
%}
%union {
}
%right '='
/*
* make sure ':' comes immediately after '?' in precedence declarations
*/
%right '?'
%nonassoc ':'
%left '|'
%left '^'
%left '&'
%left '-' '+'
%right '!' '~'
%left '.'
%%
{ (void)tree_root($1); }
;
{ $$ = NULL; }
;
{ $$ = tree_nothing(); }
{ $$ = $5; }
{ $$ = $6; }
{
}
{
}
{
}
{
}
{
}
| /*superfluous semicolons are ignored*/ ';'
{ $$ = tree_nothing(); }
;
{
}
{
}
;
{ $$ = NULL; }
{ $$ = $2; }
;
| ID
/* really can only be 'A', enforced by check_arrow() later */
{ $$ = $2; }
;
{ $$ = NULL; }
| nvpair
;
/* "engine" is a reserved word, but a valid property name */
{
}
/* "count" is a reserved word, but a valid property name */
{
}
;
{
/* hack to allow dashes in property names */
}
;
/* the RHS of an nvpair can be a value, or an ename, or an ename@pname */
| pname
| globid
| func
/*
* ID must be timevals only ("ms", "us", etc.).
* enforced by tree_timeval().
*/
| QUOTE
;
/* arithmetic operations, no variables or symbols */
{ $$ = $2; }
| NUMBER
;
;
;
{ $$ = NULL; }
| '@' pname
{ $$ = $2; }
;
{ $$ = NULL; }
{ $$ = $2; }
;
;
/*
* conflicts between cexpr and iterid involving the use of ID
*/
/*
* ID must be timevals only ("ms", "us", etc.).
* enforced by tree_timeval().
*/
;
| '!' cexpr
| '~' cexpr
{ $$ = $2; }
| func
| NUMBER
| ID
{
/* iteration variable */
}
| globid
| QUOTE
;
| pfunc
;
;
| pname
{ $$ = tree_pname($1); }
| QUOTE
;
/*
* these functions are in the grammar so we can force the arg to be
* a path or an event. they show up as functions in the parse tree.
*/
;
;
| ID '[' ']'
{
$$ = tree_name_iterator(
}
| ID '<' '>'
{
$$ = tree_name_iterator(
}
{
/* hack to allow dashes in path name components */
}
;
/* iname is an ID where we can peel numbers off the end */
;
/* base case of ID.ID instead of just ID requires ename to contain one dot */
{
$$ = tree_name_append(
}
{
$$ = tree_name_append($1,
}
{
/*
* hack to allow dashes in class names. when we
* detect the dash here, we know we're in a class
* name because the left recursion of this rule
* means we've already matched at least:
* ID '.' ID
* so the ename here has an incomplete final
* component (because the lexer stopped at the
* dash). so we repair that final component here.
*/
}
;
/* like an ID, but we let reserved words act unreserved in enames */
| PROP
| MASK
| EVENT
| ENGINE
| ASRU
| FRU
| CONFIG
| IF
;
/* pname is a pathname, like x/y, x<i>/y[0], etc */
;
;
%%