-
Notifications
You must be signed in to change notification settings - Fork 0
/
smiles.peg
41 lines (33 loc) · 1.88 KB
/
smiles.peg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
grammar smiles
smiles <- atom ( chain / branch )*
chain <- bond? ( atom / ( DIGIT / "%" DIGIT DIGIT ) )
branch <- "(" bond? smiles+ ")"
atom <- bracket_atom / ALIPHATIC_ORGANIC / AROMATIC_ORGANIC / "*"
bracket_atom <- "[" NUMBER? symbol chiral? hcount? charge? clazz? "]"
symbol <- ELEMENT_SYMBOLS
/ AROMATIC_SYMBOLS
/ "*"
chiral <- ( "@TB" / "@OH" ) DIGIT? DIGIT / "@SP" [1-3] / ("@AL" / "@TH") [1-2] / "@@" / "@"
hcount <- "H" DIGIT?
charge <- ( "-" / "+" ) ( DIGIT DIGIT? )?
clazz <- ":" NUMBER
ALIPHATIC_ORGANIC <- "Cl" / "Br" / "B" / "C" / "N" / "O" / "S" / "P" / "F" / "I"
ELEMENT_SYMBOLS <- symb_1 / symb_2 / symb_3
symb_1 <- "Os" / "Og" / "O" / "Cu" / "Cs" / "Cr" / "Co" / "Cn" / "Cm" / "Cl" / "Cf"
/ "Ce" / "Cd" / "Ca" / "C" / "P" / "Np" / "No" / "Ni" / "Nh" / "Ne" / "Nd"
/ "Nb" / "Na" / "N" / "Hs" / "Ho" / "Hg" / "Hf" / "He" / "H" / "Sr" / "Sn"
/ "Sm" / "Si" / "Sg" / "Se" / "Sc" / "Sb" / "S"
symb_2 <- "Fr" / "Fm" / "Fl" / "Fe" / "F" / "Br" / "Bk" / "Bi" / "Bh" / "Be" / "Ba"
/ "B" / "Kr" / "K" / "Ir" / "In" / "I" / "Zr" / "Zn" / "Yb" / "Y" / "Xe"
/ "W" / "V" / "Uue" / "Ubu" / "Ubt" / "Ubq" / "Ubp" / "Ubn" / "Ubh" / "Ubb"
/ "U" / "Ts" / "Tm" / "Tl" / "Ti" / "Th" / "Te" / "Tc" / "Tb" / "Ta"
symb_3 <- "Au" / "At" / "As" / "Ar" / "Am" / "Al" / "Ag" / "Ac" / "Ru" / "Rn" / "Rh"
/ "Rg" / "Rf" / "Re" / "Rb" / "Ra" / "Pu" / "Pt" / "Pr" / "Po" / "Pm" / "Pd"
/ "Pb" / "Pa" / "Mt" / "Mo" / "Mn" / "Mg" / "Md" / "Mc" / "Lv" / "Lu" / "Lr"
/ "Li" / "La" / "Ge" / "Gd" / "Ga" / "Eu" / "Es" / "Er" / "Dy" / "Ds" / "Db"
AROMATIC_SYMBOLS <- "se" / "as" / "b" / "c" / "n" / "o" / "p" / "s"
AROMATIC_ORGANIC <- "b" / "c" / "n" / "o" / "s" / "p"
DIGIT <- [0-9]
NUMBER <- [0] / [1-9] [0-9]*
WS <- [ \t\n\r]
bond <- [-=#$:/\\.]