Build your own Programming Language - Second Edition: A programmer's guide to designing compilers, DSLs and interpreters for solving modern computing

Jeffery, Clinton L.

  • 出版商: Packt Publishing
  • 出版日期: 2024-01-30
  • 售價: $1,890
  • 貴賓價: 9.5$1,796
  • 語言: 英文
  • 頁數: 556
  • 裝訂: Quality Paper - also called trade paper
  • ISBN: 1804618020
  • ISBN-13: 9781804618028
  • 相關分類: Compiler
  • 立即出貨 (庫存 < 3)

商品描述

Written by the creator of the Unicon programming language, this book will show you how to implement programming languages to reduce the time and cost of creating applications for new or specialized areas of computing.


Key Features:


  • Solve pain points in your application domain by building a custom programming language
  • Learn how to create parsers, code generators, semantic analyzers, and interpreters
  • Target bytecode, native code, and preprocess or transpile code into another high level language


Book Description:


The need for different types of computer languages is growing, as is the need for domain-specific languages. Building your own programming language has its advantages, as it can be your antidote to the ever-increasing complexity of software.


In this book, you'll start with implementing the frontend of a compiler for your language, including a lexical analyzer and parser, including the handling of parse errors. The book then covers a series of traversals of syntax trees, culminating with code generation for a bytecode virtual machine or native code. You'll also manage data structures and output code when writing a preprocessor or a transpiler.


Moving ahead, you'll learn how domain-specific language features are often best represented by operators and functions that are built into the language, rather than library functions. We'll conclude with how to implement garbage collection. Throughout the book, Dr. Jeffery weaves in his experience from building the Unicon programming language to give better context to the concepts. Relevant examples are provided in Unicorn and Java so that you can follow the code of your choice. In this edition, code examples have been extended and further tested.


By the end of this book, you'll be able to build and deploy your own domain-specific languages, capable of compiling and running programs.


What You Will Learn:


  • Perform requirements analysis for the new language and design language syntax and semantics
  • Write lexical and context-free grammar rules for common expressions and control structures
  • Develop a scanner that reads source code and generate a parser that checks syntax
  • Build key data structures in a compiler and use your compiler to build a syntax-coloring code editor
  • Write tree traversals that insert information into the syntax tree
  • Implement a bytecode interpreter and run bytecode generated by your compiler
  • Write native code and run it after assembling and linking using system tools
  • Preprocess and transpile code from your language into another high level language
  • Implement garbage collection in your language


Who this book is for:


This book is for software developers interested in the idea of inventing their own language or developing a domain-specific language. Computer science students taking compiler construction courses will also find this book highly useful as a practical guide to language implementation to supplement more theoretical textbooks. We assume most readers will have intermediate or better proficiency in a high level programming language such as Java or C++.

商品描述(中文翻譯)

由Unicon程式語言的創造者撰寫,本書將向您展示如何實現程式語言,以減少為新的或特定領域的應用程序創建應用程序的時間和成本。

主要特點:
- 通過構建自定義程式語言來解決應用程序領域中的痛點
- 學習如何創建解析器、代碼生成器、語義分析器和解釋器
- 將代碼目標設置為字節碼、本機代碼,或將代碼預處理或轉譯為另一種高級語言

書籍描述:
隨著不同類型的計算機語言的需求增加,領域特定語言的需求也在增加。構建自己的程式語言具有優勢,因為它可以成為應對軟件日益增長的複雜性的解藥。

在本書中,您將從實現語言的前端開始,包括詞法分析器和解析器,包括處理解析錯誤。然後,本書涵蓋了一系列的語法樹遍歷,最終生成字節碼虛擬機器或本機代碼的代碼生成。在編寫預處理器或轉譯器時,您還將管理數據結構並輸出代碼。

接下來,您將學習領域特定語言功能通常最好由內置於語言中的運算符和函數表示,而不是庫函數。我們將以實現垃圾回收的方式結束。在整本書中,Jeffery博士結合了他構建Unicon程式語言的經驗,以更好地解釋概念。提供了Unicon和Java的相關示例,以便您可以選擇自己喜歡的代碼。在本版本中,代碼示例已擴展並進行了進一步的測試。

通過閱讀本書,您將能夠構建和部署自己的領域特定語言,能夠編譯和運行程序。

您將學到什麼:
- 為新語言執行需求分析,設計語言語法和語義
- 為常見表達式和控制結構編寫詞法和上下文無關文法規則
- 開發一個讀取源代碼並生成檢查語法的解析器的掃描器
- 在編譯器中構建關鍵數據結構,並使用編譯器構建語法著色的代碼編輯器
- 編寫將信息插入語法樹的樹遍歷
- 實現字節碼解釋器,並運行編譯器生成的字節碼
- 編寫本機代碼,並在使用系統工具進行組裝和鏈接後運行它
- 從您的語言預處理和轉譯代碼到另一種高級語言
- 在您的語言中實現垃圾回收

本書適合對發明自己的語言或開發領域特定語言感興趣的軟件開發人員。學習編譯器構建課程的計算機科學學生也會發現本書作為一本實用指南,以補充更理論性的教材。我們假設大多數讀者在高級程式語言(如Java或C++)方面具有中級或更高的熟練度。