%{
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
%}
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
%{
#pragma ident "%Z%%M% %I% %E% SMI"
extern long evalval;
#define YYSTYPE long
%}
%left '|' '^'
%left '&'
%right '!' '~'
%left '+' '-'
%left '*' '/' '%'
%%
s : e = { evalval = $1; }
| = { evalval = 0; }
;
| '!' e = { $$ = $2 == 0; }
| '~' e = { $$ = ~$2; }
| e '|' e = { $$ = ($1 | $3); }
| e '&' e = { $$ = ($1 & $3); }
| e '^' e = { $$ = ($1 ^ $3); }
| e '+' e = { $$ = ($1 + $3); }
| e '-' e = { $$ = ($1 - $3); }
| e '*' e = { $$ = ($1 * $3); }
| e '/' e = { $$ = ($1 / $3); }
| e '%' e = { $$ = ($1 % $3); }
| '(' e ')' = { $$ = ($2); }
;
%%
#include "m4.h"
int
yylex(void)
{
pe++;
switch (*pe) {
case '\0':
case '+':
case '-':
case '/':
case '%':
case '^':
case '~':
case '(':
case ')':
return (*pe++);
case '*':
case '>':
case '<':
case '=':
case '|':
case '&':
case '!':
default: {
int base;
evalval = 0;
if (*pe == '0') {
base = 16;
++pe;
} else
base = 8;
} else
base = 10;
for (;;) {
int c, dig;
c = *pe;
if (is_digit(c))
dig = c - '0';
else if (c >= 'a' && c <= 'f')
else if (c >= 'A' && c <= 'F')
else
break;
++pe;
}
return (DIGITS);
}
}
}
static int
{
if (*++pe != c)
return (r2);
++pe;
return (r1);
}
/*ARGSUSED*/
static void
{
}