diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-03 17:49:29 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-03 21:23:21 +0300 |
commit | 3d679b3df641f59fb81ca1651799f4e2965ed67e (patch) | |
tree | 5a614ee25cff44d015ee9e6f6920e2ba19379bba | |
parent | 24ec67c9f6375d34d88e79981ed8abbe15a78169 (diff) | |
download | grecs-3d679b3df641f59fb81ca1651799f4e2965ed67e.tar.gz grecs-3d679b3df641f59fb81ca1651799f4e2965ed67e.tar.bz2 |
Switch to the two-layer model. Add testsuite.
The configuration file parser creates a syntax tree. This step
does not require any knowledge about which keywords are allowed.
The user can then either use that tree directly, or post-process
it using parser tables. The latter approach is equivalent to
previous versions of grecs.
-rw-r--r-- | .gitignore | 29 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | am/grecs.m4 | 21 | ||||
-rw-r--r-- | src/.gitignore | 4 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/diag.c | 73 | ||||
-rw-r--r-- | src/format.c | 121 | ||||
-rw-r--r-- | src/grecs-gram.y | 715 | ||||
-rw-r--r-- | src/grecs.h | 86 | ||||
-rw-r--r-- | src/lookup.c | 272 | ||||
-rw-r--r-- | src/tree.c | 773 | ||||
-rw-r--r-- | tests/.gitignore | 8 | ||||
-rw-r--r-- | tests/Makefile.am | 84 | ||||
-rw-r--r-- | tests/atlocal.in | 10 | ||||
-rw-r--r-- | tests/cfhelp.at | 76 | ||||
-rw-r--r-- | tests/format00.at | 38 | ||||
-rw-r--r-- | tests/format01.at | 38 | ||||
-rw-r--r-- | tests/format02.at | 38 | ||||
-rw-r--r-- | tests/gcf1.conf | 54 | ||||
-rw-r--r-- | tests/gcffmt.c | 67 | ||||
-rw-r--r-- | tests/gcfpeek.c | 76 | ||||
-rw-r--r-- | tests/gcfset.c | 240 | ||||
-rw-r--r-- | tests/peek00.at | 25 | ||||
-rw-r--r-- | tests/peek01.at | 30 | ||||
-rw-r--r-- | tests/peek02.at | 26 | ||||
-rw-r--r-- | tests/peek03.at | 33 | ||||
-rw-r--r-- | tests/set.at | 38 | ||||
-rw-r--r-- | tests/testsuite.at | 54 |
28 files changed, 2318 insertions, 716 deletions
@@ -1,4 +1,25 @@ | |||
1 | gconf-gram.c | 1 | *.a |
2 | gconf-gram.h | 2 | *.o |
3 | gconf-gram.output | 3 | *.tar.* |
4 | gconf-lex.c | 4 | *~ |
5 | .deps | ||
6 | .emacs.desktop | ||
7 | .emacs.desktop.lock | ||
8 | .emacsrc | ||
9 | ABOUT-NLS | ||
10 | ChangeLog | ||
11 | INSTALL | ||
12 | Makefile | ||
13 | Makefile.in | ||
14 | TAGS | ||
15 | aclocal.m4 | ||
16 | autom4te.cache | ||
17 | build-aux | ||
18 | config.h | ||
19 | config.h.in | ||
20 | config.log | ||
21 | config.status | ||
22 | configure | ||
23 | core | ||
24 | m4 | ||
25 | stamp-h1 | ||
diff --git a/Makefile.am b/Makefile.am index 1bfdcf4..17f1ff6 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -1 +1 @@ | |||
SUBDIRS=src | SUBDIRS=src @GRECS_TESTDIR@ | ||
diff --git a/am/grecs.m4 b/am/grecs.m4 index 47c9867..5fc1819 100644 --- a/am/grecs.m4 +++ b/am/grecs.m4 | |||
@@ -46,33 +46,35 @@ AC_DEFUN([_GRECS_OPTION_SWITCH], | |||
46 | # _GRECS_SET_OPTIONS(OPTIONS) | 46 | # _GRECS_SET_OPTIONS(OPTIONS) |
47 | # ---------------------------------- | 47 | # ---------------------------------- |
48 | # OPTIONS is a space-separated list of Grecs options. | 48 | # OPTIONS is a space-separated list of Grecs options. |
49 | AC_DEFUN([_GRECS_SET_OPTIONS], | 49 | AC_DEFUN([_GRECS_SET_OPTIONS], |
50 | [m4_foreach_w([_GRECS_Option], [$1], [_GRECS_SET_OPTION(_GRECS_Option)])]) | 50 | [m4_foreach_w([_GRECS_Option], [$1], [_GRECS_SET_OPTION(_GRECS_Option)])]) |
51 | 51 | ||
52 | # GRECS_SETUP([OPTIONS],[pp-setup-file]) | 52 | # GRECS_SETUP([dir],[OPTIONS],[pp-setup-file]) |
53 | # | 53 | # dir - Directory in the source tree where grecs has been cloned. |
54 | # Options are: | 54 | # OPTIONS are: |
55 | # no-preproc Disable the use of preprocessor. | 55 | # no-preproc Disable the use of preprocessor. |
56 | # std-pp-setup Install standard pp-setup file. | 56 | # std-pp-setup Install standard pp-setup file. |
57 | # pp-setup-option Add the --with-pp-setup-file option to the | 57 | # pp-setup-option Add the --with-pp-setup-file option to the |
58 | # configuration file. The option allows user to | 58 | # configuration file. The option allows user to |
59 | # control whether the pp-setup file is installed. | 59 | # control whether the pp-setup file is installed. |
60 | # tests Build tests. | ||
60 | # | 61 | # |
61 | # The pp-setup-file argument supplies the pathname of the preprocessor | 62 | # The pp-setup-file argument supplies the pathname of the preprocessor |
62 | # setup file in the source tree. It is ignored if std-pp-setup option is | 63 | # setup file in the source tree. It is ignored if std-pp-setup option is |
63 | # given. | 64 | # given. |
64 | # | 65 | # |
65 | # If neither std-pp-setup option, nor pp-setup-file argument are supplied, | 66 | # If neither std-pp-setup option, nor pp-setup-file argument are supplied, |
66 | # no preprocessor setup file is installed. | 67 | # no preprocessor setup file is installed. |
67 | 68 | ||
68 | AC_DEFUN([GRECS_SETUP],[ | 69 | AC_DEFUN([GRECS_SETUP],[ |
69 | AC_PROG_YACC | 70 | AC_PROG_YACC |
70 | AM_PROG_LEX | 71 | AM_PROG_LEX |
71 | 72 | ||
72 | _GRECS_SET_OPTIONS([$1]) | 73 | AC_SUBST([GRECS_SUBDIR],m4_if([$1],,grecs,$1)) |
74 | _GRECS_SET_OPTIONS([$2]) | ||
73 | # ********************** | 75 | # ********************** |
74 | # Preprocessor | 76 | # Preprocessor |
75 | # ********************** | 77 | # ********************** |
76 | _GRECS_IF_OPTION_SET([no-preproc], | 78 | _GRECS_IF_OPTION_SET([no-preproc], |
77 | [use_ext_pp=no], | 79 | [use_ext_pp=no], |
78 | [AC_ARG_WITH([preprocessor], | 80 | [AC_ARG_WITH([preprocessor], |
@@ -101,13 +103,13 @@ AC_DEFUN([GRECS_SETUP],[ | |||
101 | AC_PATH_PROG(PPBIN, $DEFAULT_PREPROCESSOR) | 103 | AC_PATH_PROG(PPBIN, $DEFAULT_PREPROCESSOR) |
102 | DEFAULT_PREPROCESSOR=$PPBIN | 104 | DEFAULT_PREPROCESSOR=$PPBIN |
103 | if test -n "$DEFAULT_PREPROCESSOR"; then | 105 | if test -n "$DEFAULT_PREPROCESSOR"; then |
104 | DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS" | 106 | DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS" |
105 | _GRECS_IF_OPTION_SET([std-pp-setup], | 107 | _GRECS_IF_OPTION_SET([std-pp-setup], |
106 | [PP_SETUP_FILE='pp-setup'], | 108 | [PP_SETUP_FILE='pp-setup'], |
107 | [m4_if([$2],,[PP_SETUP_FILE=],[PP_SETUP_FILE='$2'])]) | 109 | [m4_if([$3],,[PP_SETUP_FILE=],[PP_SETUP_FILE='$3'])]) |
108 | AC_SUBST(PP_SETUP_FILE) | 110 | AC_SUBST(PP_SETUP_FILE) |
109 | if test -n "$PP_SETUP_FILE"; then | 111 | if test -n "$PP_SETUP_FILE"; then |
110 | _GRECS_IF_OPTION_SET([pp-setup-option], | 112 | _GRECS_IF_OPTION_SET([pp-setup-option], |
111 | [AC_ARG_WITH([pp-setup-file], | 113 | [AC_ARG_WITH([pp-setup-file], |
112 | AC_HELP_STRING([--with-pp-setup-file], | 114 | AC_HELP_STRING([--with-pp-setup-file], |
113 | [install the default pp-setup file]), | 115 | [install the default pp-setup file]), |
@@ -124,8 +126,17 @@ AC_DEFUN([GRECS_SETUP],[ | |||
124 | fi | 126 | fi |
125 | PATH=$save_PATH | 127 | PATH=$save_PATH |
126 | DEFAULT_PREPROCESSOR="\\\"$DEFAULT_PREPROCESSOR\\\"" | 128 | DEFAULT_PREPROCESSOR="\\\"$DEFAULT_PREPROCESSOR\\\"" |
127 | else | 129 | else |
128 | DEFAULT_PREPROCESSOR=NULL | 130 | DEFAULT_PREPROCESSOR=NULL |
129 | fi | 131 | fi |
132 | _GRECS_IF_OPTION_SET([tests], | ||
133 | [m4_pushdef([TESTDIR],m4_if([$1],,grecs,$1)/tests) | ||
134 | AC_CONFIG_TESTDIR(TESTDIR) | ||
135 | AC_CONFIG_FILES(TESTDIR/Makefile TESTDIR/atlocal) | ||
136 | m4_popdef([TESTDIR]) | ||
137 | AM_MISSING_PROG([AUTOM4TE], [autom4te]) | ||
138 | GRECS_TESTDIR=tests | ||
139 | ]) | ||
130 | AC_SUBST([GRECS_INCLUDES]) | 140 | AC_SUBST([GRECS_INCLUDES]) |
141 | AC_SUBST([GRECS_TESTDIR]) | ||
131 | ]) | 142 | ]) |
diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..7c38320 --- /dev/null +++ b/src/.gitignore | |||
@@ -0,0 +1,4 @@ | |||
1 | grecs-gram.c | ||
2 | grecs-gram.h | ||
3 | grecs-gram.output | ||
4 | grecs-lex.c | ||
diff --git a/src/Makefile.am b/src/Makefile.am index 759716b..0c2c444 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -13,20 +13,23 @@ | |||
13 | # | 13 | # |
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 Grex. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Grex. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | noinst_LIBRARIES=libgrecs.a | 17 | noinst_LIBRARIES=libgrecs.a |
18 | libgrecs_a_SOURCES = \ | 18 | libgrecs_a_SOURCES = \ |
19 | diag.c\ | ||
19 | format.c\ | 20 | format.c\ |
20 | grecs-gram.y\ | 21 | grecs-gram.y\ |
21 | grecs-lex.l\ | 22 | grecs-lex.l\ |
22 | list.c\ | 23 | list.c\ |
24 | lookup.c\ | ||
23 | mem.c\ | 25 | mem.c\ |
24 | preproc.c\ | 26 | preproc.c\ |
25 | symtab.c\ | 27 | symtab.c\ |
26 | text.c\ | 28 | text.c\ |
29 | tree.c\ | ||
27 | grecs.h\ | 30 | grecs.h\ |
28 | wordsplit.c\ | 31 | wordsplit.c\ |
29 | wordsplit.h | 32 | wordsplit.h |
30 | 33 | ||
31 | EXTRA_DIST=grecs-gram.h $(PP_SETUP_FILE) | 34 | EXTRA_DIST=grecs-gram.h $(PP_SETUP_FILE) |
32 | 35 | ||
diff --git a/src/diag.c b/src/diag.c new file mode 100644 index 0000000..fcb8fd2 --- /dev/null +++ b/src/diag.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* grecs - Gray's Extensible Configuration System | ||
2 | Copyright (C) 2007-2011 Sergey Poznyakoff | ||
3 | |||
4 | Grecs is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published by the | ||
6 | Free Software Foundation; either version 3 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | Grecs is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with Grecs. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #ifdef HAVE_CONFIG_H | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | #include <grecs.h> | ||
21 | #include <stdlib.h> | ||
22 | #include <stdio.h> | ||
23 | #include <string.h> | ||
24 | #include <errno.h> | ||
25 | |||
26 | static void | ||
27 | default_print_diag(grecs_locus_t *locus, int err, int errcode, const char *msg) | ||
28 | { | ||