From 3356d1fff412b8f89e9a71b60237f1ebca78af11 Mon Sep 17 00:00:00 2001 From: Minero Aoki Date: Tue, 25 Dec 2007 17:46:37 +0000 Subject: [PATCH] * net/loveruby/cflat/parser/Parser.jj: 5-1-1 should be 3, not 5. * test/test.sh: test op association. * test/assoc.cb: new test case. * test/Makefile: build it. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3758 1b9489fe-b721-0410-924e-b54b9192deb8 --- ChangeLog | 10 ++++++++ net/loveruby/cflat/parser/Parser.jj | 39 ++++++++++++++++------------- test/Makefile | 2 +- test/assoc.cb | 8 ++++++ test/test.sh | 2 ++ 5 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 test/assoc.cb diff --git a/ChangeLog b/ChangeLog index 5df5f7a..d712c7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Wed Dec 26 02:46:32 2007 Minero Aoki + + * net/loveruby/cflat/parser/Parser.jj: 5-1-1 should be 3, not 5. + + * test/test.sh: test op association. + + * test/assoc.cb: new test case. + + * test/Makefile: build it. + Tue Dec 25 05:53:19 2007 Minero Aoki * net/loveruby/cflat/parser/Parser.jj (fixedparams, diff --git a/net/loveruby/cflat/parser/Parser.jj b/net/loveruby/cflat/parser/Parser.jj index ea42049..eebf7bd 100644 --- a/net/loveruby/cflat/parser/Parser.jj +++ b/net/loveruby/cflat/parser/Parser.jj @@ -925,7 +925,7 @@ Node expr10(): Node expr9(): { Node l, r; } { - l=expr8() ["||" r=expr9() { return new LogicalOrNode(labelPool, l, r); }] + l=expr8() ("||" r=expr8() { l = new LogicalOrNode(labelPool, l, r); })* { return l; } @@ -934,7 +934,7 @@ Node expr9(): Node expr8(): { Node l, r; } { - l=expr7() ["&&" r=expr8() { return new LogicalAndNode(labelPool, l, r); }] + l=expr7() ("&&" r=expr7() { l = new LogicalAndNode(labelPool, l, r); })* { return l; } @@ -943,12 +943,12 @@ Node expr8(): Node expr7(): { Node l, r; } { - l=expr6() [( ">" r=expr7() { return new GtNode(l, r); } - | "<" r=expr7() { return new LtNode(l, r); } - | ">=" r=expr7() { return new GtEqNode(l, r); } - | "<=" r=expr7() { return new LtEqNode(l, r); } - | "==" r=expr7() { return new EqNode(l, r); } - | "!=" r=expr7() { return new NotEqNode(l, r); } )] + l=expr6() ( ">" r=expr6() { l = new GtNode(l, r); } + | "<" r=expr6() { l = new LtNode(l, r); } + | ">=" r=expr6() { l = new GtEqNode(l, r); } + | "<=" r=expr6() { l = new LtEqNode(l, r); } + | "==" r=expr6() { l = new EqNode(l, r); } + | "!=" r=expr6() { l = new NotEqNode(l, r); } )* { return l; } @@ -957,7 +957,7 @@ Node expr7(): Node expr6(): { Node l, r; } { - l=expr5() ["|" r=expr6() { return new BitwiseOrNode(l, r); }] + l=expr5() ("|" r=expr5() { l = new BitwiseOrNode(l, r); })* { return l; } @@ -966,7 +966,7 @@ Node expr6(): Node expr5(): { Node l, r; } { - l=expr4() ["^" r=expr5() { return new BitwiseXorNode(l, r); }] + l=expr4() ("^" r=expr4() { l = new BitwiseXorNode(l, r); })* { return l; } @@ -975,7 +975,7 @@ Node expr5(): Node expr4(): { Node l, r; } { - l=expr3() ["&" r=expr4() { return new BitwiseAndNode(l, r); }] + l=expr3() ("&" r=expr3() { l = new BitwiseAndNode(l, r); })* { return l; } @@ -984,8 +984,9 @@ Node expr4(): Node expr3(): { Node l, r; } { - l=expr2() [( ">>" r=expr3() { return new RShiftNode(l, r); } - | "<<" r=expr3() { return new LShiftNode(l, r); } )] + l=expr2() ( ">>" r=expr2() { l = new RShiftNode(l, r); } + | "<<" r=expr2() { l = new LShiftNode(l, r); } + )* { return l; } @@ -994,8 +995,9 @@ Node expr3(): Node expr2(): { Node l, r; } { - l=expr1() [( "+" r=expr2() { return new PlusNode(l, r); } - | "-" r=expr2() { return new MinusNode(l, r); } )] + l=expr1() ( "+" r=expr1() { l = new PlusNode(l, r); } + | "-" r=expr1() { l = new MinusNode(l, r); } + )* { return l; } @@ -1004,9 +1006,10 @@ Node expr2(): Node expr1(): { Node l, r; } { - l=term() [( "*" r=expr1() { return new MulNode(l, r); } - | "/" r=expr1() { return new DivNode(l, r); } - | "%" r=expr1() { return new ModNode(l, r); } )] + l=term() ( "*" r=term() { l = new MulNode(l, r); } + | "/" r=term() { l = new DivNode(l, r); } + | "%" r=term() { l = new ModNode(l, r); } + )* { return l; } diff --git a/test/Makefile b/test/Makefile index c95a8d8..35a86ca 100644 --- a/test/Makefile +++ b/test/Makefile @@ -16,7 +16,7 @@ CBPROGS = zero one hello hello2 hello3 hello4 integer string \ pointer ptrmemb funcptr \ charops shortops intops longops \ ucharops ushortops uintops ulongops \ - block cast defvar mbc \ + block cast defvar mbc assoc \ # immscope cast diff --git a/test/assoc.cb b/test/assoc.cb new file mode 100644 index 0000000..2b7dbb8 --- /dev/null +++ b/test/assoc.cb @@ -0,0 +1,8 @@ +import stdio; + +int +main(int argc, char **argv) +{ + printf("%d\n", 5 - 1 - 1); + return 0; +} diff --git a/test/test.sh b/test/test.sh index d08dcd2..193337b 100755 --- a/test/test.sh +++ b/test/test.sh @@ -145,4 +145,6 @@ assert_out "1;2;3" ./defvar assert_error $CBC defun-semcheck.cb assert_error $CBC funcall-semcheck.cb +assert_out "3" ./assoc + test_finished