Difference between revisions of "PLC Project"
Line 3: | Line 3: | ||
=== Program's formatting === | === Program's formatting === | ||
− | The program consists of a sequence of commands. Commands are written with free formating. Comments, spaces, tabs and line breaks serve only as delimiters and do not affect the meaning of the program. ''Commnets'' are bounded by two slashes and the end of the line. Keywords are reserved. Identifiers and keywords are case sensitive. | + | The program consists of a sequence of commands. Commands are written with free formating. Comments, spaces, tabs and line breaks serve only as delimiters and do not affect the meaning of the program. '''Commnets''' are bounded by two slashes and the end of the line. Keywords are reserved. Identifiers and keywords are case sensitive. |
=== Variables === | === Variables === | ||
Line 10: | Line 10: | ||
=== Statements === | === Statements === | ||
+ | |||
+ | Following statements are defined: | ||
+ | |||
+ | * Empty command; | ||
+ | * var variable, variable, ...: type; | ||
+ | Declaration of variables of the specified type. The type can be int, float, boolean or String. | ||
+ | expression; | ||
+ | The resulting value of the expression is ignored. A side effect can be, for example, an assignment to a variable. | ||
+ | read variable, variable, ...; | ||
+ | Read values from standard input and assign to variables. Each read value is on a separate input line. | ||
+ | write expression, expression, ...; | ||
+ | Listing the value of expressions to standard output. An end-of-line character is listed after the value of the last expression. | ||
+ | Command block - block starts {and ends} | ||
+ | if (condition) statements else statements | ||
+ | Conditional statement, condition must be a Boolean expression. Commands indicate a sequence of commands separated by a semicolon. The else part is optional. | ||
+ | for (expression_1; condition; expression_2) statements | ||
+ | Cycle statement, condition must be a Boolean expression. The first expression is executed before the start of the cycle, the second after each step of the cycle. | ||
=== Expression === | === Expression === |
Revision as of 12:37, 14 March 2022
Contents
Language Specification
Program's formatting
The program consists of a sequence of commands. Commands are written with free formating. Comments, spaces, tabs and line breaks serve only as delimiters and do not affect the meaning of the program. Commnets are bounded by two slashes and the end of the line. Keywords are reserved. Identifiers and keywords are case sensitive.
Variables
Variable's identifiers are composed from letters and digits and it must start with a letter. Each variable must be declared before it is used. Repeated declaration of a variable with the same name is an error. Variables must have one of the following types: int
, float
, boolean
or String
. After the declaration, variables have initial values: 0
, 0.0
, ""
respectivelly False
.
Statements
Following statements are defined:
- Empty command;
- var variable, variable, ...: type;
Declaration of variables of the specified type. The type can be int, float, boolean or String. expression; The resulting value of the expression is ignored. A side effect can be, for example, an assignment to a variable. read variable, variable, ...; Read values from standard input and assign to variables. Each read value is on a separate input line. write expression, expression, ...; Listing the value of expressions to standard output. An end-of-line character is listed after the value of the last expression. Command block - block starts {and ends} if (condition) statements else statements Conditional statement, condition must be a Boolean expression. Commands indicate a sequence of commands separated by a semicolon. The else part is optional. for (expression_1; condition; expression_2) statements Cycle statement, condition must be a Boolean expression. The first expression is executed before the start of the cycle, the second after each step of the cycle.