10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-06-02 03:15:19 +02:00
QCaml/Basis/Basis_lexer.mll

34 lines
820 B
OCaml
Raw Normal View History

2017-12-30 19:06:07 +01:00
{
exception SyntaxError of string
2018-01-17 15:56:57 +01:00
open Gamess_parser
2017-12-30 19:06:07 +01:00
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
}