Chemical Parser (2015)

A simple molecular formula parser inspired by a CodeWars problem.


I still am in the process of learning about parsers. When I saw this CodeWars problem, I felt like this would be a good exercise in simple lexing and parsing.

Languages / Libraries:

  • Python


  • Language Parsing

The CodeWars problem

The Lexer

The Parser


  • Solves the CodeWars Problem
  • Working Lexer and simple parser

Needed Improvements:

  • Forgot about elements with 3 letters (Uut, Uup, etc)
  • Refactor out a generic lexer class