]> ocean-lang.org Git - ocean/blobdiff - csrc/indent_test.mdc
indent_test: integrate into Makefile scheme nicely.
[ocean] / csrc / indent_test.mdc
similarity index 83%
rename from csrc/indent_test.cgm
rename to csrc/indent_test.mdc
index 974c1676e55c5e531e64733b3906bd9876a77d6d..792e152523055781b282ac2d261fcae324f0fc79 100644 (file)
@@ -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 <unistd.h>
        #include <stdlib.h>
        #include <fcntl.h>
        #include <sys/mman.h>
@@ -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