相關主題
商品描述
Write good regexes and parsers with the Perl 6 programming language. You’ll see how regexes are used for searching, parsing, and validation: in particular the grammar extension makes them uniquely suitable for parsing, the main focus of this book. Written by Perl 6 expert Moritz Lenz, a core contributor of Rakudo, Parsing with Perl 6 Regexes and Grammars starts from the very basics of regular expressions, and then explores how they integrate with regular Perl 6 code. Then follows a deeper exploration of how regexes work under the hood and a discussion of common techniques for constructing regexes and exploring the data under scrutiny. Later material goes beyond relatively simple formats to reusable named regexes and grammars, which permit code reuse in grammars, and shows how to write parsers for more involved data formats. Error reporting and case studies wrap up the topic.
While regexes allow you to search for patterns in text and validate input, Perl 6 regexes advance that concept: you’ll see how they are easier to read, yet much more powerful, than the traditional "Perl-compatible regular expression". With improved reusability and backtracking control, you will be able to write complete parsers with the help of this book.
What You'll Learn
- Discover the building blocks of Perl 6 regexes
- Handle regex mechanics and master useful regex techniques
- Extract data and work with patterns among these use cases
- Reuse named regexes and other grammars as components or templates
- Write full parsers, including advanced error reporting and data extraction
- Learn how to parse nested scopes and indention-based formats
Who This Book Is For
Those with at least some prior experience with Perl programming, but who may be new to Perl 6 as well as searching and parsing.
商品描述(中文翻譯)
撰寫良好的正則表達式和解析器,使用 Perl 6 程式語言。您將看到正則表達式如何用於搜尋、解析和驗證:特別是語法擴展使它們特別適合解析,這是本書的主要焦點。由 Perl 6 專家 Moritz Lenz 撰寫,他是 Rakudo 的核心貢獻者,使用 Perl 6 正則表達式和語法進行解析 從正則表達式的基本概念開始,然後探討它們如何與常規的 Perl 6 代碼整合。接下來深入探討正則表達式的內部運作,以及構建正則表達式和探索數據的常見技術的討論。後面的內容超越了相對簡單的格式,介紹可重用的命名正則表達式和語法,這允許在語法中重用代碼,並展示如何為更複雜的數據格式編寫解析器。錯誤報告和案例研究總結了這個主題。
雖然正則表達式允許您在文本中搜尋模式並驗證輸入,但 Perl 6 的正則表達式進一步推進了這一概念:您將看到它們比傳統的「Perl 兼容正則表達式」更易於閱讀,但功能更強大。隨著可重用性和回溯控制的改善,您將能夠在本書的幫助下編寫完整的解析器。
您將學到什麼
- 發現 Perl 6 正則表達式的基本構建塊
- 處理正則表達式的機制並掌握有用的正則表達式技術
- 提取數據並在這些用例中處理模式
- 重用命名的正則表達式和其他語法作為組件或模板
- 編寫完整的解析器,包括高級錯誤報告和數據提取
- 學習如何解析嵌套範疇和基於縮排的格式
本書適合誰
對於那些至少有一些 Perl 程式設計經驗的人,但可能對 Perl 6 以及搜尋和解析是新手。