Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: [A1] Parsing Unsupported Features in Joos 1W

63 views
Skip to first unread message

Ondřej Lhoták

unread,
Jan 17, 2014, 2:07:22 PM1/17/14
to
On Wed, Jan 08, 2014 at 04:08:45PM +0000, Jeremy Roman wrote:
> I've been looking over A1 and the corresponding sections of the JLS,
> and I have a few questions about the relationship between Joos 1W
> and Java 1.3 (as described in JLS 2ED).
>
>
> Should keywords that are reserved by Java 1.3 but are not related to
> any feature of Joos 1W be treated as keywords (that happen to be
> always invalid), or should they be treated as identifiers? e.g. is
> it legal in Joos 1W to define a variable called "strictfp"?
> (Permitting this would seem to make Joos 1W not a subset of Java
> 1.3.)

The general rule is that every Joos 1W program should also be a valid
Java 1.3 program. Since Java 1.3 prohibits using keywords for
identifiers, Joos 1W should also prohibits all Java 1.3 keywords
from being used as identifiers. Therefore, it is illegal in Joos 1W
to define a variable called "strictfp", and your compiler should
check for this.

> A1 seems to contradict the JLS on the treatment of integer literals.
> In particular, A1 says that "For integer literals, it must check
> that the literal is within the range of a Java int.". The JLS, on
> the other hand, permits the decimal integer literal "2147483648"
> (but only as the operand of the unary minus operator). That is, the
> line "int x = -2147483648;" is valid Java 1.3; is it also valid Joos
> 1W?

A1 combines scanning and parsing. Your submission for A1 should reject
a program containing:
int x = 2147483648;
but accept a program containing
int x = -2147483648;
Whether you detect this in the scanner or the parser is up to you.

> Regarding Unicode escapes, in Java 1.3 these are a pre-lexing
> feature. As a result, it seems that totally ignoring this feature
> (which is what the table for the Joos language versions suggests)
> makes the following class valid Joos 1W, but invalid Java 1.3 (which
> makes Joos 1W not a strict subset of Java 1.3); is this a correct
> interpretation? e.g.
>
> public class Foo {
> // u000a This is a comment in Joos 1W, but a syntax error in
> Java 1.3.
> }

Did you intend to put a backslash before u000a in the above example? The
intent is that I do not want you to worry about Unicode when working on
your compilers. Therefore, yes, the code that you cite is an example
of a valid Joos 1W program that is not a valid Java 1.3 program, an
exception to the general rule mentioned above.

0 new messages