X-Git-Url: https://ocean-lang.org/code/?a=blobdiff_plain;f=csrc%2Findent_test.mdc;h=f3bd7f1517960575b2ceb71253f2647c739223ae;hb=6c169be0f1605d213b40db3a99b6b3689fd524da;hp=7b5fe5ccc5769281242cf53b4d98a0b54b4674bb;hpb=1755b9a1a4070502f4a46ba1f4accc6f9feb7fd4;p=ocean diff --git a/csrc/indent_test.mdc b/csrc/indent_test.mdc index 7b5fe5c..f3bd7f1 100644 --- a/csrc/indent_test.mdc +++ b/csrc/indent_test.mdc @@ -4,35 +4,30 @@ 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) - myLDLIBS:= libparser.o libscanner.o libmdcode.o -licuuc - LDLIBS := $(filter-out $(myLDLIBS),$(LDLIBS)) $(myLDLIBS) + itestCFLAGS := -Wall -g -fplan9-extensions + itestLDLIBS:= libparser.o libscanner.o libmdcode.o -licuuc all :: itest - itest.c itest.h : indent_test.mdc parsergen libparser.o libscanner.o libmdcode.o + itest.c itest.h : indent_test.mdc parsergen ./parsergen -o itest --LALR --tag indent indent_test.mdc - indent_test.mk: indent_test.mdc md2c + indent_test.mk itest.code: indent_test.mdc md2c ./md2c indent_test.mdc - itest: itest.c + itest: itest.c | $(filter %.o,$(itestLDLIBS)) + $(CC) $(itestCFLAGS) $^ $(itestLDLIBS) -o $@ doitest: itest itest.code ./itest itest.code checkitest: itest itest.code @grep -v '^#' itest.out > .tmp.out - @./itest itest.code | diff -u - .tmp.out || echo itest FAILED + @./itest itest.code | diff -u .tmp.out - || echo itest FAILED @sed -e 'i\ ' itest.code > itest2.code - @./itest itest2.code| diff -u - .tmp.out || echo itest2 FAILED + @./itest itest2.code| diff -u .tmp.out - || echo itest2 FAILED demos :: doitest tests :: checkitest # indent: header - ./parsergen -o itest --LALR indent_test.cgm - cc -o itest itest.c lib*.o -licuuc -lgmp - ./itest itest.code - struct expression { struct text op; struct expression *left, *right; @@ -115,8 +110,6 @@ with complete bracketing and indenting. char *file = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); struct section *s = code_extract(file, file+len, NULL); struct token_config config = { - .ignored = (1 << TK_line_comment) - | (1 << TK_block_comment), .number_chars = ".,_+-", .word_start = "", .word_cont = "", @@ -135,13 +128,15 @@ with complete bracketing and indenting. ~~~~~~ +$TERM if { } : * + - / ; = + Program -> Statementlist ${ print_statement($1, 0); }$ $*statement Newlines -> NEWLINE | Newlines NEWLINE - Statementlist -> Statements ${ $0 = $<1; }$ - | Newlines Statements ${ $0 = $<2; }$ + Statementlist -> Statements ${ $0 = $ Statements Statement ${ { @@ -160,20 +155,20 @@ $*statement | Newlines { Close -> } | Newlines } - Block -> Open Statementlist Close ${ $0 = $<2; }$ - | Open SimpleStatements } ${ $0 = $<2; }$ - | : SimpleStatements ${ $0 = $<2; }$ - | : StatementBlock ${ $0 = $<2; }$ - StatementBlock -> Statementlist $$OUT ${ $0 = $<1; }$ + Block -> Open Statementlist Close ${ $0 = $ Statementlist $$OUT ${ $0 = $ SimpleStatements ; SimpleStatement ${ { struct statement **s; - $0 = $<1; + $0 = $next; - *s = $<3; + *s = $