Update of /cvsroot/flexml/flexml/testbed
In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv30895/testbed
Modified Files:
Makefile
Added Files:
init_header.act init_header.dtd init_header.h init_header.in
init_header.stdout.expected
Log Message:
Add code and tests that allow a user to specify a header file
on the flexml command line, using -h, to be included in the %{...%}
section of the generated .l file. Closes sourceforge bug #1526054.
--- NEW FILE: init_header.dtd ---
<!ELEMENT foo (#PCDATA|bar)*>
<!ELEMENT bar (#PCDATA)>
<!-- <!ATTLIST bar batt CDATA #REQUIRED> -->
--- NEW FILE: init_header.h ---
/* header file to be included at end of generated %{ ... %} section */
#define YY_DECL static int static_lexer_param; int lexer(int lexer_param)
#define YY_USER_INIT static_lexer_param = lexer_param;
--- NEW FILE: init_header.in ---
<!DOCTYPE foo SYSTEM "init_header.dtd">
<foo>012<bar>456789ab</bar>cdefghijklmn</foo>
Index: Makefile
===================================================================
RCS file: /cvsroot/flexml/flexml/testbed/Makefile,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile 30 Aug 2006 14:37:02 -0000 1.11
+++ Makefile 12 Sep 2006 18:05:45 -0000 1.12
@@ -40,20 +40,26 @@
#####################################################
EXES = mixed1 mixed-enumatt mixed-enumatt2 mixed-stratt mixed-stratt-def \
- multi-parser-run biparser
+ multi-parser-run biparser init_header
INTERMEDIATES = $(EXES) $(EXES:%=%.c) $(EXES:%=%.l)
+# leave this alphabetically sorted for easy scanning
UNIT_TESTS = \
- test_mixed1 \
+ test_biparser \
+ test_init_header \
test_mixed-enumatt \
test_mixed-enumatt2 \
test_mixed-stratt \
test_mixed-stratt-def \
- test_multi-parser-run \
- test_biparser
+ test_mixed1 \
+ test_multi-parser-run
test : $(UNIT_TESTS)
+# Test init_header
+test_init_header_cmd = ./init_header < init_header.in
+test_init_header_deps = init_header init_header.in
+
# Test mixed1
test_mixed1_cmd = ./mixed1 < mixed1.in
test_mixed1_deps = mixed1 mixed1.in
@@ -94,6 +100,11 @@
CLEANFILES+= biparser-one.h biparser-one.l biparser-one.c \
biparser-two.h biparser-two.l biparser-two.c
+init_header : init_header.act init_header.dtd init_header.h
+ $(FLEXML) -b 1000 -A -i$@.h -a$@.act $@.dtd
+ $(FLEX) -s -L -o$@.c $@.l
+ $(CC) $(CFLAGS) -o $@ $@.c
+
% : %.dtd %.act
$(FLEXML) -b 1000 -A -a$@.act $@.dtd
$(FLEX) -s -L -o$@.c $@.l
--- NEW FILE: init_header.stdout.expected ---
bar pcdata: 456789ab
foo pcdata: 012cdefghijklmn
param was 7
retval = 0
--- NEW FILE: init_header.act ---
<!DOCTYPE actions SYSTEM "flexml-act.dtd">
<actions>
<top><![CDATA[
#include <stdio.h>
]]></top>
<end tag='bar'><![CDATA[
printf("bar pcdata: %s\n", {#PCDATA});
]]></end>
<end tag='foo'><![CDATA[
printf("foo pcdata: %s\nparam was %d\n", {#PCDATA}, static_lexer_param);
]]></end>
<main><![CDATA[
int main(int argc, char **argv)
{
int retval = lexer(7);
printf("retval = %d\n", retval);
return retval;
}
]]></main>
</actions>
|