awk.y revision 7c478bd95313f5f23a4c958a745db2134aa03244
%{
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* awk -- YACC grammar
*
* Copyright (c) 1995 by Sun Microsystems, Inc.
*
* Copyright 1986, 1992 by Mortice Kern Systems Inc. All rights reserved.
*
* This Software is unpublished, valuable, confidential property of
* Mortice Kern Systems Inc. Use is authorized only in accordance
* with the terms and conditions of the source licence agreement
* protecting this Software. Any unauthorized use or disclosure of
* this Software is strictly prohibited and will result in the
* termination of the licence agreement.
*
*
*/
/*
* Do not use any character constants as tokens, so the resulting C file
* is codeset independent.
*/
#ident "%Z%%M% %I% %E% SMI"
#include "awk.h"
%}
%union {
};
/*
* Do not use any character constants as tokens, so the resulting C file
* is codeset independent.
*
* Declare terminal symbols before their operator
* precedences to get them in a contiguous block
* for giant switches in action() and exprreduce().
*/
/* Tokens from exprreduce() */
/* Tokens shared by exprreduce() and action() */
/* Tokens from action() */
/*
* Terminal symbols not used in action() and exprrreduce()
* switch statements.
*/
/*
* Tokens not used in grammar
*/
/*
* Tokens representing character constants
* TILDE, '~', taken care of above
*/
CARAT /* '^' */
LANGLE /* '<' */
RANGLE /* '>' */
PLUSC /* '+' */
HYPHEN /* '-' */
STAR /* '*' */
SLASH /* '/' */
PERCENT /* '%' */
EXCLAMATION /* '!' */
DOLLAR /* '$' */
LSQUARE /* '[' */
RSQUARE /* ']' */
LPAREN /* '(' */
RPAREN /* ')' */
SEMI /* ';' */
LBRACE /* '{' */
RBRACE /* '}' */
/*
* Priorities of operators
* Lowest to highest
*/
%%
prog = {
}
;
prog:
rule = {
yytree = $1;
}
if ($1 != NNULL) {
yytree = $1;
}
}
;
doing_begin = 0;
}
npattern++;
}
| pattern = {
doing_begin = 0;
}
{ funparm = 0; }
$$ = NNULL;
}
/* NOTREACHED */
}
| = {
$$ = NNULL;
}
;
++npattern;
}
;
BEGIN = {
doing_begin++;
}
| END = {
++npattern;
}
| expr = {
++npattern;
$$ = $1;
}
;
| = {
$$ = NNULL;
}
;
}
;
= {
$$ = NNULL;
}
| varlist2
;
}
;
| = {
$$ = NNULL;
}
;
/*
* Normal expression (includes regular expression)
*/
expr:
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
| getline
| rvalue
}
;
}
/*
* Prevents conflict with FOR LPAREN var IN var RPAREN production
*/
}
;
var:
| PARM
;
| CONSTANT
$$ = $2;
}
| EXCLAMATION expr = {
}
}
$$ = $2;
}
}
}
| FUNC = {
}
}
}
}
$$ = $<node>3;
}
;
}
/*
* attempt to optimize statements for the form
* for (i in x) delete x[i]
* to
* delete x
*/
np = $7;
else
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
$$ = $1;
}
| SEMI = {
$$ = NNULL;
}
$$ = $2;
}
;
if ($1 == NNULL)
$$ = $2;
else if ($2 == NNULL)
$$ = $1;
else
}
;
}
}
}
| = {
$$ = NNULL;
}
;
}
}
}
;
| = {
$$ = NNULL;
}
;
term:
{catterm = 1;}
;
%%
/*
* Flip a left-recursively generated list
* so that it can easily be traversed from left
* to right without recursion.
*/
static NODE *
{
int type;
#if 0
#endif
) {
;
}
}
}
return (np);
}