Basic implementation of the Berry-Sethi algorithm in Scala