the grammar of graphics second pdf
时间: 2023-08-27 10:02:15 浏览: 49
《The Grammar of Graphics 第二版》是对图形语法的深入研究和讨论的一本书。图形语法是一种描述和创造图形的方法,它将图形视为由一系列有组织的组成要素构成的结构。通过了解这些组成要素及其相互之间的关系,可以更好地理解并优化图形的表达和传达。
本书的第二版在第一版的基础上进行了更新和扩充。它系统地介绍了图形语法的核心原理和概念,并在此基础上提供了丰富的示例和实践案例。读者可以通过学习本书,了解图形语法的基础知识,并学会如何运用图形语法来创建具有良好可读性和可解释性的图形。
除了介绍图形语法的基本原理之外,本书还探讨了多种不同类型的图形,包括散点图、折线图、柱状图等。它提供了关于如何使用图形语法来构建这些特定类型图形的具体指导和实践技巧。同时,本书还介绍了一些高级主题,如图形的标尺、颜色和布局等,帮助读者进一步提升图形的质量和效果。
《The Grammar of Graphics 第二版》是一本重要的图形学习资源,对于数据可视化、图形设计和数据分析领域的从业者和学习者来说都具有很高的参考价值。通过学习本书,读者可以在图形创作过程中更好地理解和运用图形语法,从而提高图形的可视化效果和表达能力。
相关问题
4.9 Consider the following grammar: lexp→atom|list atom →number|identifier list→(lexp-seq) lexp-seq→lexp, lexp-seq|lexp a. Left factor this grammar. b. Construct First and Follow sets for the nonterminals of the resulting grammar. c. Show that the resulting grammar is LL(1). d. Construct the LL(1) parsing table for the resulting grammar. e. Show the actions of the corresponding LL(1) parser, given the input string (a,(b,(2)),(c)).
a. Left factored grammar:
```
lexp → atom | list
atom → number A | identifier A
A → ε | , lexp A
list → ( lexp-seq )
lexp-seq → lexp B
B → ε | , lexp-seq
```
b. First and Follow sets:
```
FIRST(lexp) = {number, identifier, (}
FOLLOW(lexp) = {), ,}
FIRST(atom) = {number, identifier}
FOLLOW(atom) = {), ,}
FIRST(A) = {ε, ,}
FOLLOW(A) = {), ,}
FIRST(list) = {(}
FOLLOW(list) = {), ,}
FIRST(lexp-seq) = {number, identifier, (}
FOLLOW(lexp-seq) = {)}
FIRST(B) = {ε, ,}
FOLLOW(B) = {)}
```
c. The grammar is LL(1) because each nonterminal has distinct sets of FIRST and FOLLOW symbols, and there are no conflicts in the LL(1) parsing table.
d. LL(1) parsing table:
| | number | identifier | ( | ) | , |
|------------|--------|------------|-----|-----|-----|
| lexp | atom | atom | list | | |
| atom | number | identifier | | | |
| A | ε | , lexp A | | ) | , |
| list | | | ( lexp-seq ) | | |
| lexp-seq | atom | atom | list | | |
| B | ε | , lexp B | | ) | , |
e. Parsing the input string `(a,(b,(2)),(c))`:
| Stack | Input | Action |
|-------|-------|--------|
| $ | (a,(b,(2)),(c))$ | shift, push ( |
| $(, $ | a,(b,(2)),(c))$ | shift, push a |
| $(, a, $ | ,(b,(2)),(c))$ | shift, push , |
| $(, a, ,, $ | (b,(2)),(c))$ | shift, push ( |
| $(, a, ,, (, $ | b,(2)),(c))$ | shift, push b |
| $(, a, ,, (, b, $ | ,(2)),(c))$ | shift, push , |
| $(, a, ,, (, b, ,, $ | (2)),(c))$ | shift, push ( |
| $(, a, ,, (, b, ,, (, $ | 2)),(c))$ | shift, push 2 |
| $(, a, ,, (, b, ,, (, 2, $ | )),(c))$ | shift, pop 2, pop (, reduce to atom |
| $(, a, ,, (, b, ,, atom, $ | ),(c))$ | shift, pop atom, reduce to lexp |
| $(, a, ,, (, list, $ | ),(c))$ | shift, pop ), reduce to lexp-seq |
| $(, a, ,, lexp-seq, $ | ,(c))$ | shift, push , |
| $(, a, ,, lexp-seq, ,, $ | (c))$ | shift, push ( |
| $(, a, ,, lexp-seq, ,, (, $ | c))$ | shift, push c |
| $(, a, ,, lexp-seq, ,, (, c, $ | ), $ | shift, pop c, pop (, reduce to atom |
| $(, a, ,, lexp-seq, ,, atom, $ | ) | shift, pop atom, reduce to lexp |
| $(, a, ,, list, $ | ) | shift, pop ), reduce to lexp-seq |
| $(, lexp, $ | $ | shift, push $ |
| $ | $ | accept |
Write down an unambiguous grammar that generates the set of strings{s;,s;,s;s;s,...}.
Here is a grammar that generates the specified set of strings:
S -> S;S | ε
Explanation:
S represents a set of semicolons and can be expanded to include additional semicolons by recursively applying the production rule S -> S;S. The empty string is also included in the set and is represented by the production rule S -> ε.