djspiewak / parseback

A Scala implementation of parsing with derivatives
http://parseback.io
Apache License 2.0
197 stars 22 forks source link

isNullable does not correctly handle certain cases #24

Closed djspiewak closed 7 years ago

djspiewak commented 7 years ago

For example:

S ::= S | 'a'

This is a valid grammar, and it parses just the single character: a. However, isNullable will return neither true nor false for its nullability. The problem is that the implementation for isNullable is attempting to approximate a least-fixed-point solution by linear graph traversal, and I'm pretty sure that isn't doable. (if it were, a lot of static program analysis would be much faster!) The function needs to be reimplemented to use explicit constraint solving.