一句话:扩展 Perses,使任何有上下文无关文法的语言仅需配置文件即可进行语法引导程序归约。
程序归约是调试编译器、解释器等语言实现的关键技术。Perses 利用语法引导归约,但为新语言落地时,用户需手动将文法转换为 PNF、修改 Perses 代码库并重新构建,可用性较差。本文提出 Persesadhoc,只要目标语言具有上下文无关文法,用户只需编写配置文件并执行一条命令,即可对该语言程序进行即席归约。案例研究显示,支持 GLSL 所需的 Perses 基础设施代码从 190 行降至 20 行;广泛评估表明,Persesadhoc 在归约效果与效率上与 Perses 相当,且支持新语言仅需约 10 秒,相比原有人工投入可忽略不计。
Program reduction is a widely adopted, indispensable technique for debugging language implementations such as compilers and interpreters. Given a program 𝑃 and a bug triggered by 𝑃, a program reducer can produce a minimized program 𝑃∗ that is derived from 𝑃 and still triggers the same bug. Perses is one of the state-of-the-art program reducers. It leverages the syntax of 𝑃 to guide the reduction process for efficiency and effectiveness. It is language-agnostic as its reduction algorithm is independent of any language-specific syntax. Conceptually to support a new language, Perses only needs the context-free grammar 𝐺 of the language; in practice, it is not easy. One needs to first manually transform 𝐺 into a special grammar form PNF with a tool provided by Perses, second manually change the code base of Perses to integrate the new language, and lastly build a binary of Perses. This paper presents our latest work to improve the usability of Perses by extending Perses to perform ad hoc program reduction for any new language as long as the language has a context-free grammar 𝐺. With this extended version (referred to as Persesadhoc), the difficulty of supporting new languages is significantly reduced: a user only needs to write a configuration file and execute one command to support a new language in Perses, compared to manually transforming the grammar format, modifying the code base, and re-building Perses. Our case study demonstrates that with Persesadhoc, the Perses related infrastructure code required for supporting GLSL can be reduced from 190 lines of code to 20. Our extensive evaluations also show that Persesadhoc is as effective and efficient as Perses in reducing hoc programs, and only takes 10 seconds to support a new language, which is negligible compared to the manual effort required in Perses. A video demonstration of the tool can be found at https://youtu.be/trYwOT0mXhU.