-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbparser.mly
42 lines (35 loc) · 1.37 KB
/
bparser.mly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**************************************************************************/
/* */
/* Menhir */
/* */
/* François Pottier, INRIA Rocquencourt */
/* Yann Régis-Gianas, PPS, Université Paris Diderot */
/* */
/* Copyright 2005-2008 Institut National de Recherche en Informatique */
/* et en Automatique. All rights reserved. This file is distributed */
/* under the terms of the Q Public License version 1.0, with the change */
/* described in file LICENSE. */
/* */
/**************************************************************************/
%token <bool> BOOL
%token AND OR NOT
%token LPAREN RPAREN
%token EOL
%left AND OR /* lowest precedence */
%nonassoc NOT /* highest precedence */
%start <bool> main
%%
main:
| e = expr EOL
{ e }
expr:
| i = BOOL
{ i }
| LPAREN e = expr RPAREN
{ e }
| e1 = expr AND e2 = expr
{ e1 && e2 }
| e1 = expr OR e2 = expr
{ e1 || e2 }
| NOT e = expr %prec NOT
{ not e }