-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescription.txt
26 lines (25 loc) · 2.05 KB
/
description.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
A program is a sequence of variable and function definitions.
The syntax of a variable definition is a type followed by a non-empty enumeration of comma-separated identifiers. Variable definitions must end with the ";" character.
Functions are defined specifying the return type, the function identifier and a list of coma-separated parameters between ( and ). The return type and parameter types must be built-in (i.e., no arrays or records). The function body goes between { and }.
The bodies of functions are sequences of variable definitions followed by sequences of statements. Both must end with the ";" character.
The last and mandatory function is "main", which returns void and receives no parameters.
Built-in types are "int", "double" and "char". Array types can be created with the "[]" type constructor, following the Java syntax but specifying the size of the array with an integer constant (like C). The "struct" type constructor is added for specifying record types. Records have no type identifier, and fields are declared as var definitions between { and }. Type definition (i.e., typedef) is not supported.
The syntax of a write statement is the "write" keyword followed by a non-empty comma-separated list of expressions. The read statement is similar, but using the "read" keyword.
Assignments are built with two expressions separated by the "=" operator.
If / else and while statements follow the C syntax. The return <expression> statement is also supported (the expression is mandatory).
A function invocation may be an expression or a statement. A procedure invocation is always a statement.
The cast expression follows the C syntax.
Expressions are built with:
- Integer, real and character constants without sign.
- Identifiers.
- The following operators applied to one or two expressions (descending order of precedence):
( ) Non associative
[] Non associative
. Non associative
Cast Non associative
- (unary) Non associative
! Non associative
* / % Left associative
+ - Left associative
> >= < <= != == Left associative
&& || Left associative