-
-# 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
struct statement *elsepart;
};
-# code
+# indent: code
+ #include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>
}
-# grammar
+# indent: grammar
~~~~~~
$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
+++ /dev/null
-
-# 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
-