Skip to Content
深入理解運算原理|從簡單的機器到無所不能的程式
book

深入理解運算原理|從簡單的機器到無所不能的程式

by Tom Stuart
November 2017
Beginner to intermediate
344 pages
7h 2m
Chinese
GoTop Information, Inc.
Content preview from 深入理解運算原理|從簡單的機器到無所不能的程式
58
|
2
應用
完成所有這些工作之後,這個指稱語意完成了什麼?它主要的目的是示範如何將
SIMPLE 轉譯成 Ruby,使用後者作為解釋各種語言結構意義的工具。這剛好給了我們
執行 SIMPLE 程序的方式(因為我們在可執行的 Ruby 撰寫了指稱語意規則,而且因為
規則的輸出就是可執行的 Ruby 本身),但那只是偶然,因為我們能以簡單易懂的英語
提供規則,並且使用一些數學語言作為指稱。重要的部分是,我們採用了我們自己設計
的任意語言,並將它轉換成某人或別的東西可以理解的語言。
為了給這些轉譯一些解釋能力,讓語言意義的某些部分浮出水面(而非讓它們繼續沈
默)會很有幫助。舉例來說,這種語意將環境顯示成具體的 Ruby 物件(傳進和傳出
proc 的雜湊)而讓環境變得明確,而不是將變數表示成真正的 Ruby 變數,也不是依賴
Ruby 自己難以理解的範圍規則來指定變數存取工作。語意在這方面不僅將所有的解釋
工作都推給 Ruby;它以 Ruby 作為簡單的基礎,卻在頂端做了一些額外的工作,藉以
精準的示範如何以不同的程式建構物來使用和改變環境。
我們在前面看到,操作語意是藉由設計語言的直釋器來解釋語言的意義。相較之下,操
作語意語言對語言的翻譯就像
編譯器
compiler
):在這種情況,我們
#to_ruby
的實作
物會很有效率的將 SIMPLE 編譯成 Ruby。這些語意風格無一必能說明如何
有效
實作語
言的直釋器或編譯器,但是它們提供了官方基準,可以判斷任何有效率的實作物的正確
性。
這些指稱定義也出現在現實生活 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JSON實務手冊

JSON實務手冊

Tom Marrs

Publisher Resources

ISBN: 9789864766000