4 ms·
That's "SMILES". Yes. Here is the yacc grammar for the SMILES parser in the RDKit. https://github.com/rdkit/rdkit/blob/master/Code/GraphMol/SmilesParse/smiles.
by dalke 11mo ago
That's "SMILES".
Yes. Here is the yacc grammar for the SMILES parser in the RDKit. https://github.com/rdkit/rdkit/blob/master/Code/GraphMol/SmilesParse/smiles.yy https://github.com/rdkit/rdkit/blob/master/Code/GraphMol/Smi...
There's also one from OpenSMILES at http://opensmiles.org/opensmiles.html#_grammar http://opensmiles.org/opensmiles.html#_grammar . It has a shift/reduce error (as I recall) that I was not competent enough to fix.
I prefer to parser almost completely in the lexer, with a small amount of lexer state to handle balanced parens, bracket atoms, and matching ring closures. See https://hg.sr.ht/~dalke/opensmiles-ragel https://hg.sr.ht/~dalke/opensmiles-ragel and more specifically https://hg.sr.ht/~dalke/opensmiles-ragel/browse/opensmiles.rl?rev=tip https://hg.sr.ht/~dalke/opensmiles-ragel/browse/opensmiles.r... .
- dalke 11mo agoOh, I should have pointed out my Python lexer-driven parser at https://hg.sr.ht/~dalke/smiview/browse/smiview.py https://hg.sr.ht/~dalke/smiview/browse/smiview.py The lexer: https://hg.sr.ht/~dalke/smiview/browse/smiview.py?rev=tip#L337 https://hg.sr.ht/~dalke/smiview/browse/smiview.py?rev=tip#L3... The lexer state transitions: https://hg.sr.ht/~dalke/smiview/browse/smiview.py?rev=tip#L364 https://hg.sr.ht/~dalke/smiview/browse/smiview.py?rev=tip#L3...