Build Your Own Programming Language: A programmer's guide to designing compilers, interpreters, and DSLs for solving modern computing problems (Paperback)

Clinton L. Jeffery

買這商品的人也買了...

商品描述

Key Features

  • Reduce development time and solve pain points in your application domain by building a custom programming language
  • Learn how to create parsers, code generators, file readers, analyzers, and interpreters
  • Create an alternative to frameworks and libraries to solve domain-specific problems

Book Description

The need for different types of computer languages is growing rapidly and developers prefer creating domain-specific languages for solving specific application domain problems. Building your own programming language has its advantages. It can be your antidote to the ever-increasing size and complexity of software. However, creating a custom language isn't easy.

In this book, you'll be able to put the knowledge you gain to work in language design and implementation. You'll implement the frontend of a compiler for your language, including a lexical analyzer and parser. The book covers a series of traversals of syntax trees, culminating with code generation for a bytecode virtual machine. Moving ahead, you'll learn how domain-specific language (DSL) features are often best represented by operators and functions that are built into the language, rather than library functions. The book concludes by showing you how to implement garbage collection, including reference counting and mark-and-sweep garbage collection. Throughout the book, Dr. Jeffery weaves in his experience of building the Unicon programming language to give better context to the concepts, while providing relevant examples in Unicon and Java.

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
  • Implement a bytecode interpreter and run bytecode generated by your compiler
  • Write tree traversals that insert information into the syntax tree
  • 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. Intermediate-level knowledge and experience working with a high-level language such as Java or the C++ language are expected to help you get the most out of this book.

商品描述(中文翻譯)

主要特點


  • 通過構建自定義編程語言,減少開發時間並解決應用領域中的痛點

  • 學習如何創建解析器、代碼生成器、文件讀取器、分析器和解釋器

  • 創建替代框架和庫以解決特定領域問題

書籍描述

對於不同類型的計算機語言的需求正在迅速增長,開發人員更喜歡創建特定應用領域的領域特定語言來解決問題。構建自己的編程語言有其優勢。它可以成為應對軟件日益增長的大小和複雜性的解藥。然而,創建自定義語言並不容易。

在本書中,您將能夠將所學的知識應用於語言設計和實現中。您將實現語言的前端,包括詞法分析器和解析器。本書涵蓋了一系列的語法樹遍歷,最終生成字節碼虛擬機的代碼生成。接下來,您將學習領域特定語言(DSL)功能通常最好由內置於語言中的運算符和函數來表示,而不是庫函數。本書最後展示了如何實現垃圾回收,包括引用計數和標記-清除垃圾回收。在整本書中,Jeffery博士融入了他構建Unicon編程語言的經驗,以更好地解釋概念,同時提供Unicon和Java的相關示例。

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

您將學到什麼


  • 對新語言進行需求分析,設計語言語法和語義

  • 為常見表達式和控制結構編寫詞法和上下文無關文法規則

  • 開發一個讀取源代碼並生成檢查語法的解析器的掃描器

  • 在編譯器中構建關鍵數據結構,並使用編譯器構建語法著色的代碼編輯器

  • 實現字節碼解釋器,並運行編譯器生成的字節碼

  • 編寫將信息插入語法樹的樹遍歷

  • 在您的語言中實現垃圾回收

本書適合對象

本書適合對發明自己的語言或開發領域特定語言感興趣的軟件開發人員。學習編譯器構造課程的計算機科學學生也會發現本書作為一本實用的語言實現指南,以補充更理論性的教材。預期您具有中級水平的知識和經驗,並能夠使用高級語言(如Java或C++語言)以獲得本書的最大收益。

作者簡介

Clinton L. Jeffery is Professor and Chair of the Department of Computer Science and Engineering at New Mexico Institute of Mining and Technology. He received his B.S. from the University of Washington, and M.S. and Ph.D. degrees from the University of Arizona, all in computer science. He has conducted research and written many books and papers on programming languages, program monitoring, debugging, graphics, virtual environments, and visualization. With colleagues, he invented the Unicon programming language, hosted on the Unicon website.

作者簡介(中文翻譯)

Clinton L. Jeffery是新墨西哥科技研究所(New Mexico Institute of Mining and Technology)計算機科學與工程系的教授和系主任。他在華盛頓大學獲得學士學位,並在亞利桑那大學獲得碩士和博士學位,專業都是計算機科學。他在編程語言、程序監控、調試、圖形、虛擬環境和可視化等領域進行研究並撰寫了許多書籍和論文。與同事們一起,他發明了Unicon編程語言,該語言可在Unicon網站上找到。

目錄大綱

Table of Contents

  1. Why Build Another Programming Language
  2. Programming Language Design
  3. Scanning Source Code
  4. Parsing
  5. Syntax Trees
  6. Symbol Tables
  7. Checking Base Types
  8. Checking Types on Arrays, Method Calls, and Structure Accesses
  9. Intermediate Code Generation
  10. Syntax Cloning in an IDE
  11. Bytecode Interpreters
  12. Generating Bytecode
  13. Native Code Generation
  14. Implementing Operators and Built-In Functions
  15. Domain Control Structures
  16. Garbage Collection
  17. Final Thoughts
  18. Appendix A - Unicon Essentials

目錄大綱(中文翻譯)

目錄

1. 為什麼要建立另一個程式語言
2. 程式語言設計
3. 掃描原始碼
4. 解析
5. 語法樹
6. 符號表
7. 檢查基本類型
8. 檢查陣列、方法呼叫和結構存取的類型
9. 中間碼生成
10. IDE中的語法複製
11. 字節碼解譯器
12. 生成字節碼
13. 本機代碼生成
14. 實現運算符和內建函數
15. 領域控制結構
16. 垃圾回收
17. 最後的思考
18. 附錄A - Unicon基礎知識