arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2208.02815cs.SE
收藏

使用神经网络的动态高亮显示

On-the-Fly Syntax Highlighting using Neural Networks

Marco Edoardo Palma, Pasquale Salza, Harald C. Gall

摘要:

随着软件开发人员在线协作工具的出现,源代码被频繁地共享和查阅,从代码查看器到合并请求和代码片段。通常,在这种情况下,代码突出显示的质量是为了系统响应而牺牲的。在这些动态设置中,对源代码执行正式的语法分析不仅昂贵,而且难以处理,因为很多时候输入是语言的无效派生。事实上,当前流行的高亮器严重依赖于正则表达式系统,通常远离语言的词法分析器规范。由于其复杂性,正则表达式需要定期更新,因为从用户那里收集了更多反馈,并且它们的设计不受检测到更复杂的语言形式的欢迎。本文提供了一种基于深度学习的方法,适用于对正确和不正确的语言派生(如代码查看器和代码片段)进行实时语法代码突出显示。它侧重于减轻开发人员的负担,开发人员可以重用语言的解析策略来生成所需的突出显示规范。此外,这种方法相比,现在的在线语法突出工具和正式的方法在准确性和执行时间,在不同层次的语法覆盖,三个主流的程序设计语言。所获得的结果显示了所提出的方法如何在其预测中始终实现近乎完美的准确性,从而优于基于正则表达式的策略。

英文摘要:

With the presence of online collaborative tools for software developers, source code is shared and consulted frequently, from code viewers to merge requests and code snippets. Typically, code highlighting quality in such scenarios is sacrificed in favor of system responsiveness. In these on-the-fly settings, performing a formal grammatical analysis of the source code is not only expensive, but also intractable for the many times the input is an invalid derivation of the language. Indeed, current popular highlighters heavily rely on a system of regular expressions, typically far from the specification of the language's lexer. Due to their complexity, regular expressions need to be periodically updated as more feedback is collected from the users and their design unwelcome the detection of more complex language formations. This paper delivers a deep learning-based approach suitable for on-the-fly grammatical code highlighting of correct and incorrect language derivations, such as code viewers and snippets. It focuses on alleviating the burden on the developers, who can reuse the language's parsing strategy to produce the desired highlighting specification. Moreover, this approach is compared to nowadays online syntax highlighting tools and formal methods in terms of accuracy and execution time, across different levels of grammatical coverage, for three mainstream programming languages. The results obtained show how the proposed approach can consistently achieve near-perfect accuracy in its predictions, thereby outperforming regular expression-based strategies.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑