کد مقاله کد نشریه سال انتشار مقاله انگلیسی نسخه تمام متن
433931 1441690 2014 25 صفحه PDF دانلود رایگان
عنوان انگلیسی مقاله ISI
On the semantics of parsing actions
ترجمه فارسی عنوان
در معنای تجزیه و تحلیل اقدامات
موضوعات مرتبط
مهندسی و علوم پایه مهندسی کامپیوتر نظریه محاسباتی و ریاضیات
چکیده انگلیسی


• We develop a categorical semantics for parsing actions.
• Via the semantics, left-recursion elimination (in syntax) is shown to lead to continuation passing (in semantics).
• We define a type-and-effect calculus idealizing parser generators together with its abstract machine semantics.

Parsers, whether constructed by hand or automatically via a parser generator tool, typically need to compute some useful semantic information in addition to the purely syntactic analysis of their input. Semantic actions may be added to parsing code by hand, or the parser generator may have its own syntax for annotating grammar rules with semantic actions. In this paper, we take a functional programming view of such actions. We use concepts from the semantics of mostly functional programming languages and adapt them to give meaning to the actions of the parser. Specifically, the semantics is inspired by the categorical semantics of lambda calculi and the use of premonoidal categories for the semantics of effects in programming languages. This framework is then applied to our leading example, the transformation of grammars to eliminate left recursion. The syntactic transformation of left-recursion elimination leads to a corresponding semantic transformation of the actions for the grammar. We prove the semantic transformation correct and relate it to continuation passing style, a widely studied transformation in lambda calculi and functional programming. As an idealization of the input language of parser generators, we define a call-by-value calculus with first-order functions and a type-and-effect system where the effects are given by sequences of grammar symbols. The account of left-recursion elimination is then extended to this calculus.

ناشر
Database: Elsevier - ScienceDirect (ساینس دایرکت)
Journal: Science of Computer Programming - Volume 84, 1 May 2014, Pages 52-76