Writing A C Compiler: Build a Real Programming Language from Scratch
暫譯: 編寫 C 編譯器:從零開始構建一種真正的程式語言

Sandler, Nora

  • 出版商: No Starch Press
  • 出版日期: 2024-08-20
  • 定價: $2,450
  • 售價: 9.0$2,205
  • 語言: 英文
  • 頁數: 792
  • 裝訂: Quality Paper - also called trade paper
  • ISBN: 1718500424
  • ISBN-13: 9781718500426
  • 相關分類: C 程式語言ScratchCompiler
  • 立即出貨

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

相關主題

商品描述

A hands-on, example-filled guide to the theory and practice of writing a C compiler: a computer program that translates code written by programmers into code the computer can read.

Compilers are at the heart of everything programmers do, yet even experienced developers find them intimidating. For those eager to truly grasp how compilers work, Writing a C Compiler dispels the mystery. This book guides you through a fun and engaging project where you'll learn what it takes to compile a real-world programming language to actual assembly code.

Writing a C Compiler will take you step by step through the process of building your own compiler for a significant subset of C--no prior experience with compiler construction or assembly code needed. Once you've built a working compiler for the simplest C program, you'll add new features chapter by chapter. The algorithms in the book are all in pseudocode, so you can implement your compiler in whatever language you like. Along the way, you'll explore key concepts like:

 

  • Lexing and parsing: Learn how to write a lexer and recursive descent parser that transform C code into an abstract syntax tree.
  • Program analysis: Discover how to analyze a program to understand its behavior and detect errors.
  • Code generation: Learn how to translate C language constructs like arithmetic operations, function calls, and control-flow statements into x64 assembly code.
  • Optimization techniques: Improve performance with methods like constant folding, dead store elimination, and register allocation.


Compilers aren't terrifying beasts--and with help from this hands-on, accessible guide, you might even turn them into your friends for life.

商品描述(中文翻譯)

一本實作性強、充滿範例的指南,介紹撰寫 C 編譯器的理論與實踐:一個將程式設計師撰寫的程式碼轉換為電腦可讀代碼的電腦程式。

編譯器是程式設計師所做的一切的核心,然而即使是經驗豐富的開發者也會感到畏懼。對於那些渴望真正理解編譯器如何運作的人來說,Writing a C Compiler 解開了這個謎團。本書引導您通過一個有趣且引人入勝的專案,學習將一種真實的程式語言編譯成實際的組合語言代碼所需的知識。

Writing a C Compiler 將一步步帶您完成為 C 的一個重要子集構建自己的編譯器的過程——不需要任何編譯器建構或組合語言的先前經驗。一旦您為最簡單的 C 程式建立了一個可運作的編譯器,您將逐章添加新功能。本書中的演算法均以偽代碼呈現,因此您可以使用任何您喜歡的語言來實作您的編譯器。在此過程中,您將探索以下關鍵概念:



  • 詞法分析與語法分析:學習如何撰寫一個詞法分析器和遞歸下降解析器,將 C 代碼轉換為抽象語法樹。


  • 程式分析:發現如何分析程式以理解其行為並檢測錯誤。


  • 代碼生成:學習如何將 C 語言結構(如算術運算、函數調用和控制流語句)轉換為 x64 組合語言代碼。


  • 優化技術:通過常數折疊、死存儲消除和寄存器分配等方法提高性能。

編譯器並不是可怕的怪物——在這本實作性強、易於理解的指南的幫助下,您甚至可能會將它們變成您一生的朋友。

作者簡介

Nora Sandler is a software engineer based in Seattle. She holds a BS in computer science from the University of Chicago, where she researched the implementation of parallel programming languages. More recently, she's worked on domain-specific languages at an endpoint security company. You can find her blog on pranks, compilers, and other computer science topics at https: //norasandler.com.

作者簡介(中文翻譯)

Nora Sandler 是一位位於西雅圖的軟體工程師。她擁有芝加哥大學的計算機科學學士學位,並在那裡研究了平行程式語言的實作。最近,她在一家端點安全公司從事特定領域語言的工作。您可以在 https://norasandler.com 找到她關於惡作劇、編譯器和其他計算機科學主題的部落格。