2017-12-30 19:06:07 +01:00
|
|
|
{
|
|
|
|
exception SyntaxError of string
|
|
|
|
|
|
|
|
open Basis_parser
|
|
|
|
|
2017-12-30 19:12:20 +01:00
|
|
|
}
|
|
|
|
|
2017-12-30 19:06:07 +01:00
|
|
|
let eol = ['\n']
|
|
|
|
let white = [' ' '\t']+
|
|
|
|
let element = ['A'-'Z' 'a'-'z']+ white? eol
|
|
|
|
let ang_mom = ['S' 'P' 'D' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O'
|
|
|
|
's' 'p' 'd' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' ]
|
|
|
|
white
|
|
|
|
let integer = ['0'-'9']+
|
2017-12-31 18:27:58 +01:00
|
|
|
let real = '-'? integer '.' integer (['e' 'E'] ('+'|'-')? integer)?
|
2017-12-30 19:06:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
rule read_all_rule = parse
|
|
|
|
| eol { EOL }
|
|
|
|
| white { SPACE }
|
|
|
|
| ang_mom as a { ANG_MOM (a.[0]) }
|
|
|
|
| element as e { ELEMENT (String.trim e) }
|
|
|
|
| integer as i { INTEGER (int_of_string i) }
|
|
|
|
| real as f { FLOAT (float_of_string f) }
|
|
|
|
| eof { EOF }
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
let rec read_all lexbuf =
|
|
|
|
match read_all_rule lexbuf with
|
|
|
|
| SPACE -> read_all_rule lexbuf
|
|
|
|
| x -> x
|
|
|
|
}
|