This is a proposal for a Tiny Imperative Language for setting tiny benchmarks of source transformation systems such as the TIL Chairmarks.

-- EelcoVisser & JamesCordy

Added "primary -> string", to allow for transformations involving addition of meaningful output statements.

-- JamesCordy - 29 Apr 2005

% Grammar for Tiny Imperative Language (TIL)

program -> statement*

statement ->  declaration
           |  assignment_statement
           |  if_statement
           |  while_statement
           |  for_statement
           |  read_statement
           |  write_statement

% Untyped variables
declaration -> "var" identifier ";"

assignment_statement -> identifier ":=" expression ";"

if_statement -> "if" expression "then" 
                    statement* 
                "end"
             |  "if" expression "then" 
                    statement* 
                "else" 
                    statement* 
                "end"

% While loop 
while_statement -> "while" expression "do"
                      statement* 
                   "end"

% Declaring for
for_statement -> "for"  identifier ":=" expression "to" expression do
                     statement*
                 "end"

read_statement -> "read" identifier ";"

write_statement -> "write" expression ";"

% Simple 
expression -> primary
           |  expression op expression

primary -> identifier
        |  integer
        |  string
        |  "(" expression ")"

op -> "=" | "!="        % lowest priority       
   |  "+" | "-"
   |  "*" | "/"         % highest priority

Revision: r1.3 - 17 Aug 2005 - 13:10 - JamesCordy
Sts > StsBench > TinyImperativeLanguage
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback