PLY (Python Lex-Yacc)

David M. Beazley, “PLY (Python Lex-Yacc)”, public translation into Russian from English More about this translation.

See also 21 similar translations

Translate into another language.

Participants

flipback2080 points
SilverBaby3 points
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next next untranslated

PLY (Python Lex-Yacc)

PLY (Python Lex-Yacc)

History of edits (Latest: flipback 1 year ago) §

1. Preface and Requirements

1. Предисловие и требования

History of edits (Latest: flipback 1 year ago) §

This document provides an overview of lexing and parsing with PLY. Given the intrinsic complexity of parsing, I would strongly advise that you read (or at least skim) this entire document before jumping into a big development project with PLY.

Данный документ описывает лексический и синтаксический анализ с помощью PLY. Принимая во внимание свойственную синтаксическому анализу сложность, я настоятельно рекомендую прочитать (или хотя бы просмотреть) данный документ целиком, прежде чем приступать к серьезной разработке проекта с PLY.

History of edits (Latest: flipback 1 year ago) §

PLY-3.0 is compatible with both Python 2 and Python 3. Be aware that Python 3 support is new and has not been extensively tested (although all of the examples and unit tests pass under Python 3.0). If you are using Python 2, you should try to use Python 2.4 or newer. Although PLY works with versions as far back as Python 2.2, some of its optional features require more modern library modules.

PLY-3.0 совместим с Python 2 и Python 3. Имейте в виду, что поддержка Python 3 появилась недавно и не была подробно протестирована (несмотря на то,что все из примеров и юнит тестов прошли успешно для Python 3). Если Вы используете Python 2, то старайтесь применять Python 2.4 или выше. Хотя PLY работает еще с версиями Python 2.2, некоторые опциональные возможности требуют более современных библиотечных модулей.

History of edits (Latest: flipback 1 year ago) §

2. Introduction

2. Введение

History of edits (Latest: flipback 1 year ago) §

PLY is a pure-Python implementation of the popular compiler construction tools lex and yacc. The main goal of PLY is to stay fairly faithful to the way in which traditional lex/yacc tools work. This includes supporting LALR(1) parsing as well as providing extensive input validation, error reporting, and diagnostics. Thus, if you've used yacc in another programming language, it should be relatively straightforward to use PLY.

PLY - реализация на чистом Python популярного набора генераторов lex и yacc. Главная цель PLY это оставаться преданным тому пути, которому придерживаются традиционные lex/yacc инструменты. Это включает поддержку LALR(1) алгоритма синтаксического разбора, а так же обеспечение обширной проверки ввода, отчета об ошибках и диагностики. И так, если Вы использовали yacc в другом языке программирования, то он должен быть относительно прост в использовании PLY.

History of edits (Latest: flipback 1 year ago) §

— Последнее предложения сомнительно. Не понтяно кто ОН flipback

Early versions of PLY were developed to support an Introduction to Compilers Course I taught in 2001 at the University of Chicago. In this course, students built a fully functional compiler for a simple Pascal-like language. Their compiler, implemented entirely in Python, had to include lexical analysis, parsing, type checking, type inference, nested scoping, and code generation for the SPARC processor. Approximately 30 different compiler implementations were completed in this course. Most of PLY's interface and operation has been influenced by common usability problems encountered by students. Since 2001, PLY has continued to be improved as feedback has been received from users. PLY-3.0 represents a major refactoring of the original implementation with an eye towards future enhancements.

Ранние версии PLY разработаны для поддержки курса "Введение в компиляторы", который я преподавал в 2001 году в Университете Чикаго. В данном курсе, студенты собрали полнофункциональный компилятор простого, похожего на Паскаль языка. Этот компилятор, реализован полностью на Python, включал лексический анализ, синтаксический анализатор, проверку типов, вывод типов, вложенности и генератор кода для SPARC процессора. Примерно 30 различных реализаций компиляторов были завершены данным курсом. Большая часть интерфейса и логики работы PLY подвергалось влиянию общих проблем удобного использования, обнаруженных студентами. С 2001 года, PLY продолжает улучшаться через обратную связь полученную от пользователей. PLY-3.0 представляет масштабный рефакторинг оригинальной реализации с точки зрения будущего расширения.

History of edits (Latest: flipback 1 year ago) §

Since PLY was primarily developed as an instructional tool, you will find it to be fairly picky about token and grammar rule specification. In part, this added formality is meant to catch common programming mistakes made by novice users. However, advanced users will also find such features to be useful when building complicated grammars for real programming languages. It should also be noted that PLY does not provide much in the way of bells and whistles (e.g., automatic construction of abstract syntax trees, tree traversal, etc.). Nor would I consider it to be a parsing framework. Instead, you will find a bare-bones, yet fully capable lex/yacc implementation written entirely in Python.

Так как PLY в первую очередь разрабатывался как инструмент для обучения, Вы возможно найдете его достаточно капризным к идентификаторам и правилам грамматики. Отчасти, добавление таких правил предназначено для предупреждения типичных программных ошибок совершаемых новичками. Однако, продвинутые пользователи смогут также найти такие функции пригодными, что бы построить законченную грамматику для настоящих программных языков. Так же они отметят, что PLY не предоставляет многого в плане "красивостей" (автоматических конструкторов абстрактных синтаксических деревьев и т.п.). Я так же не рассматриваю его как фреймворк синтаксического анализа. Зато, Вы найдете оголенный до предела, но все же достаточно способную lex\yacc реализацию написанную полностью на Python.

History of edits (Latest: flipback 1 year ago) §
Pages: ← previous Ctrl next next untranslated