-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrammar.ebnf
38 lines (38 loc) · 1.82 KB
/
grammar.ebnf
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
String ::= prefix formula? connections? h_atoms? tetrahedral?
formula ::= "/" elemental ( "." elemental )*
connections ::= "/c" graph? ( ";" graph? )*
h_atoms ::= "/h" hydrogens? ( ";" hydrogens? )*
tetrahedral ::= "/t" tetrahedral_centers? ( ";" tetrahedral_centers? )*
elemental ::= count? ( c h? b? br? cl? f? rest_elements )
| ( b? br? cl? f? h? rest_elements )
rest_elements ::= i? mg? n? o? p? s?
b ::= "B" count?
c ::= "C" count?
h ::= "H" count?
br ::= "Br" count?
cl ::= "Cl" count?
f ::= "F" count?
i ::= "I" count?
mg ::= "Mg" count?
n ::= "N" count?
o ::= "O" count?
p ::= "P" count?
s ::= "S" count?
/* and so on... */
graph ::= (count "*")? index body
body ::= ( "-" | branch+ ) tail
branch ::= "(" ( index ( ( "," index ) | body )* ) ")"
tail ::= index body*
hydrogens ::= (count "*")? ( vh_count ( "," mh_count )* ) | mh_count
vh_count ::= virtual_hydrogens ( "," virtual_hydrogens )*
mh_count ::= mobile_hydrogens+
virtual_hydrogens ::= index ( ( "," | "-" ) index )* "H" count?
mobile_hydrogens ::= "(H" (count? "-" | count )? ( "," index )+ ")"
tetrahedral_centers ::= tetrahedral_center ( "," tetrahedral_center )*
tetrahedral_center ::= index ( "+" | "-" | "?" )
index ::= nonzero digit*
count ::= ( "1" digit+ ) | ( twoplus digit* )
digit ::= "0" | nonzero
nonzero ::= "1" | twoplus
prefix ::= "InChI=1" "S"?
twoplus ::= "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"