views:

17

answers:

1

I am adding more to my language using bison and in the rules i am getting a little confused.

How do i name expressions that have {} such as class, functions, switch etc VS expressions that need a semicolon at the end of them (Int i;)

I had them as typeExprWO VS typeExpr but i mixed them up having WO meaning without the need a semicolon (aka has a brace) in some areas and without brace (so it needs semicolons) in other places.

I need a better name. Ideas?

+2  A: 

Normally, that would be a declaration or a statement.

Statements are normally expressions with no meaningful return value or a discarded return value.

A sequence of statements is normally called a block (or block statement), but in the case of declaration (inc method declaration), the name body might be a better choice.

leppie
So body VS statement? `switch{}` is a body and `int a` is a statement. I can see that. Maybe i'll use it +1
acidzombie24
`int a` would be a declaration (and I would assume an optional initializer statement). `switch { ... }` would also be a statement. However the `...` inside the could be the `switch-body` or `case-clauses`.
leppie
Have a look at the C# spec, at the end (in grammar) they have pretty much all the names you can think of :)
leppie
I looked at the specs http://msdn.microsoft.com/en-us/library/aa664812%28v=VS.71%29.aspx it appears they use MANY endings. It appears statements are blocks and do not need semicolons and pretty much everything else (declaration, initializer etc) are expressions/need a semicolon. I'll stick to body and expr to make it simpler. I dont need single rules like `continue-statement: continue ;` yet i have rules half as much which is hard to believe seeing how many single rules they have
acidzombie24