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

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

by Tom Stuart
November 2017
Beginner to intermediate
344 pages
7h 2m
Chinese
GoTop Information, Inc.
Content preview from 深入理解運算原理|從簡單的機器到無所不能的程式
程式的意義
|
61
describe "Array#<<" do
it "correctly resizes the Array" do
a = []
a.size.should == 0
a << :foo
a.size.should == 1
a << :bar << :baz
a.size.should == 3
a = [1, 2, 3]
a.shift
a.shift
a.shift
a << :foo
a.should == [:foo]
end
end
實作解析器
我們在本章始終自行手寫 SIMPLE 程式的抽象語法樹(手寫像是
Assign.new(:x, Add.
new(Vari able.new(:x), Number.new(1)))
之類的 Ruby 運算式),而非從像是
'x = x + 1'
的原始 SIMPLE 原始碼開始,並且使用解析器自動將它轉換成語法樹。
從無到有的實作 SIMPLE 解析器將涉及許多細節,而且不只會將我們帶離形式語意的
討論,更會帶離很遠。拆解、剖析沒有價值的玩具程式語言雖然有趣,而且由於存在著
很多的解析工具和程式庫,因此若要根據其他人的努力來構建解析器也不會太過困難,
這裡便是如何完成的簡要概述。
Treetop
http://treetop.rubyforge.org/
)就是可以用在 Ruby 的最佳解析工具之一,這是
一種特定領域語言,它允許自動產生解析器,並以此作為描述語法的方式。Treetop
言語法的描述撰寫成 ...
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