mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-15 10:33:39 +01:00
34 lines
820 B
OCaml
34 lines
820 B
OCaml
{
|
|
exception SyntaxError of string
|
|
|
|
open Gamess_parser
|
|
|
|
}
|
|
|
|
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']+
|
|
let real = '-'? integer '.' integer (['e' 'E'] ('+'|'-')? integer)?
|
|
|
|
|
|
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
|
|
}
|