This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This file implements Brzozowski's parsing-with-derivatives (see: | |
# https://arxiv.org/abs/1604.04695) with fairly simple and | |
# straightforward Python code. This implementation is naive and | |
# subject to exponential memory growth in the worst case; in practice, | |
# average complexity is closer to linear. This version recalculates | |
# derivatives every time they are needed; memoization, the first and | |
# most obvious optimization, is not implemented. | |
# |