2017-12-31 18:27:58 +01:00
|
|
|
/* Parses basis sets in GAMESS format */
|
|
|
|
|
|
|
|
%{
|
|
|
|
exception InputError of string
|
|
|
|
%}
|
|
|
|
|
|
|
|
%token EOL
|
|
|
|
%token <string> SPACE
|
|
|
|
%token <string> WORD
|
|
|
|
%token <int> INTEGER
|
|
|
|
%token <float> FLOAT
|
|
|
|
%token EOF
|
|
|
|
|
2018-01-02 22:33:17 +01:00
|
|
|
%start input_xyz
|
|
|
|
%type <Nuclei.xyz_input> input_xyz
|
2017-12-31 18:27:58 +01:00
|
|
|
|
|
|
|
%% /* Grammar rules and actions follow */
|
|
|
|
|
2018-01-02 22:33:17 +01:00
|
|
|
input_xyz:
|
|
|
|
| integer title atoms_xyz {
|
2017-12-31 18:27:58 +01:00
|
|
|
let len = List.length $3 in
|
|
|
|
if len <> $1 then
|
|
|
|
let error_msg = Printf.sprintf "%d atoms entered, expected %d" len $1 in
|
|
|
|
raise (InputError error_msg)
|
|
|
|
else
|
|
|
|
($2,Array.of_list $3)
|
|
|
|
}
|
|
|
|
|
|
|
|
integer:
|
|
|
|
| INTEGER EOL { $1 }
|
|
|
|
| INTEGER SPACE EOL { $1 }
|
|
|
|
|
|
|
|
title:
|
|
|
|
| title_list EOL { $1 }
|
|
|
|
|
|
|
|
text:
|
|
|
|
| WORD {$1 }
|
|
|
|
| SPACE {$1 }
|
|
|
|
| FLOAT {(string_of_float $1)}
|
|
|
|
| INTEGER {(string_of_int $1)}
|
|
|
|
|
|
|
|
title_list:
|
|
|
|
| { "" }
|
|
|
|
| title_list text { $1 ^ $2 }
|
|
|
|
|
2018-01-02 22:33:17 +01:00
|
|
|
atoms_xyz:
|
2017-12-31 18:27:58 +01:00
|
|
|
| atoms_list EOL { List.rev $1 }
|
|
|
|
| atoms_list EOF { List.rev $1 }
|
|
|
|
|
|
|
|
atoms_list:
|
|
|
|
| { [] }
|
2018-01-02 22:33:17 +01:00
|
|
|
| atoms_list WORD SPACE FLOAT SPACE FLOAT SPACE FLOAT EOL { (Element.of_string $2, [| $4;$6;$8 |]) :: $1 }
|
|
|
|
| atoms_list WORD SPACE FLOAT SPACE FLOAT SPACE FLOAT SPACE EOL { (Element.of_string $2, [| $4;$6;$8 |]) :: $1 }
|
|
|
|
|
|
|
|
label:
|
|
|
|
| FLOAT { Zmatrix.Value $1 }
|
|
|
|
| WORD { Zmatrix.Label $1 }
|
|
|
|
|
|
|
|
first_line:
|
|
|
|
| WORD { $1 }
|
|
|
|
|
|
|
|
second_line:
|
|
|
|
| WORD INTEGER label { ($1,$2,$3) }
|
|
|
|
|
|
|
|
third_line:
|
|
|
|
| WORD INTEGER label INTEGER label { ($1,$2,$3,$4,$5) }
|
|
|
|
|
|
|
|
nth_line:
|
|
|
|
| WORD INTEGER label INTEGER label INTEGER label { ($1,$2,$3,$4,$5,$6,$7) }
|
2017-12-31 18:27:58 +01:00
|
|
|
|
|
|
|
|