Is Stateful Packrat Parsing Really Linear in Practice? -- A Counter-Example, An Improved Grammar and Its Parsing Algorithms --
Stateful packrat parsing is an algorithm for parsing syntaxes that have context-sensitive features. It is a well-known knowledge among researchers that the running time of stateful packrat parsing is linear for real-world grammars, as demonstrated in existing studies. However, we have found the cases in real-world grammars and tools that lead its running time becomes exponential.
This paper proposes a new grammar, parsing expression grammar with variable bindings, and two parsing algorithms for the grammar, stateful packrat parsing with selected global states and stateful packrat parsing with conditional memoization. Our proposal overcomes the exponential behavior that appears in parsers and guarantees polynomial running time. The key idea behind our algorithms is to memoize the information relevant to the use of the global states in order to avoid memoizing the full global states. We implemented our algorithms as a parser generator and evaluated them on real-world grammars. Our evaluation shows that our algorithms significantly outperform an existing stateful packrat parsing algorithm in terms of both running time and space consumption. In particular, stateful packrat parsing with conditional memoization improves the running time and space consumption for malicious inputs that lead to exponential behavior with the existing algorithm by 260x and 217x, respectively, compared to the existing algorithm.
Sat 22 FebDisplayed time zone: Pacific Time (US & Canada) change
10:30 - 12:00
|Bitwidth Customization in Image Processing Pipelines using Interval Analysis and SMT Solvers|
|Is Stateful Packrat Parsing Really Linear in Practice? -- A Counter-Example, An Improved Grammar and Its Parsing Algorithms --|
|Automatically Harnessing Sparse Acceleration|
|Compiling First-order Functions to Session-Typed Parallel Code|