From 34189a207bc903e9ff96549ad222fa20f2e41508 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 3 Oct 2014 14:01:45 +1000 Subject: [PATCH] indent_test: integrate into Makefile scheme nicely. The test code is now included in indent_test.mdc, and there is a '.mk'. make tests will run the test. Signed-off-by: NeilBrown --- csrc/{indent_test.cgm => indent_test.mdc} | 65 +++++++++++++++++++++-- csrc/itest.code | 38 ------------- 2 files changed, 60 insertions(+), 43 deletions(-) rename csrc/{indent_test.cgm => indent_test.mdc} (83%) delete mode 100644 csrc/itest.code diff --git a/csrc/indent_test.cgm b/csrc/indent_test.mdc similarity index 83% rename from csrc/indent_test.cgm rename to csrc/indent_test.mdc index 974c167..792e152 100644 --- a/csrc/indent_test.cgm +++ b/csrc/indent_test.mdc @@ -1,11 +1,25 @@ - -# header - This parser is primarily for testing indent and linebreak handling. It reads a very simple code fragment with if/else statements and simple assignments with expressions, and then prints out the same with complete bracketing and indenting. +# File: indent_test.mk + myCFLAGS := -Wall -g -fplan9-extensions + CFLAGS := $(filter-out $(myCFLAGS),$(CFLAGS)) $(myCFLAGS) + LDLIBS:= libparser.o libscanner.o libmdcode.o -licuuc + + all :: itest + itest.c itest.h : indent_test.mdc parsergen libparser.o libscanner.o libmdcode.o + ./parsergen -o itest --LALR --tag indent indent_test.mdc + indent_test.mk: indent_test.mdc md2c + ./md2c indent_test.mdc + itest: itest.c + + tests:: itest itest.code + ./itest itest.code + +# indent: header + ./parsergen -o itest --LALR indent_test.cgm cc -o itest itest.c lib*.o -licuuc -lgmp ./itest itest.code @@ -21,7 +35,8 @@ with complete bracketing and indenting. struct statement *elsepart; }; -# code +# indent: code + #include #include #include #include @@ -108,7 +123,7 @@ with complete bracketing and indenting. } -# grammar +# indent: grammar ~~~~~~ @@ -227,4 +242,44 @@ $*expression $0 = calloc(1, sizeof(struct expression)); $0->op = $1.txt; }$ +~~~~~~ + +# File: itest.code + + # test code + ~~~~~~ + hello = yes; mister = no; + there = x; + all = y; + if cond + cond2 : + hello = x; + hello2 = x; + + sum = val + + val; + + if condX: + foo = x * + x + + y + / two; + else if cond2: + there1 =x + there1a=x + there2=x + there3=x; + all = y; + if true {yes=x;} else : no=x + if true: yes = no; no = yes; + + if false { + print = OK + } else { + print = not_OK + } + + if a: + if b: + c= d + x = y diff --git a/csrc/itest.code b/csrc/itest.code deleted file mode 100644 index 86b71a4..0000000 --- a/csrc/itest.code +++ /dev/null @@ -1,38 +0,0 @@ - -# stuff - - hello = yes; mister = no; - there = x; - all = y; - if cond + cond2 : - hello = x; - hello2 = x; - - sum = val + - val; - - if condX: - foo = x * - x + - y - / two; - else if cond2: - there1 =x - there1a=x - there2=x - there3=x; - all = y; - if true {yes=x;} else : no=x - if true: yes = no; no = yes; - - if false { - print = OK - } else { - print = not_OK - } - - if a: - if b: - c= d - x = y - -- 2.43.0