Introduction to Mini-Triangle 
 

(This is a copy of a page copied from google cash as the original is no longer awailable on the web. The original author, whoever it is,  is recognised as the owner of this document)

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.

    1. Concrete Syntax

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.

      1. Terminal Symbols

begin, const, do, else, end, if, in, let, while, then, var, ;, :, :=, -, (, ), +, ~, *, -, /, <, >, =, \

      1. Nonterminal Symbols

Program (start symbol), Command, Expression, V-name, Declaration, Type-denoter, Operator, Integer-Literal, single-Command, primary-Expression, single-Declaration, Identifier

      1. Production Rules

Primary-Expression ::=  Integer-Literal 
| V-name 
| Operator primary-Expression 
| (Expression)
 

Declaration ::= single-Declaration 
| Declaration; single-Declaration
 

Single-Declaration ::= const Identifier ~ Expression 
 | var Identifier : Type-denoter
 

    1. Abstract Syntax
      1. Terminal Symbols

As before.

      1. Nonterminal Symbols

Program, Command, Expression, V-name, Declaration, Type-denoter

      1. Production Rules

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

    1. Semantics

Commands: 

 

Expressions:

 

Declarations: