Discussion:
Order of statements
(too old to reply)
Jason Luu
2004-07-01 18:07:20 UTC
Permalink
Is it necessary to check for the order of statments, for example:

begin
// declarations
// statements
end

is accepted but

begin
// statements
// declarations
// statements
end

is rejected.

Also, how do we determine the unary '-' from the unary '+' since unary '+'
is not defined in SL and unary '-' is tokenized as an ADDOP

Thank you.
Nguyen Nguyen
2004-07-01 21:24:44 UTC
Permalink
Yes, quoting the SL specification: "All variable declarations must occur
before any non-variable declaration statement: that is, they appear before
any in, out, block etc. statement".

You cannot distinguish between "+" and "-" unary operations in this
assignment because you are not inserting any actions in the .cup
specification and as you know, both "+" and "-" return ADDOP tokens.

Nguyen
Post by Jason Luu
begin
// declarations
// statements
end
is accepted but
begin
// statements
// declarations
// statements
end
is rejected.
Also, how do we determine the unary '-' from the unary '+' since unary '+'
is not defined in SL and unary '-' is tokenized as an ADDOP
Thank you.
Shruti
2004-07-04 19:59:11 UTC
Permalink
I have a questions about the following section of the specification:
"All variable declarations must occur before any non-variable declaration
statement: that is, they appear before any in, out, block etc. statement".

Isn't checking for this semantic analysis? If so, are we required to handle
it in Assignment 4?

Thanks,
Shruti
Post by Nguyen Nguyen
Yes, quoting the SL specification: "All variable declarations must occur
before any non-variable declaration statement: that is, they appear before
any in, out, block etc. statement".
You cannot distinguish between "+" and "-" unary operations in this
assignment because you are not inserting any actions in the .cup
specification and as you know, both "+" and "-" return ADDOP tokens.
Nguyen
Post by Jason Luu
begin
// declarations
// statements
end
is accepted but
begin
// statements
// declarations
// statements
end
is rejected.
Also, how do we determine the unary '-' from the unary '+' since unary '+'
is not defined in SL and unary '-' is tokenized as an ADDOP
Thank you.
Nguyen Nguyen
2004-07-04 22:18:33 UTC
Permalink
Yes, you should handle this in assignment 4.

Nguyen
Post by Shruti
"All variable declarations must occur before any non-variable declaration
statement: that is, they appear before any in, out, block etc. statement".
Isn't checking for this semantic analysis? If so, are we required to handle
it in Assignment 4?
Thanks,
Shruti
Post by Nguyen Nguyen
Yes, quoting the SL specification: "All variable declarations must occur
before any non-variable declaration statement: that is, they appear before
any in, out, block etc. statement".
You cannot distinguish between "+" and "-" unary operations in this
assignment because you are not inserting any actions in the .cup
specification and as you know, both "+" and "-" return ADDOP tokens.
Nguyen
Post by Jason Luu
begin
// declarations
// statements
end
is accepted but
begin
// statements
// declarations
// statements
end
is rejected.
Also, how do we determine the unary '-' from the unary '+' since unary
'+'
Post by Nguyen Nguyen
Post by Jason Luu
is not defined in SL and unary '-' is tokenized as an ADDOP
Thank you.
Loading...