Mini-Triangle is used throughout the textbook Programming Language Processors in Java by Watt and Brown. This handout provides you with the basic definition of Mini-Triangle. For more information you should consult the textbook.
The concrete syntax of a language defines how it appears on the page or screen. The concrete syntax consists of a collection of terminals, non-terminals and production rules.
begin, const, do, else, end, if, in, let, while, then, var, ;, :, :=, -, (, ), +, ~, *, -, /, <, >, =, \
Program (start symbol), Command, Expression, V-name, Declaration, Type-denoter, Operator, Integer-Literal, single-Command, primary-Expression, single-Declaration, Identifier
Program ::=
single-Command
Command ::= single-Command
| Command; single-Command
single-Command ::= V-name :=
Expression
| Identifier(Expression)
| if
Expression then single-Command else single-Command
| while
Expression do single-Command
| let Declaration in
single-Command
| begin Command
end
Expression ::= primary-Expression
| Expression Operator
primary-Expression
Primary-Expression ::=
Integer-Literal
| V-name
| Operator
primary-Expression
| (Expression)
V-name ::= Identifier
Declaration ::= single-Declaration
| Declaration;
single-Declaration
Single-Declaration ::= const Identifier ~
Expression
| var Identifier :
Type-denoter
Type-denoter ::=
Identifier
Operator ::= + | - | * | / | <
| > | = | \
Identifier ::= Leter | Identifier Letter | Identifier
Digit
Integer-Literal ::= Digit |
Integer-Literal Digit
Command ::= ! Graphic*
eol
As before.
Program, Command, Expression, V-name, Declaration, Type-denoter
Program ::=
Command
Command ::= V-name :=
Expression
| Identifier(Expression)
|
Command; Command
| if Expression then Command else
Command
| while Expresion do Command
|
let Declaration in Command
Expression ::=
Integer-Literal
|
V-name
| Operator Expression
|
Expression Operator Expression
V-name ::= Identifier
Declaration ::= const Identifier ~
Expression
| var Identifier :
Type-denoter
| Declaration; Declaration
Type-denoter ::= Identifier
Commands:
Expressions:
Declarations: