[Grace-core] Comments
Michael Homer
mwh at ecs.vuw.ac.nz
Wed Jan 28 15:38:30 PST 2015
The specification says:
Comments are _not_ treated as white-
space. Each comment is conceptually attached to the smallest immediately
preceding syntactic unit, except that comments following a blank line are
attached to the largest immediately following syntactic unit.
Which is the attachment syntactic unit for each of the following comments?
// comment
1 + 2 // comment
1 + // comment
2
x.y(1 // comment
, 2)
x.y(1, // comment
2)
x.y(1, // comment
// comment2
2)
x.y(1 // comment
, // comment2
2)
x.y(1
// comment
, 2)
x.y // comment
( // comment2
1
) // comment3
-x // comment
- // comment
x // comment2
1 + x.y // comment
1 + x.y {} // comment
method x(a // comment
: String) {}
method x(a : // comment
String) {}
method x(a : String // comment
) {}
method x(a : String) // comment
{}
method x(a) -> // comment
String {}
method x(a) -> String // comment
{}
method x(a) // comment
-> // comment2
String // comment3
{} // comment4
method // comment
x // comment2
(a) // comment3
{}
x.y // comment
(1) z(2)
x.y(1) // comment
z(2)
x.y "" // comment
x.y "" // comment
z(2)
x.y // comment
"" // comment2
z // comment3
(2) // comment4
x // comment
.y // comment2
x // comment
. // comment2
y // comment3
x.y.z // comment
x.y.z "" // comment
// comment
// comment2
var x := 1 // comment
var x := 1; // comment
var x := // comment
1
var x // comment
:= 1
var // comment
x := 1
var // comment
x // comment2
:= // comment3
1 // comment4
var x : // comment
Number := 1
var x : String | Number // comment
:= 1
if ( // comment
true) then { // comment2
}
if (true) then {
// comment
}
for (1..10) do { i -> // comment
}
for (1..10) do {
i // comment
// comment2
-> // comment3
}
return 1 + 2 // comment
return // comment
1 + 2 // comment2
// comment
Are any of those invalid comment locations? Is the attachment unit for
any of them outside the passage?
-Michael
More information about the Grace-core
mailing list