%{ // $Id: esmiles.flex 4974 2006-02-18 00:49:21Z glandrum $ // // Copyright (C) 2002-2006 Rational Discovery LLC // // @@ All Rights Reserved @@ // #pragma warning(disable:4786) #include #undef yywrap #undef YY_INPUT #include "InputFiller.h" extern INPUT_FUNC_TYPE gp_myInput; #define YY_INPUT( b, r, ms) (r = gp_myInput( b, ms )) #include #include #include #include #ifdef WIN32 #include #endif #include #include "smiles.tab.h" #ifdef WIN32 int isatty( int fd ) { return _isatty( fd ); } #endif using namespace RDKit; static PeriodicTable * gl_ptab = PeriodicTable::getTable(); %} %s IN_ATOM_STATE %% @[' ']*TH | @[' ']*AL | @[' ']*SQ | @[' ']*BP | @[' ']*OH { return CHI_CLASS; } @+ { return AT; } He | Li | Be | Ne | Na | Mg | Al | Si | Ar | K | Ca | Sc | Ti | V | Cr | Mn | Co | Fe | Ni | Cu | Zn | Ga | Ge | As | Se | Kr | Rb | Sr | Y | Zr | Nb | Mo | Tc | Ru | Rh | Pd | Ag | Cd | In | Sn | Sb | Te | Xe | Cs | Ba | La | Ce | Pr | Nd | Pm | Sm | Eu | Gd | Tb | Dy | Ho | Er | Tm | Yb | Lu | Hf | Ta | W | Re | Os | Ir | Pt | Au | Hg | Tl | Pb | Bi | Po | At | Rn | Fr | Ra | Ac | Th | Pa | U | Np | Pu | Am | Cm | Bk | Cf | Es | Fm | Md | No | Lr { yylval.atom = new Atom( gl_ptab->getAtomicNumber( yytext ) ); return ATOM; } B | C | N | O | P | S | F | Cl | Br | I { yylval.atom = new Atom( gl_ptab->getAtomicNumber( yytext ) ); return ORGANIC_ATOM; } H { return H; } c { yylval.atom = new Atom ( 6 ); yylval.atom->setIsAromatic(true); return AROMATIC_ATOM; } n { yylval.atom = new Atom( 7 ); yylval.atom->setIsAromatic(true); return AROMATIC_ATOM; } o { yylval.atom = new Atom( 8 ); yylval.atom->setIsAromatic(true); return AROMATIC_ATOM; } p { yylval.atom = new Atom( 15 ); yylval.atom->setIsAromatic(true); return AROMATIC_ATOM; } s { yylval.atom = new Atom( 16 ); yylval.atom->setIsAromatic(true); return AROMATIC_ATOM; } \- { return MINUS; } \+ { return PLUS; } \< { return LT; } \> { return GT; } [\=\#\:] { yylval.bond = new Bond(); Bond::BondType bt; switch(yytext[0]){ case '=': bt = Bond::DOUBLE; break; case '#': bt = Bond::TRIPLE; break; case ':': bt = Bond::AROMATIC; break; } yylval.bond->setBondType(bt); return BOND; } [\\] { yylval.bond = new Bond(Bond::SINGLE); yylval.bond->setBondDir(Bond::ENDDOWNRIGHT); return BOND; } [\/] { yylval.bond = new Bond(Bond::SINGLE); yylval.bond->setBondDir(Bond::ENDUPRIGHT); return BOND; } \( { return GROUP_OPEN; } \) { return GROUP_CLOSE; } \[ { BEGIN IN_ATOM_STATE; return ATOM_OPEN; } \] { BEGIN INITIAL; return ATOM_CLOSE; } \. { return SEPARATOR; } \_ { return DATIVE_MARK; } \% { return PERCENT; } [0-9] { yylval.ival = atoi( yytext ); return DIGIT; } \n return 0; . return yytext[0]; %% int yywrap( void ) { return 1; }