1 /***************************************************************************
2 * Copyright (C) 2004 by Thomas Nagy *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
28 (*let parse_error somestring = Printf.printf "%s \n" somestring;;
34 %token LPAREN RPAREN LBRACKET RBRACKET
36 %token <string> CAPITAL
40 %type <Chemset.listitems> main
49 expr ARROW expr { chem_negate $3; List.append $1 $3 }
54 | item PLUS expr { $1::$3 }
58 MINOR symbols { {ikey=$1; itbl=$2; sign=1} }
59 | INT symbols { {ikey=string_of_int($1); itbl=$2; sign=1} }
60 | symbols { {ikey="1"; itbl=$1; sign=1}}
65 | qte symbols { chem_add $1 $2 }
69 element INT { createchem $1 $2 }
70 | element { createchem $1 1 }
71 | LPAREN symbols RPAREN INT { chem_mult $2 $4 }
72 | LBRACKET INT PLUS RBRACKET { createchem "+" $2 }
73 | LBRACKET INT MINUS RBRACKET { createchem "-" $2 }
74 | LBRACKET PLUS RBRACKET { createchem "+" 1 }
75 | LBRACKET MINUS RBRACKET { createchem "-" 1 }
79 CAPITAL MINOR { $1 ^ $2 }