diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-19 09:49:20 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-19 09:49:20 +0300 |
commit | 304935a296997c9781688f08693ef70180dd24e4 (patch) | |
tree | 7b7801f3a97a780af1719826b2b9ef471151a352 /doc | |
parent | 6ef143bd53c35635b6d7edc6410d45fa58f54da2 (diff) | |
download | grecs-304935a296997c9781688f08693ef70180dd24e4.tar.gz grecs-304935a296997c9781688f08693ef70180dd24e4.tar.bz2 |
Reimplement grecs_format_ familiy as output-independent functions.
* src/format.c (grecs_format_docstring): Rename to grecs_print_docstring.
(grecs_format_simple_statement): Rename to grecs_print_simple_statement.
(grecs_format_block_statement): Rename to grecs_print_block_statement.
(grecs_format_statement_array): Rename to grecs_print_statement_array.
(grecs_format_locus): Rename to grecs_print_locus.
(grecs_format_node_path): Rename to grecs_print_node_path.
(grecs_format_value): Rename to grecs_print_value.
(grecs_format_node): Rename to grecs_print_node.
(grecs_format_locus,grecs_format_node_path)
(grecs_format_value,grecs_format_node): Reimplement as
output-independent functions.
All uses changed.
* src/grecs.h: Update prototypes.
* doc/grecs_format_locus.3: Update.
* doc/grecs_format_node.3: Update.
* doc/grecs_format_node_path.3: Update.
* doc/grecs_format_value.3: Update.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/grecs_format_locus.3 | 50 | ||||
-rw-r--r-- | doc/grecs_format_node.3 | 33 | ||||
-rw-r--r-- | doc/grecs_format_node_path.3 | 23 | ||||
-rw-r--r-- | doc/grecs_format_value.3 | 26 |
4 files changed, 104 insertions, 28 deletions
diff --git a/doc/grecs_format_locus.3 b/doc/grecs_format_locus.3 index a7743f1..83c9c0b 100644 --- a/doc/grecs_format_locus.3 +++ b/doc/grecs_format_locus.3 | |||
@@ -14,31 +14,59 @@ | |||
14 | .\" You should have received a copy of the GNU General Public License | 14 | .\" You should have received a copy of the GNU General Public License |
15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. | 15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. |
16 | .\" | 16 | .\" |
17 | .TH GRECS_FORMAT_LOCUS 3 "May 4, 2011" "GRECS" "Grecs User Reference" | 17 | .TH GRECS_FORMAT_LOCUS 3 "May 19, 2011" "GRECS" "Grecs User Reference" |
18 | .SH NAME | 18 | .SH NAME |
19 | grecs_format_locus \- format and output source file location | 19 | grecs_format_locus \- format and output source file location |
20 | .SH SYNOPSIS | 20 | .SH SYNOPSIS |
21 | .nf | 21 | .nf |
22 | .B #include <grecs.h> | 22 | .B #include <grecs.h> |
23 | .sp | 23 | .sp |
24 | .BI "void grecs_format_locus(grecs_locus_t " "*locus" ", FILE " "*fp" ); | 24 | .BI "void grecs_format_locus(grecs_locus_t " "*locus" "," |
25 | .ti +17 | ||
26 | .BI "struct grecs_format_closure " "*clos" ); | ||
27 | .sp | ||
28 | .BI "void grecs_print_locus(grecs_locus_t " "*locus" ", FILE " "*fp" ); | ||
29 | |||
25 | .SH DESCRIPTION | 30 | .SH DESCRIPTION |
26 | \fBgrecs_format_locus\fR formats the location from \fIlocus\fR in the | 31 | \fBgrecs_print_locus\fR formats the location from \fIlocus\fR in the |
27 | human-readable form and outputs it to file \fBfp\fR. | 32 | human-readable form and outputs it using the format closure |
33 | \fIclos\fR. The closure is defined as: | ||
34 | .sp | ||
35 | .nf | ||
36 | .in +5 | ||
37 | struct grecs_format_closure | ||
38 | { | ||
39 | int (*fmtfun)(const char *str, void *data); | ||
40 | void *data; | ||
41 | }; | ||
42 | .in | ||
43 | .fi | ||
28 | .PP | 44 | .PP |
29 | The location is output as follows: the file name, followed by a | 45 | While formatting the location, the formatter function \fBfmtfun\fR can |
30 | semicolon, followed by the line number. | 46 | be called one or more times. On each invocation, it is supplied with |
47 | the string to be output as its first argument, and pointer to | ||
48 | \fBdata\fR as the second one. | ||
31 | .PP | 49 | .PP |
32 | If \fIlocus\fR is \fBNULL\fR, \fBgrecs_format_locus\fR returns without | 50 | \fBgrecs_print_locus\fR is an alternative interface, which formats the |
51 | location from \fIlocus\fR in the human-readable form and outputs it to | ||
52 | file \fBfp\fR. | ||
53 | .PP | ||
54 | In both cases, the location is formatted as follows: the file name, | ||
55 | followed by a semicolon, followed by the line number. | ||
56 | .PP | ||
57 | If \fIlocus\fR is \fBNULL\fR, both functions return without | ||
33 | doing anything. | 58 | doing anything. |
34 | .SH "RETURN VALUE" | 59 | .SH "RETURN VALUE" |
35 | None. | 60 | None. |
36 | .SH NOTES | 61 | .SH NOTES |
37 | This is an auxiliary function used by | 62 | This are auxiliary functions used by |
38 | .BR grecs_format_node (3). | ||
39 | It is seldom needed in user programs. | ||
40 | .SH "SEE ALSO" | ||
41 | .BR grecs_format_node (3) | 63 | .BR grecs_format_node (3) |
64 | and | ||
65 | .BR grecs_print_node (3), | ||
66 | correspondingly. They are is seldom needed in user programs. | ||
67 | .SH "SEE ALSO" | ||
68 | .BR grecs_format_node (3), | ||
69 | .BR grecs_print_node (3). | ||
42 | .SH AUTHORS | 70 | .SH AUTHORS |
43 | Sergey Poznyakoff | 71 | Sergey Poznyakoff |
44 | .SH "BUG REPORTS" | 72 | .SH "BUG REPORTS" |
diff --git a/doc/grecs_format_node.3 b/doc/grecs_format_node.3 index 095a494..dd87ca7 100644 --- a/doc/grecs_format_node.3 +++ b/doc/grecs_format_node.3 | |||
@@ -14,7 +14,7 @@ | |||
14 | .\" You should have received a copy of the GNU General Public License | 14 | .\" You should have received a copy of the GNU General Public License |
15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. | 15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. |
16 | .\" | 16 | .\" |
17 | .TH GRECS_FORMAT_NODE 3 "May 4, 2011" "GRECS" "Grecs User Reference" | 17 | .TH GRECS_FORMAT_NODE 3 "May 19, 2011" "GRECS" "Grecs User Reference" |
18 | .SH NAME | 18 | .SH NAME |
19 | grecs_format_node \- format and print a single node from a syntax tree | 19 | grecs_format_node \- format and print a single node from a syntax tree |
20 | .SH SYNOPSIS | 20 | .SH SYNOPSIS |
@@ -22,11 +22,19 @@ grecs_format_node \- format and print a single node from a syntax tree | |||
22 | .B #include <grecs.h> | 22 | .B #include <grecs.h> |
23 | .sp | 23 | .sp |
24 | .BI "void grecs_format_node(struct grecs_node *" "node" ", int " \ | 24 | .BI "void grecs_format_node(struct grecs_node *" "node" ", int " \ |
25 | "flags" "," | ||
26 | .ti +17 | ||
27 | .BI "struct grecs_format_closure " "*clos" ); | ||
28 | .sp | ||
29 | .BI "void grecs_print_node(struct grecs_node *" "node" ", int " \ | ||
25 | "flags" ", FILE " "*fp" ); | 30 | "flags" ", FILE " "*fp" ); |
26 | .SH DESCRIPTION | 31 | .SH DESCRIPTION |
27 | \fBgrecs_format_node\fR prints to the output file \fBfp\fR the | 32 | \fBgrecs_format_node\fR formats the contents of a parse tree node |
28 | contents of a parse tree node \fBnode\fR, according to formatting | 33 | \fInode\fR, according to formatting options, given by \fIflags\fR. The |
29 | options, given by \fBflags\fR. | 34 | formatter closure \fIclos\fR is used for actual output. |
35 | .PP | ||
36 | \fBgrecs_print_node\fR is an alternative entry point, which formats | ||
37 | the node to the given file. | ||
30 | .PP | 38 | .PP |
31 | The \fBflags\fR argument is a bitwise \fBOR\fR of one or more of the | 39 | The \fBflags\fR argument is a bitwise \fBOR\fR of one or more of the |
32 | following options: | 40 | following options: |
@@ -72,6 +80,23 @@ Same as | |||
72 | GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE|GRECS_NODE_FLAG_QUOTE | 80 | GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE|GRECS_NODE_FLAG_QUOTE |
73 | .PP | 81 | .PP |
74 | If \fBflag\fR is 0, \fBGRECS_NODE_FLAG_DEFAULT\fR is assumed. | 82 | If \fBflag\fR is 0, \fBGRECS_NODE_FLAG_DEFAULT\fR is assumed. |
83 | .SH CLOSURE | ||
84 | The format closure is defined as: | ||
85 | .sp | ||
86 | .nf | ||
87 | .in +5 | ||
88 | struct grecs_format_closure | ||
89 | { | ||
90 | int (*fmtfun)(const char *str, void *data); | ||
91 | void *data; | ||
92 | }; | ||
93 | .in | ||
94 | .fi | ||
95 | .PP | ||
96 | While formatting the node, the formatter function \fBfmtfun\fR can | ||
97 | be called one or more times. On each invocation, it is supplied with | ||
98 | the string to be output as its first argument, and pointer to | ||
99 | \fBdata\fR as the second one. | ||
75 | .SH "RETURN VALUE" | 100 | .SH "RETURN VALUE" |
76 | None. | 101 | None. |
77 | .SH "SEE ALSO" | 102 | .SH "SEE ALSO" |
diff --git a/doc/grecs_format_node_path.3 b/doc/grecs_format_node_path.3 index bf119e7..ed687db 100644 --- a/doc/grecs_format_node_path.3 +++ b/doc/grecs_format_node_path.3 | |||
@@ -14,7 +14,7 @@ | |||
14 | .\" You should have received a copy of the GNU General Public License | 14 | .\" You should have received a copy of the GNU General Public License |
15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. | 15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. |
16 | .\" | 16 | .\" |
17 | .TH GRECS_FORMAT_NODE_PATH 3 "May 4, 2011" "GRECS" "Grecs User Reference" | 17 | .TH GRECS_FORMAT_NODE_PATH 3 "May 19, 2011" "GRECS" "Grecs User Reference" |
18 | .SH NAME | 18 | .SH NAME |
19 | grecs_format_node_path \- format and output statement pathname for the | 19 | grecs_format_node_path \- format and output statement pathname for the |
20 | node | 20 | node |
@@ -23,10 +23,21 @@ node | |||
23 | .B #include <grecs.h> | 23 | .B #include <grecs.h> |
24 | .sp | 24 | .sp |
25 | .BI "void grecs_format_node_path(struct grecs_node " "*node" ", int " \ | 25 | .BI "void grecs_format_node_path(struct grecs_node " "*node" ", int " \ |
26 | "flag" ", " | ||
27 | .ti +17 | ||
28 | .BI "struct grecs_format_closure " "*clos" ); | ||
29 | .sp | ||
30 | .BI "void grecs_print_node_path(struct grecs_node " "*node" ", int " \ | ||
26 | "flag" ", FILE " "*fp" ); | 31 | "flag" ", FILE " "*fp" ); |
27 | .SH DESCRIPTION | 32 | .SH DESCRIPTION |
28 | \fBgrecs_format_node_path\fR computes the \fIstatement pathname\fR for | 33 | \fBgrecs_format_node_path\fR computes the \fIstatement pathname\fR for |
29 | the \fInode\fR, and outputs it to the file \fBfp\fR. | 34 | the \fInode\fR, and outputs it using the closure \fIclos\fR. See |
35 | section \fBCLOSURE\fR in | ||
36 | .BR grecs_format_node (3), | ||
37 | for a description of struct grecs_format_closure. | ||
38 | .PP | ||
39 | \fBgrecs_print_node_path\fR is an alternative interface that outputs | ||
40 | the formatted data to the file. | ||
30 | .PP | 41 | .PP |
31 | The \fIflags\fR argument describes what character to use as a pathname | 42 | The \fIflags\fR argument describes what character to use as a pathname |
32 | component separator and how to format the statement tag, if \fInode\fR | 43 | component separator and how to format the statement tag, if \fInode\fR |
@@ -36,9 +47,11 @@ for a discussion of available flags. | |||
36 | .SH "RETURN VALUE" | 47 | .SH "RETURN VALUE" |
37 | None. | 48 | None. |
38 | .SH NOTES | 49 | .SH NOTES |
39 | This is an auxiliary function used by | 50 | This are auxiliary functions used by |
40 | .BR grecs_format_node (3). | 51 | .BR grecs_format_node (3) |
41 | It is seldom needed in user programs. | 52 | and |
53 | .BR grecs_print_node (3), | ||
54 | correspondingly. They are is seldom needed in user programs. | ||
42 | .SH "SEE ALSO" | 55 | .SH "SEE ALSO" |
43 | .BR grecs_format_node (3), | 56 | .BR grecs_format_node (3), |
44 | .BR grecs_stmt_path (5). | 57 | .BR grecs_stmt_path (5). |
diff --git a/doc/grecs_format_value.3 b/doc/grecs_format_value.3 index e4b45fa..918e972 100644 --- a/doc/grecs_format_value.3 +++ b/doc/grecs_format_value.3 | |||
@@ -14,7 +14,7 @@ | |||
14 | .\" You should have received a copy of the GNU General Public License | 14 | .\" You should have received a copy of the GNU General Public License |
15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. | 15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. |
16 | .\" | 16 | .\" |
17 | .TH GRECS_FORMAT_VALUE 3 "May 4, 2011" "GRECS" "Grecs User Reference" | 17 | .TH GRECS_FORMAT_VALUE 3 "May 19, 2011" "GRECS" "Grecs User Reference" |
18 | .SH NAME | 18 | .SH NAME |
19 | grecs_format_value \- format and output a configuration value | 19 | grecs_format_value \- format and output a configuration value |
20 | .SH SYNOPSIS | 20 | .SH SYNOPSIS |
@@ -22,21 +22,31 @@ grecs_format_value \- format and output a configuration value | |||
22 | .B #include <grecs.h> | 22 | .B #include <grecs.h> |
23 | .sp | 23 | .sp |
24 | .BI "void grecs_format_value(struct grecs_value *" "val" ", int " \ | 24 | .BI "void grecs_format_value(struct grecs_value *" "val" ", int " \ |
25 | "flags" ", " | ||
26 |