Skip to content

Commit f3ccc2b

Browse files
authored
Update README.md of code import
Fix text appearances.
1 parent c7fc0c0 commit f3ccc2b

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

import/code/README.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The usage procedure is shown below.
2727
%auxil "pcc_ast_manager_t *"
2828
```
2929

30-
If the prefix is set with `%prefix`, all symbols starting with <code><b><i>pcc</i></b>`_`</code> are changed to those with the specified prefix as below.
30+
If the prefix is set with `%prefix`, all symbols starting with <code><b><i>pcc</i></b>\_</code> are changed to those with the specified prefix as below.
3131
```c
3232
%prefix "my"
3333

@@ -36,33 +36,33 @@ The usage procedure is shown below.
3636
%auxil "my_ast_manager_t *"
3737
```
3838
3. Create an AST node using either of the following functions in every rule action.
39-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_0(void);`</code>
39+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_0(void);</code>
4040
+ Returns a newly created nullary node.
41-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_0_str(const char *str);`</code>
41+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_0_str(const char *str);</code>
4242
+ Returns a newly created nullary node retaining a copy of the specified string.
43-
+ The string can be accessed using <code>`const char *`<b><i>pcc</i></b>`_ast_node__get_string(`<b><i>pcc</i></b>`_ast_node_t *node)`</code>.
44-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_1(`<b><i>pcc</i></b>`_ast_node_t *node);`</code>
43+
+ The string can be accessed using <code>const char *<b><i>pcc</i></b>\_ast_node__get_string(<b><i>pcc</i></b>\_ast_node_t *node)</code>.
44+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_1(<b><i>pcc</i></b>\_ast_node_t *node);</code>
4545
+ Returns a newly created unary node with one child node specified by the argument `node`.
46-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_2(`<b><i>pcc</i></b>`_ast_node_t *node0, `<b><i>pcc</i></b>`_ast_node_t *node1);`</code>
46+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_2(<b><i>pcc</i></b>\_ast_node_t *node0, <b><i>pcc</i></b>\_ast_node_t *node1);</code>
4747
+ Returns a newly created binary node with two child nodes specified by the argument `node0` and `node1`.
48-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_3(`<b><i>pcc</i></b>`_ast_node_t *node0, `<b><i>pcc</i></b>`_ast_node_t *node1, `<b><i>pcc</i></b>`_ast_node_t *node2);`</code>
48+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_3(<b><i>pcc</i></b>\_ast_node_t *node0, <b><i>pcc</i></b>\_ast_node_t *node1, <b><i>pcc</i></b>\_ast_node_t *node2);</code>
4949
+ Returns a newly created ternary node with three child nodes specified by the argument `node0`, `node1`, and `node2`.
50-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_v(void);`</code>
50+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_v(void);</code>
5151
+ Returns a newly created variadic node initially with no child node.
52-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__add_child(`<b><i>pcc</i></b>`_ast_node_t *obj, `<b><i>pcc</i></b>`_ast_node_t *node);`</code>
52+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__add_child(<b><i>pcc</i></b>\_ast_node_t *obj, <b><i>pcc</i></b>\_ast_node_t *node);</code>
5353
+ Adds a child node specified by the argument `node` to the variadic node `obj`.
5454
+ Can be used for `obj` as a variadic node only.
5555

56-
As written above, if the prefix is set with `%prefix`, all symbols starting with <code><b><i>pcc</i></b>`_`</code> are changed to those with the specified prefix.
56+
As written above, if the prefix is set with `%prefix`, all symbols starting with <code><b><i>pcc</i></b>\_</code> are changed to those with the specified prefix.
5757

5858
There are the variants of the node creation functions that enable setting a label as an `int` value.
5959
The label can be used for specifying node kinds in order to make it easier to analyze the AST in the later parsing steps.
60-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_0_ext(int label);`</code>
61-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_0_ext_str(int label, const char *str);`</code>
62-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_1_ext(int label, `<b><i>pcc</i></b>`_ast_node_t *node);`</code>
63-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_2_ext(int label, `<b><i>pcc</i></b>`_ast_node_t *node0, `<b><i>pcc</i></b>`_ast_node_t *node1);`</code>
64-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_3_ext(int label, `<b><i>pcc</i></b>`_ast_node_t *node0, `<b><i>pcc</i></b>`_ast_node_t *node1, `<b><i>pcc</i></b>`_ast_node_t *node2);`</code>
65-
- <code><b><i>pcc</i></b>`_ast_node_t *`<b><i>pcc</i></b>`_ast_node__create_v_ext(int label);`</code>
60+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_0_ext(int label);</code>
61+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_0_ext_str(int label, const char *str);</code>
62+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_1_ext(int label, <b><i>pcc</i></b>\_ast_node_t *node);</code>
63+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_2_ext(int label, <b><i>pcc</i></b>\_ast_node_t *node0, <b><i>pcc</i></b>\_ast_node_t *node1);</code>
64+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_3_ext(int label, <b><i>pcc</i></b>\_ast_node_t *node0, <b><i>pcc</i></b>\_ast_node_t *node1, <b><i>pcc</i></b>\_ast_node_t *node2);</code>
65+
- <code><b><i>pcc</i></b>\_ast_node_t *<b><i>pcc</i></b>\_ast_node__create_v_ext(int label);</code>
6666

6767
Every AST node retains the rule pattern matching range in the member variable `range`.
6868
Namely, `obj->range.start` and `obj->range.end` memorize `$0s` and `$0e` respectively at the time when the node `obj` was created in a rule action.
@@ -92,9 +92,9 @@ The usage procedure is shown below.
9292
#### Customization
9393
9494
To build a meaningful AST, customization of the node is needed.
95-
By defining the macro <code><b><i>PCC</i></b>`_AST_NODE_CUSTOM_DATA_DEFINED`</code> in a `%header` section before `%import "code/pcc_ast.peg"`,
96-
the node member variable `custom` whose data type is <code><b><i>pcc</i></b>`_ast_node_custom_data_t`</code> is enabled for storing node custom data.
97-
If the prefix is set with `%prefix`, the macro name <code><b><i>PCC</i></b>`_AST_NODE_CUSTOM_DATA_DEFINED`</code> is changed to those with the uppercased prefix as below.
95+
By defining the macro <code><b><i>PCC</i></b>\_AST_NODE_CUSTOM_DATA_DEFINED</code> in a `%header` section before `%import "code/pcc_ast.peg"`,
96+
the node member variable `custom` whose data type is <code><b><i>pcc</i></b>\_ast_node_custom_data_t</code> is enabled for storing node custom data.
97+
If the prefix is set with `%prefix`, the macro name <code><b><i>PCC</i></b>\_AST_NODE_CUSTOM_DATA_DEFINED</code> is changed to those with the uppercased prefix as below.
9898
```c
9999
%prefix "my"
100100
@@ -134,9 +134,9 @@ The concrete usage procedure is shown below.
134134
rule1 <- < [0-9]+ > { $$ = my_ast_node__create_0(); $$->custom.text = strdup($1); }
135135
```
136136
3. Implement the initialization and finalization functions for the node custom data.
137-
- <code>`void `<b><i>pcc</i></b>`_ast_node_custom_data__initialize(`<b><i>pcc</i></b>`_ast_node_custom_data_t *obj);`</code>
137+
- <code>void <b><i>pcc</i></b>\_ast_node_custom_data__initialize(<b><i>pcc</i></b>\_ast_node_custom_data_t *obj);</code>
138138
+ Initializes the node custom data `obj`.
139-
- <code>`void `<b><i>pcc</i></b>`_ast_node_custom_data__finalize(`<b><i>pcc</i></b>`_ast_node_custom_data_t *obj);`</code>
139+
- <code>void <b><i>pcc</i></b>\_ast_node_custom_data__finalize(<b><i>pcc</i></b>\_ast_node_custom_data_t *obj);</code>
140140
+ Finalizes the node custom data `obj`.
141141
142142
An example is as follows.
@@ -161,7 +161,7 @@ Note that, unlike other symbols, the prefix of these macro names is never change
161161
**`PCC_AST_MALLOC(`**_mgr_**`,`**_size_**`)`**
162162
163163
The function macro to allocate a memory block.
164-
The pointer to the instance of <code><b><i>pcc</i></b>`_ast_manager_t`</code> that was passed to the API function <code><b><i>pcc</i></b>`_create()`</code> can be retrieved from the argument _auxil_.
164+
The pointer to the instance of <code><b><i>pcc</i></b>\_ast_manager_t</code> that was passed to the API function <code><b><i>pcc</i></b>\_create()</code> can be retrieved from the argument _auxil_.
165165
It can be ignored if the instance does not concern memory allocation.
166166
The argument _size_ is the number of bytes to allocate.
167167
This macro must return a pointer to the allocated memory block, or `NULL` if no sufficient memory is available.
@@ -171,7 +171,7 @@ The default is defined as `PCC_MALLOC(mgr, size)`, which is used in the generate
171171
**`PCC_AST_REALLOC(`**_mgr_**`,`**_ptr_**`,`**_size_**`)`**
172172
173173
The function macro to reallocate the existing memory block.
174-
The pointer to the instance of <code><b><i>pcc</i></b>`_ast_manager_t`</code> that was passed to the API function <code><b><i>pcc</i></b>`_create()`</code> can be retrieved from the argument _auxil_.
174+
The pointer to the instance of <code><b><i>pcc</i></b>\_ast_manager_t</code> that was passed to the API function <code><b><i>pcc</i></b>\_create()</code> can be retrieved from the argument _auxil_.
175175
It can be ignored if the instance does not concern memory allocation.
176176
The argument _ptr_ is the pointer to the previously allocated memory block.
177177
The argument _size_ is the new number of bytes to reallocate.
@@ -183,7 +183,7 @@ The default is defined as `PCC_REALLOC(mgr, ptr, size)`, which is used in the ge
183183
**`PCC_AST_FREE(`**_mgr_**`,`**_ptr_**`)`**
184184
185185
The function macro to free the existing memory block.
186-
The pointer to the instance of <code><b><i>pcc</i></b>`_ast_manager_t`</code> that was passed to the API function <code><b><i>pcc</i></b>`_create()`</code> can be retrieved from the argument _auxil_.
186+
The pointer to the instance of <code><b><i>pcc</i></b>\_ast_manager_t</code> that was passed to the API function <code><b><i>pcc</i></b>\_create()</code> can be retrieved from the argument _auxil_.
187187
It can be ignored if the instance does not concern memory allocation.
188188
The argument _ptr_ is the pointer to the previously allocated memory block.
189189
This macro need not return a value.

0 commit comments

Comments
 (0)