A - Syntax
Published online by Cambridge University Press: 02 November 2009
Summary
General
In this appendix a concrete syntax for COLD-K is defined. It is concerned with the full language, including the constructs presented in Chapter 10 and 11. The notions of term, expression and statement are integrated into a single syntactical category called <expression>. We give an (extended) BNF grammar defining a set of strings of ASCII characters which are used as concrete representations of the COLD-K constructs.
For user convenience, it is allowed to omit redundant type information. In the applied occurrence of a name the associated type information is generally omitted (otherwise the use of names would become very clumsy). Though in many situations the missing type information can be reconstructed from the context, there are situations where ambiguities may occur. We leave it to the parser to report such ambiguities; there is a special syntactic operator (the cast) to disambiguate the type of an expression.
In the concrete syntax defined here prefix, infix and postfix notations are used for the built-in operators of the language. For the user-defined operators (predicates, functions, procedures) only a prefix notation is provided. The main reason for not introducing infix, postfix or mixfix notations for the latter is simplicity. The possibility to define special notations for user-defined operators is typical for user-oriented versions of COLD, which can be defined as a kind of macro-extension of COLD-K.
Concrete syntax
We define the concrete syntax of COLD-K by means of a context free grammar and priority and associativity rules for the built-in operators. Below we shall define the lexical elements (tokens).
- Type
- Chapter
- Information
- Formal Specification and Design , pp. 309 - 316Publisher: Cambridge University PressPrint publication year: 1992