Skip to Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
5.11 實作語法分析器(Parser)與文法
|
231
分析可能為空的形容詞串列
形容詞串列文法,
介系詞子句文法,
分析副詞串列(也可能沒有)
副詞串列文法,
[Page-231]
ch05.indd 231 2014/4/2 上午 06:13:38
232
|
第五章
使用遵守此文法的語句對語法分析器進行測試。[Page-232]
討論說明
你可能會覺得奇怪,既然要手工打造語法分析器,為什麼還要費力建立文法。首先,此
分析器並不是我撰寫的,我只是把 Daniel Lichtblau 的分析器美化一番,正經一點的理
由是,除了語法分析器,文法也可以用來建立語言生成器,生成器對於測試分析器十
分有用。以下根據 Lichtblau 實作的生成器,加以改造一番。因為善用了 Mathematica
模式匹配的功能,首先改善的 是,本文 的實作是陳述式的(declarative)而非程序式
的(procedural)。其次是生成器吸收了程式複雜度,因此文法可以繼續保持簡潔。在
Lichtblau 原本的文法中,由於程式建構的理由,文法表示非常的麻煩,例如
Hold[]
指
令及隨機選擇的實作方式。除了機率的存在外,前文所建構的文法非常乾淨,事實上它
跟 BNF 一樣易讀。如果讀者想要比較我的版本與原始的實作版本,請參考「 ...
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

Mathematica Cookbook

Mathematica Cookbook

Sal Mangano
人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar

Publisher Resources

ISBN: 9789863470106