Skip to content

Commit eacc8b3

Browse files
committed
Extract grammar
Grammar is now defined in <!-- GRAMMAR --> blocks. The actually displayed grammar will be auto-generated.
1 parent a1bfc76 commit eacc8b3

12 files changed

+1352
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/.commit-template
2+
*.swp

spec/04-basic-concepts.md

+19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@
33
A PHP *program* consists of one or more source files, known formally as
44
*scripts*.
55

6+
<!-- GRAMMAR
7+
script:
8+
script-section
9+
script script-section
10+
11+
script-section:
12+
text? start-tag statement-list? end-tag? text?
13+
14+
start-tag:
15+
'<?php'
16+
'<?='
17+
18+
end-tag:
19+
'?>'
20+
21+
text:
22+
"arbitrary text not containing any of" start-tag "sequences"
23+
-->
24+
625
<pre>
726
<i>script:</i>
827
<i>script-section</i>

spec/05-types.md

+19
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,25 @@ the requirements of a numeric string, and whose trailing characters are
119119
non-numeric. A *non-numeric string* is a string that is not a numeric
120120
string.
121121

122+
<!-- GRAMMAR
123+
str-numeric::
124+
str-whitespace? sign? str-number
125+
126+
str-whitespace::
127+
str-whitespace? str-whitespace-char
128+
129+
str-whitespace-char::
130+
new-line
131+
"Space character (U+0020)"
132+
"Horizontal-tab character (U+0009)"
133+
"Vertical-tab character (U+000B)"
134+
"Form-feed character (U+000C)"
135+
136+
str-number::
137+
digit-sequence
138+
floating-literal
139+
-->
140+
122141
<pre>
123142
<i>str-numeric::</i>
124143
<i>str-whitespace<sub>opt</sub> sign<sub>opt</sub> str-number</i>

spec/07-variables.md

+24
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,21 @@ $b = &colors[100]; // a VSlot for $b is created which points to the array
266266

267267
**Syntax**
268268

269+
<!-- GRAMMAR
270+
function-static-declaration:
271+
'static' static-variable-name-list ';'
272+
273+
static-variable-name-list:
274+
static-variable-declaration
275+
static-variable-name-list ',' static-variable-declaration
276+
277+
static-variable-declaration:
278+
variable-name function-static-initializer?
279+
280+
function-static-initializer:
281+
'=' constant-expression
282+
-->
283+
269284
<pre>
270285
<i>function-static-declaration:</i>
271286
static <i>static-variable-name-list</i> ;
@@ -350,6 +365,15 @@ echo "\$fs = $fs\n"; // $fs = 3
350365

351366
**Syntax**
352367

368+
<!-- GRAMMAR
369+
global-declaration:
370+
'global' variable-name-list ';'
371+
372+
variable-name-list:
373+
simple-variable
374+
variable-name-list ',' simple-variable
375+
-->
376+
353377
<pre>
354378
<i>global-declaration:</i>
355379
global <i>variable-name-list</i> ;

0 commit comments

Comments
 (0)