Skip to content

Commit 00cf312

Browse files
committed
Amended lemon docs [skip appveyor]
1 parent e8b7ab1 commit 00cf312

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

parser/zephir.lemon

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,36 @@
88
* the LICENSE file that was distributed with this source code.
99
*/
1010

11+
// All token codes are small integers with #defines that begin with "XX_"
1112
%token_prefix XX_
13+
14+
// The type of the data attached to each token is xx_parser_token.
1215
%token_type {xx_parser_token*}
16+
17+
// Default type for non-terminals is zval.
1318
%default_type {zval}
19+
20+
// The generated parser function takes a 4th argument as follows:
21+
%extra_argument {xx_parser_status *status}
22+
1423
%default_destructor {
1524
if (&$$) {
1625
zval_ptr_dtor(&$$);
1726
}
1827
}
19-
%extra_argument {xx_parser_status *status}
28+
29+
// The name of the generated procedure that implements the parser
30+
// is as follows:
2031
%name xx_
2132

33+
// Define operator precedence early so that this is the first occurrence
34+
// of the operator tokens in the grammer. Keeping the operators together
35+
// causes them to be assigned integer values that are close together,
36+
// which keeps parser tables smaller.
37+
//
38+
// The token values assigned to these symbols is determined by the order
39+
// in which lemon first sees them.
2240
%left INTERNAL PUBLIC PROTECTED STATIC PRIVATE SCOPED .
23-
2441
%left COMMA .
2542
%right REQUIRE .
2643
%right DOUBLEARROW .
@@ -45,16 +62,18 @@
4562
%right SBRACKET_OPEN .
4663
%right ARROW .
4764

65+
// The following text is included near the beginning of the C source
66+
// code file that implements the parser.
4867
%include {
4968
#include "parser.h"
5069
}
70+
// end %include
5171

72+
// This code runs whenever there is a syntax error
5273
%syntax_error {
53-
5474
zval syntax_error;
5575

5676
array_init(&syntax_error);
57-
5877
parser_add_str(&syntax_error, "type", "error");
5978

6079
if (status->scanner_state->start_length) {
@@ -80,7 +99,7 @@
8099
}
81100
}
82101

83-
program ::= xx_language(Q) . {
102+
input ::= xx_language(Q) . {
84103
status->ret = Q;
85104
}
86105

0 commit comments

Comments
 (0)