www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Invariant grammar

reply Ary Manzana <asterite gmail.com> writes:
Hello.

In page http://www.digitalmars.com/d/class.html#invariants it says that 
the grammar of invariants is:

ClassInvariant:
	invariant FunctionBody

And in http://www.digitalmars.com/d/function.html is the FunctionBody 
specification:

FunctionBody:
	BlockStatement
	BodyStatement
	InStatement BodyStatement
	OutStatement BodyStatement
	InStatement OutStatement BodyStatement
	OutStatement InStatement BodyStatement

This means that possibly one could write such statements:

invariant body { }
invariant in { } body { }
invariant out(result) { }

However none of this compile under DMD 0.166 (inserting them in a class 
definition, of course).

Are the specs wrong, or instead of FunctionBody it should be a 
BlockStatement? I think it should be a BlockStatement.

I've found some other "errors" in the grammar, but I don't know if they 
are important (I think for people who want to implement a compiler or 
build an AST this stuff is important). Should I send them too?

Ary
Sep 05 2006
parent Walter Bright <newshound digitalmars.com> writes:
Ary Manzana wrote:
 Are the specs wrong, or instead of FunctionBody it should be a 
 BlockStatement? I think it should be a BlockStatement.
 
 I've found some other "errors" in the grammar, but I don't know if they 
 are important (I think for people who want to implement a compiler or 
 build an AST this stuff is important). Should I send them too?

I think the specs are in error, I'll fix them. If you find other such errors, please post them. I agree it is important to fix them.
Sep 05 2006