Commits

dalke  committed 15b2e89

oops! Forgot to include this in version control

  • Participants
  • Parent commits 5d4b722

Comments (0)

Files changed (1)

File atom_actions.rl

+%%{
+  machine symbols;
+  
+  ### Element symbols for the organic subset
+  
+  action star_atom {
+    element = 0;
+    aromatic = 0;
+  }
+  action aliphatic_B {
+    element = 5;
+    aromatic = 0;
+  }
+  action aliphatic_C {
+    element = 6;
+    aromatic = 0;
+  }
+  action aliphatic_N {
+    element = 7;
+    aromatic = 0;
+  }
+  action aliphatic_O {
+    element = 8;
+    aromatic = 0;
+  }
+  action aliphatic_S {
+    element = 16;
+    aromatic = 0;
+  }
+  action aliphatic_P {
+    element = 15;
+    aromatic = 0;
+  }
+  action aliphatic_F {
+    element = 9;
+    aromatic = 0;
+  }
+  action aliphatic_Cl {
+    element = 17;
+    aromatic = 0;
+  }
+  action aliphatic_Br {
+    element = 35;
+    aromatic = 0;
+  }
+  action aliphatic_I {
+    element = 53;
+    aromatic = 0;
+  }
+
+  action aromatic_b {
+    element = 5;
+    aromatic = 1;
+  }
+  action aromatic_c {
+    element = 6;
+    aromatic = 1;
+  }
+  action aromatic_n {
+    element = 7;
+    aromatic = 1;
+  }
+  action aromatic_o {
+    element = 8;
+    aromatic = 1;
+  }
+  action aromatic_s {
+    element = 16;
+    aromatic = 1;
+  }
+  action aromatic_p {
+    element = 15;
+    aromatic = 1;
+  }
+
+  ### The element symbols inside of []s
+
+  action symbol_star {
+    element = 0;
+    aromatic = 0;
+  }
+
+  # The aromatic element symbols
+
+  action symbol_b {
+    element = 5;
+    aromatic = 1;
+  }
+  action symbol_c {
+    element = 6;
+    aromatic = 1;
+  }
+  action symbol_n {
+    element = 7;
+    aromatic = 1;
+  }
+  action symbol_o {
+    element = 8;
+    aromatic = 1;
+  }
+  action symbol_p {
+    element = 15;
+    aromatic = 1;
+  }
+  action symbol_se {
+    element = 34;
+    aromatic = 1;
+  }
+  action symbol_s {
+    element = 16;
+    aromatic = 1;
+  }
+  action symbol_as {
+    element = 33;
+    aromatic = 1;
+  }
+
+  # The aliphatic element symbols
+
+  action symbol_H {
+    element = 1;
+    aromatic = 0;
+  }
+  action symbol_He {
+    element = 2;
+    aromatic = 0;
+  }
+  action symbol_Li {
+    element = 3;
+    aromatic = 0;
+  }
+  action symbol_Be {
+    element = 4;
+    aromatic = 0;
+  }
+  action symbol_B {
+    element = 5;
+    aromatic = 0;
+  }
+  action symbol_C {
+    element = 6;
+    aromatic = 0;
+  }
+  action symbol_N {
+    element = 7;
+    aromatic = 0;
+  }
+  action symbol_O {
+    element = 8;
+    aromatic = 0;
+  }
+  action symbol_F {
+    element = 9;
+    aromatic = 0;
+  }
+  action symbol_Ne {
+    element = 10;
+    aromatic = 0;
+  }
+  action symbol_Na {
+    element = 11;
+    aromatic = 0;
+  }
+  action symbol_Mg {
+    element = 12;
+    aromatic = 0;
+  }
+  action symbol_Al {
+    element = 13;
+    aromatic = 0;
+  }
+  action symbol_Si {
+    element = 14;
+    aromatic = 0;
+  }
+  action symbol_P {
+    element = 15;
+    aromatic = 0;
+  }
+  action symbol_S {
+    element = 16;
+    aromatic = 0;
+  }
+  action symbol_Cl {
+    element = 17;
+    aromatic = 0;
+  }
+  action symbol_Ar {
+    element = 18;
+    aromatic = 0;
+  }
+  action symbol_K {
+    element = 19;
+    aromatic = 0;
+  }
+  action symbol_Ca {
+    element = 20;
+    aromatic = 0;
+  }
+  action symbol_Sc {
+    element = 21;
+    aromatic = 0;
+  }
+  action symbol_Ti {
+    element = 22;
+    aromatic = 0;
+  }
+  action symbol_V {
+    element = 23;
+    aromatic = 0;
+  }
+  action symbol_Cr {
+    element = 24;
+    aromatic = 0;
+  }
+  action symbol_Mn {
+    element = 25;
+    aromatic = 0;
+  }
+  action symbol_Fe {
+    element = 26;
+    aromatic = 0;
+  }
+  action symbol_Co {
+    element = 27;
+    aromatic = 0;
+  }
+  action symbol_Ni {
+    element = 28;
+    aromatic = 0;
+  }
+  action symbol_Cu {
+    element = 29;
+    aromatic = 0;
+  }
+  action symbol_Zn {
+    element = 30;
+    aromatic = 0;
+  }
+  action symbol_Ga {
+    element = 31;
+    aromatic = 0;
+  }
+  action symbol_Ge {
+    element = 32;
+    aromatic = 0;
+  }
+  action symbol_As {
+    element = 33;
+    aromatic = 0;
+  }
+  action symbol_Se {
+    element = 34;
+    aromatic = 0;
+  }
+  action symbol_Br {
+    element = 35;
+    aromatic = 0;
+  }
+  action symbol_Kr {
+    element = 36;
+    aromatic = 0;
+  }
+  action symbol_Rb {
+    element = 37;
+    aromatic = 0;
+  }
+  action symbol_Sr {
+    element = 38;
+    aromatic = 0;
+  }
+  action symbol_Y {
+    element = 39;
+    aromatic = 0;
+  }
+  action symbol_Zr {
+    element = 40;
+    aromatic = 0;
+  }
+  action symbol_Nb {
+    element = 41;
+    aromatic = 0;
+  }
+  action symbol_Mo {
+    element = 42;
+    aromatic = 0;
+  }
+  action symbol_Tc {
+    element = 43;
+    aromatic = 0;
+  }
+  action symbol_Ru {
+    element = 44;
+    aromatic = 0;
+  }
+  action symbol_Rh {
+    element = 45;
+    aromatic = 0;
+  }
+  action symbol_Pd {
+    element = 46;
+    aromatic = 0;
+  }
+  action symbol_Ag {
+    element = 47;
+    aromatic = 0;
+  }
+  action symbol_Cd {
+    element = 48;
+    aromatic = 0;
+  }
+  action symbol_In {
+    element = 49;
+    aromatic = 0;
+  }
+  action symbol_Sn {
+    element = 50;
+    aromatic = 0;
+  }
+  action symbol_Sb {
+    element = 51;
+    aromatic = 0;
+  }
+  action symbol_Te {
+    element = 52;
+    aromatic = 0;
+  }
+  action symbol_I {
+    element = 53;
+    aromatic = 0;
+  }
+  action symbol_Xe {
+    element = 54;
+    aromatic = 0;
+  }
+  action symbol_Cs {
+    element = 55;
+    aromatic = 0;
+  }
+  action symbol_Ba {
+    element = 56;
+    aromatic = 0;
+  }
+  action symbol_La {
+    element = 57;
+    aromatic = 0;
+  }
+  action symbol_Ce {
+    element = 58;
+    aromatic = 0;
+  }
+  action symbol_Pr {
+    element = 59;
+    aromatic = 0;
+  }
+  action symbol_Nd {
+    element = 60;
+    aromatic = 0;
+  }
+  action symbol_Pm {
+    element = 61;
+    aromatic = 0;
+  }
+  action symbol_Sm {
+    element = 62;
+    aromatic = 0;
+  }
+  action symbol_Eu {
+    element = 63;
+    aromatic = 0;
+  }
+  action symbol_Gd {
+    element = 64;
+    aromatic = 0;
+  }
+  action symbol_Tb {
+    element = 65;
+    aromatic = 0;
+  }
+  action symbol_Dy {
+    element = 66;
+    aromatic = 0;
+  }
+  action symbol_Ho {
+    element = 67;
+    aromatic = 0;
+  }
+  action symbol_Er {
+    element = 68;
+    aromatic = 0;
+  }
+  action symbol_Tm {
+    element = 69;
+    aromatic = 0;
+  }
+  action symbol_Yb {
+    element = 70;
+    aromatic = 0;
+  }
+  action symbol_Lu {
+    element = 71;
+    aromatic = 0;
+  }
+  action symbol_Hf {
+    element = 72;
+    aromatic = 0;
+  }
+  action symbol_Ta {
+    element = 73;
+    aromatic = 0;
+  }
+  action symbol_W {
+    element = 74;
+    aromatic = 0;
+  }
+  action symbol_Re {
+    element = 75;
+    aromatic = 0;
+  }
+  action symbol_Os {
+    element = 76;
+    aromatic = 0;
+  }
+  action symbol_Ir {
+    element = 77;
+    aromatic = 0;
+  }
+  action symbol_Pt {
+    element = 78;
+    aromatic = 0;
+  }
+  action symbol_Au {
+    element = 79;
+    aromatic = 0;
+  }
+  action symbol_Hg {
+    element = 80;
+    aromatic = 0;
+  }
+  action symbol_Tl {
+    element = 81;
+    aromatic = 0;
+  }
+  action symbol_Pb {
+    element = 82;
+    aromatic = 0;
+  }
+  action symbol_Bi {
+    element = 83;
+    aromatic = 0;
+  }
+  action symbol_Po {
+    element = 84;
+    aromatic = 0;
+  }
+  action symbol_At {
+    element = 85;
+    aromatic = 0;
+  }
+  action symbol_Rn {
+    element = 86;
+    aromatic = 0;
+  }
+  action symbol_Fr {
+    element = 87;
+    aromatic = 0;
+  }
+  action symbol_Ra {
+    element = 88;
+    aromatic = 0;
+  }
+  action symbol_Ac {
+    element = 89;
+    aromatic = 0;
+  }
+  action symbol_Th {
+    element = 90;
+    aromatic = 0;
+  }
+  action symbol_Pa {
+    element = 91;
+    aromatic = 0;
+  }
+  action symbol_U {
+    element = 92;
+    aromatic = 0;
+  }
+  action symbol_Np {
+    element = 93;
+    aromatic = 0;
+  }
+  action symbol_Pu {
+    element = 94;
+    aromatic = 0;
+  }
+  action symbol_Am {
+    element = 95;
+    aromatic = 0;
+  }
+  action symbol_Cm {
+    element = 96;
+    aromatic = 0;
+  }
+  action symbol_Bk {
+    element = 97;
+    aromatic = 0;
+  }
+  action symbol_Cf {
+    element = 98;
+    aromatic = 0;
+  }
+  action symbol_Es {
+    element = 99;
+    aromatic = 0;
+  }
+  action symbol_Fm {
+    element = 100;
+    aromatic = 0;
+  }
+  action symbol_Md {
+    element = 101;
+    aromatic = 0;
+  }
+  action symbol_No {
+    element = 102;
+    aromatic = 0;
+  }
+  action symbol_Lr {
+    element = 103;
+    aromatic = 0;
+  }
+  action symbol_Rf {
+    element = 104;
+    aromatic = 0;
+  }
+  action symbol_Db {
+    element = 105;
+    aromatic = 0;
+  }
+  action symbol_Sg {
+    element = 106;
+    aromatic = 0;
+  }
+  action symbol_Bh {
+    element = 107;
+    aromatic = 0;
+  }
+  action symbol_Hs {
+    element = 108;
+    aromatic = 0;
+  }
+  action symbol_Mt {
+    element = 109;
+    aromatic = 0;
+  }
+  action symbol_Ds {
+    element = 110;
+    aromatic = 0;
+  }
+  action symbol_Rg {
+    element = 111;
+    aromatic = 0;
+  }
+
+}%%
+
+%%{
+  # Isotope field
+  machine isotope;
+
+  action no_isotope {
+    isotope = 0;
+  }
+  action first_isotope_digit {
+    isotope = *p-'0';
+  }
+  action next_isotope_digit {
+    isotope = isotope*10 + (*p-'0');
+  }
+  action end_isotope {
+  }
+}%%
+
+%%{
+  # Chirality
+  machine chirality;
+
+  action no_chiral {
+    chiral_class = CHIRAL_NONE;
+    chiral_count = 0;
+  }
+  action first_chiral_digit {
+    chiral_count = *p-'0';
+  }
+  action second_chiral_digit {
+    chiral_count = chiral_count*10 + (*p-'0');
+  }
+  action chiral_cw {
+    chiral_class = CHIRAL_TH;
+    chiral_count = 1;
+  }
+  action chiral_ccw {
+    chiral_class = CHIRAL_TH;
+    chiral_count = 2;
+  }
+  action chiral_TH {
+    chiral_class = CHIRAL_TH;
+  }
+  action chiral_TB {
+    chiral_class = CHIRAL_TB;
+  }
+  action chiral_AL {
+    chiral_class = CHIRAL_AL;
+  }
+  action chiral_SP {
+    chiral_class = CHIRAL_SP;
+  }
+  action chiral_OH {
+    chiral_class = CHIRAL_OH;
+  }
+}%%
+
+%%{
+  machine errors;
+
+  action chiral_TH_error {
+    errmsg = "Unknown TH chiral permutation";
+  }
+  action chiral_AL_error {
+    errmsg = "Unknown AL chiral permutation";
+  }
+  action chiral_SP_error {
+    errmsg = "Unknown SP chiral permutation";
+  }
+  action chiral_TB_error {
+    errmsg = "Unknown TB chiral permutation";
+  }
+  action chiral_OH_error {
+    errmsg = "Unknown OH chiral permutation";
+  }
+  action incomplete_closure_error {
+    errmsg = "Incomplete ring closure";
+  }
+  action expecting_valid_syntax_error {
+    errmsg = "Invalid SMILES syntax";
+  }
+  action expecting_atom_error {
+    errmsg = "Expecting atom";
+  }
+  action expecting_atom_or_bond_error {
+    errmsg = "Expecting atom or bond";
+  }
+  action expecting_atom_or_closure_error {
+    errmsg = "Expecting atom or ring closure";
+  }
+  action expecting_isotope_or_symbol_error {
+    errmsg = "Expecting isotope number or atomic symbol";
+  }
+  action expecting_after_symbol_error {
+    errmsg = "Expecting chiral, hydrogen count, charge, atom class, or ']'";
+  }
+  action expecting_after_at_error {
+    errmsg = "Expecting chiral qualifier, hydrogen count, charge, atom class, or ']'";
+  }
+  action expecting_chiral_class_error {
+    errmsg = "Incomplete chiral class name";
+  }
+  action expecting_after_chiral_error {
+    errmsg = "Expecting hydrogen count, charge, atom class, or ']'";
+  }
+  action expecting_after_hcount_error {
+    errmsg = "Expecting hydrogen count digit, charge, atom class, or ']'";
+  }
+  action expecting_after_plus_charge_error {
+    errmsg = "Expecting charge digit, another '+', atom class, or ']'";
+  }
+  action expecting_after_minus_charge_error {
+    errmsg = "Expecting charge digit, another '-', atom class, or ']'";
+  }
+  action expecting_after_charge_error {
+    errmsg = "Expecting charge digit, atom class, or ']'";
+  }
+  action expecting_class_digit_error {
+    errmsg = "Expecting atom class digit";
+  }
+  action expecting_after_class_error {
+    errmsg = "Expecting atom class digit or ']'";
+  }
+
+
+}%%
+
+%%{
+  # Implicit hygrogen count
+  machine hcount;
+
+  action no_hcount {
+    hcount = 0;
+  }
+  action single_hcount {
+    hcount = 1;
+  }
+  action first_hcount_digit {
+    hcount = *p-'0';
+  }
+  action next_hcount_digit {
+    hcount = hcount*10 + (*p-'0');
+  }
+  action end_hcount {}
+}%%
+
+%%{
+  # charges
+  machine charges;
+
+  action no_charge {
+    charge = 0;
+  }
+  action plus_1_charge {
+    charge = 1;
+  }
+  action plus_2_charge {
+    charge = 2;
+  }
+  action first_charge_digit {
+    charge = *p-'0';
+  }
+  action next_charge_digit {
+    charge = charge*10 + (*p-'0');
+  }
+  action end_positive_count {
+  }
+  action end_negative_count {
+    charge = -charge;
+  }
+  action minus_1_charge {
+    charge = -1;
+  }
+  action minus_2_charge {
+    charge = -2;
+  }
+}%%
+
+%%{
+  # atom class
+  machine atom_class;
+
+  action no_class {
+    atom_class = 0;
+  }
+  action first_class_digit {
+    atom_class = *p-'0';
+  }
+  action next_class_digit {
+    atom_class = 10*atom_class + (*p-'0');
+  }
+  action end_class {}
+}%%
+
+%%{
+  # branches and closures
+  machine closure;
+
+  action one_digit_closure {
+    closure = *p-'0';
+  }
+  action two_digit_closure {
+    closure = (*(p-1)-'0')*10 + (*p-'0');
+  }
+}%%
+
+%%{
+  machine standard;
+
+  include symbols;
+  include isotope;
+  include chirality;
+  include errors;
+  include hcount;
+  include charges;
+  include atom_class;
+  include closure;
+}%%