Skip to content

Commit f5ef0b8

Browse files
committed
Add reference to grammar documentation and hints to transform it
1 parent 93f7ec2 commit f5ef0b8

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/grammar/parser.y

+31-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,37 @@ import java.util.Stack;
6868

6969
%%
7070
// Source: Java Language Specification - Third Edition
71-
// The Java(TM) Language Specification - Java SE 8 Edition ( Chapter 19. Syntax )
71+
// The Java(TM) Language Specification - Java SE 17 Edition ( Chapter 19. Syntax )
72+
//
73+
// Grammar Notation (Chapter 2.4)
74+
// The syntax {x} on the right-hand side of a production denotes zero or more occurrences of x.
75+
//
76+
// The syntax [x] on the right-hand side of a production denotes zero or one occurrences of x.
77+
// That is, x is an optional symbol. The alternative which contains the optional symbol actually defines two alternatives: one that omits the optional symbol and one that includes it.
78+
//
79+
// ** Transforming **
80+
// // Statement: {Key}
81+
// Statement: Keys_opt
82+
// ;
83+
//
84+
// // Key: value
85+
// Key: value
86+
// ;
87+
// Keys_opt:
88+
// | Keys_opt Key
89+
// ;
90+
//
91+
//
92+
// // Statement: [Key]
93+
// Statement: Key_opt
94+
// ;
95+
//
96+
// // Key: value
97+
// Key: value
98+
// ;
99+
// Key_opt:
100+
// | Key
101+
// ;
72102

73103
// ------------------------------
74104
// Productions from �7 (Packages)

0 commit comments

Comments
 (0)