Remove building with NOCRYPTO option
[minix3.git] / usr.bin / m4 / parser.y
blobf8256ef41e2fae940290be5391d589234a240ff4
1 %{
2 /* $NetBSD: parser.y,v 1.3 2015/01/04 18:31:09 joerg Exp $ */
3 /* $OpenBSD: parser.y,v 1.6 2008/08/21 21:00:14 espie Exp $ */
4 /*
5 * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #if HAVE_NBTOOL_CONFIG_H
20 #include "nbtool_config.h"
21 #endif
22 #include <sys/cdefs.h>
23 __RCSID("$NetBSD: parser.y,v 1.3 2015/01/04 18:31:09 joerg Exp $");
24 #include <stdint.h>
25 #define YYSTYPE int32_t
26 extern int32_t end_result;
27 extern int yylex(void);
28 extern int yyerror(const char *);
30 %token NUMBER
31 %token ERROR
32 %left LOR
33 %left LAND
34 %left '|'
35 %left '^'
36 %left '&'
37 %left EQ NE
38 %left '<' LE '>' GE
39 %left LSHIFT RSHIFT
40 %left '+' '-'
41 %left '*' '/' '%'
42 %right UMINUS UPLUS '!' '~'
46 top : expr { end_result = $1; }
48 expr : expr '+' expr { $$ = $1 + $3; }
49 | expr '-' expr { $$ = $1 - $3; }
50 | expr '*' expr { $$ = $1 * $3; }
51 | expr '/' expr {
52 if ($3 == 0) {
53 yyerror("division by zero");
54 exit(1);
56 $$ = $1 / $3;
58 | expr '%' expr {
59 if ($3 == 0) {
60 yyerror("modulo zero");
61 exit(1);
63 $$ = $1 % $3;
65 | expr LSHIFT expr { $$ = $1 << $3; }
66 | expr RSHIFT expr { $$ = $1 >> $3; }
67 | expr '<' expr { $$ = $1 < $3; }
68 | expr '>' expr { $$ = $1 > $3; }
69 | expr LE expr { $$ = $1 <= $3; }
70 | expr GE expr { $$ = $1 >= $3; }
71 | expr EQ expr { $$ = $1 == $3; }
72 | expr NE expr { $$ = $1 != $3; }
73 | expr '&' expr { $$ = $1 & $3; }
74 | expr '^' expr { $$ = $1 ^ $3; }
75 | expr '|' expr { $$ = $1 | $3; }
76 | expr LAND expr { $$ = $1 && $3; }
77 | expr LOR expr { $$ = $1 || $3; }
78 | '(' expr ')' { $$ = $2; }
79 | '-' expr %prec UMINUS { $$ = -$2; }
80 | '+' expr %prec UPLUS { $$ = $2; }
81 | '!' expr { $$ = !$2; }
82 | '~' expr { $$ = ~$2; }
83 | NUMBER