aboutsummaryrefslogtreecommitdiff
path: root/tests/tforlan.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-09-25 14:23:29 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-09-25 14:23:29 +0300
commit2f5d961c798802f1e467de1cd310f661e0a45fa7 (patch)
tree35740af31dd26149735358e80938d5399c50e1ff /tests/tforlan.c
parent5424ff2a0969b31f84690cd19bea4e363d32e63a (diff)
downloadeclat-2f5d961c798802f1e467de1cd310f661e0a45fa7.tar.gz
eclat-2f5d961c798802f1e467de1cd310f661e0a45fa7.tar.bz2
Implement variables and loops in forlan.
* lib/forlan.c (free_type_comp): Free labels and argv. (dump_comp): Rewrite. (eval_node_finder): Remove. (eval_comp): Rewrite. (eval_comp0): New function. (free_type_loop, dump_loop, eval_loop) (dump_continue, eval_continue) (dump_break, eval_break) (dump_stop, eval_stop): New methods. (f_tab): Add new methods. * lib/forlan.h (forlan_node_comp): Change structure. * lib/forlangrm.y: Implement loops. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Likewise. * tests/forlan01.at: Update. * tests/tforlan.c: New option -s (sort tree). * tests/dump01.at: New file. * tests/dump02.at: New file. * tests/last.at: New file. * tests/let.at: New file. * tests/listall.at: New file. * tests/print01.at: New file. * tests/print02.at: New file. * tests/print03.at: New file. * tests/tags.xml: New file. * tests/tagshairy.at: New file.
Diffstat (limited to 'tests/tforlan.c')
-rw-r--r--tests/tforlan.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/tforlan.c b/tests/tforlan.c
index 550bc03..8969c6d 100644
--- a/tests/tforlan.c
+++ b/tests/tforlan.c
@@ -53,13 +53,28 @@ parse_xml(FILE *fp)
part = eclat_partial_tree_create();
XML_SetUserData(parser, part);
- while ((size = fread(buffer, 1, sizeof(buffer), fp)) > 0)
- XML_Parse(parser, buffer, size, 0);
+ while ((size = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
+ enum XML_Status status = XML_Parse(parser, buffer, size, 0);
+ if (status == XML_STATUS_ERROR) {
+ enum XML_Error error = XML_GetErrorCode(parser);
+ int line = XML_GetCurrentLineNumber(parser);
+ int column = XML_GetCurrentColumnNumber(parser);
+
+ die(EX_SOFTWARE, "XML parse error at %d:%d: %s",
+ line, column, XML_ErrorString(error));
+ }
+ }
XML_Parse(parser, "", 0, 1);
return eclat_partial_tree_finish(part);
}
+static int
+node_ident_cmp(struct grecs_node const *a, struct grecs_node const *b)
+{
+ return strcmp(a->ident, b->ident);
+}
+
int
main(int argc, char **argv)
{
@@ -70,12 +85,13 @@ main(int argc, char **argv)
struct grecs_locus_point pt;
int rc;
int dump_option = 0;
+ int sort_option = 0;
forlan_eval_env_t env;
set_program_name(argv[0]);
forlan_init();
- while ((rc = getopt(argc, argv, "Dd:h")) != EOF)
+ while ((rc = getopt(argc, argv, "Dd:hs")) != EOF)
switch (rc) {
case 'D':
dump_option++;
@@ -90,6 +106,10 @@ main(int argc, char **argv)
usage();
return 0;
+ case 's':
+ sort_option = 1;
+ break;
+
default:
exit(EX_USAGE);
}
@@ -133,11 +153,14 @@ main(int argc, char **argv)
argv[1], strerror(errno));
tree = parse_xml(fp);
fclose(fp);
+
+ if (sort_option)
+ grecs_tree_sort(tree, node_ident_cmp);
forlan_run(env, tree);
grecs_tree_free(tree);
}
-
+
forlan_free_environment(env);

Return to:

Send suggestions and report system problems to the System administrator.