Download Copper User Manual

Transcript
Contents
1
Introduction.
1.1 Copper in a nutshell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Example specification. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
Copper’s parsing algorithms.
2.1 Context-aware scanning. . . . . . . . . . . .
2.2 Specification of whitespace and other layout.
2.2.1 Layout in traditional tools. . . . . . .
2.2.2 How Copper handles layout. . . . . .
2.2.3 How to specify layout in Copper. . .
2.2.3.1 Universal layout. . . . . . .
2.2.3.2 Layout per production. . .
2.3 Lexical precedence paradigm. . . . . . . . .
2.3.1 Dominate/submit-lists. . . . . . . . .
2.3.2 Disambiguation functions/groups. . .
2.4 Transparent prefixes. . . . . . . . . . . . . .
3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Format of grammar specifications.
3.1 Comments and whitespace. . . . . . . . . . . . . . . .
3.2 Preamble. . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Parser name. . . . . . . . . . . . . . . . . . . . . . . .
3.4 Lexical syntax blocks. . . . . . . . . . . . . . . . . .
3.4.1 Terminal class declarations. . . . . . . . . . .
3.4.2 Terminal declarations. . . . . . . . . . . . . .
3.4.2.1 Semantic actions on terminals. . . .
3.4.3 Disambiguation functions/groups. . . . . . . .
3.5 Context-free syntax blocks. . . . . . . . . . . . . . . .
3.5.1 Nonterminal/start-symbol declarations. . . . .
3.5.2 Operator precedence/associativity declarations.
3.5.3 Production declarations. . . . . . . . . . . . .
3.5.3.1 Semantic actions. . . . . . . . . . .
3.6 User code blocks. . . . . . . . . . . . . . . . . . . . .
3.6.1 Auxiliary. . . . . . . . . . . . . . . . . . . . .
3.6.2 Initialization. . . . . . . . . . . . . . . . . . .
3.7 Parser attributes. . . . . . . . . . . . . . . . . . . . . .
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
3
.
.
.
.
.
.
.
.
.
.
.
7
. 7
. 7
. 7
. 8
. 8
. 8
. 9
. 9
. 10
. 10
. 11
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
12
12
12
12
12
13
13
13
14
15
15
16
16
17
17
17
18
18
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.