Download The Grace Programming Language Draft Specification Version 0.5
Transcript
Revision 2110 committed on 17-06-2015 at 16:56 by black
3
3
Syntax
Much of the following text assumes the reader has a minimal
grasp of computer terminology and a “feeling” for the structure of
a program.
Kathleen Jensen and Niklaus Wirth, Pascal: User Manual and Report.
Grace programs are written in Unicode. Reserved words are written in the
ASCII subset of Unicode. As a matter of policy, the names of methods
defined in the required libraries are also restricted to the ASCII subset of
Unicode and the character π.
3.1
Layout
Grace uses curly brackets for grouping, and semicolons as statement terminators, and infers semicolons at the end of lines. Code layout cannot be
inconsistent with grouping.
code with punctuation:
while {stream.hasNext} do {
print(stream.read);
};
code without punctuation:
while {stream.hasNext} do {
print(stream.read)
}
A line break followed by an increase in the indent level implies a line
continuation, whereas line break followed by the next line at the same or
lesser indentation implies a semicolon if one is permitted syntactically.
3.2
Comments
Grace’s comments start with a pair of slashes // and are terminated by the
end of the line, as in C++ and Java. Comments are not treated as whitespace. 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.
// comment, to end of line