* 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
This commit is contained in:
Minero Aoki 2007-12-25 17:46:37 +00:00
parent 67a9866b59
commit 3356d1fff4
5 changed files with 42 additions and 19 deletions

View File

@ -1,3 +1,13 @@
Wed Dec 26 02:46:32 2007 Minero Aoki <aamine@loveruby.net>
* 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 <aamine@loveruby.net>
* net/loveruby/cflat/parser/Parser.jj (fixedparams,

View File

@ -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;
}

View File

@ -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

8
test/assoc.cb Normal file
View File

@ -0,0 +1,8 @@
import stdio;
int
main(int argc, char **argv)
{
printf("%d\n", 5 - 1 - 1);
return 0;
}

View File

@ -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