106 lines
3.7 KiB
Plaintext
106 lines
3.7 KiB
Plaintext
The Language Alisaie
|
|
BNF Converter
|
|
|
|
|
|
%Process by txt2tags to generate html or latex
|
|
|
|
|
|
|
|
This document was automatically generated by the //BNF-Converter//. It was generated together with the lexer, the parser, and the abstract syntax module, which guarantees that the document matches with the implementation of the language (provided no hand-hacking has taken place).
|
|
|
|
==The lexical structure of Alisaie==
|
|
===Identifiers===
|
|
Identifiers //Ident// are unquoted strings beginning with a letter,
|
|
followed by any combination of letters, digits, and the characters ``_ '``
|
|
reserved words excluded.
|
|
|
|
|
|
===Literals===
|
|
Character literals //Char// have the form
|
|
``'``//c//``'``, where //c// is any single character.
|
|
|
|
|
|
Double-precision float literals //Double// have the structure
|
|
indicated by the regular expression ``digit+ '.' digit+ ('e' ('-')? digit+)?`` i.e.\
|
|
two sequences of digits separated by a decimal point, optionally
|
|
followed by an unsigned or negative exponent.
|
|
|
|
|
|
Integer literals //Integer// are nonempty sequences of digits.
|
|
|
|
|
|
String literals //String// have the form
|
|
``"``//x//``"``}, where //x// is any sequence of any characters
|
|
except ``"`` unless preceded by ``\``.
|
|
|
|
|
|
|
|
|
|
UIdent literals are recognized by the regular expression
|
|
`````upper ('_' | digit | letter)*`````
|
|
|
|
|
|
===Reserved words and symbols===
|
|
The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions.
|
|
|
|
The reserved words used in Alisaie are the following:
|
|
| ``Char`` | ``Double`` | ``Int`` | ``String``
|
|
| ``else`` | ``if`` | ``then`` | ``Λ``
|
|
| ``λ`` | | |
|
|
|
|
The symbols used in Alisaie are the following:
|
|
| : | = | * | →
|
|
| ∀ | . | ( | )
|
|
| + | - | < |
|
|
|
|
===Comments===
|
|
Single-line comments begin with --.Multiple-line comments are enclosed with {- and -}.
|
|
|
|
==The syntactic structure of Alisaie==
|
|
Non-terminals are enclosed between < and >.
|
|
The symbols -> (production), **|** (union)
|
|
and **eps** (empty rule) belong to the BNF notation.
|
|
All other symbols are terminals.
|
|
|
|
| //Program// | -> | //[Definition]//
|
|
| //Definition// | -> | //Ident// ``:`` //Type// //Ident// //[Ident]// ``=`` //Exp//
|
|
| //Kind// | -> | ``*``
|
|
| //Kind1// | -> | //Kind// ``→`` //Kind//
|
|
| | **|** | //Kind//
|
|
| //Type1// | -> | ``String``
|
|
| | **|** | ``Int``
|
|
| | **|** | ``Double``
|
|
| | **|** | ``Char``
|
|
| | **|** | //UIdent//
|
|
| | **|** | ``(`` //Type// ``)``
|
|
| //Type// | -> | //Type1// ``→`` //Type//
|
|
| | **|** | ``∀`` //Ident// ``:`` //Kind// ``.`` //Type//
|
|
| | **|** | ``λ`` //Ident// ``:`` //Kind// ``.`` //Type//
|
|
| | **|** | //Type1//
|
|
| //[Definition]// | -> | **eps**
|
|
| | **|** | //Definition// //[Definition]//
|
|
| //[Ident]// | -> | **eps**
|
|
| | **|** | //Ident// //[Ident]//
|
|
| //Exp4// | -> | //Ident//
|
|
| | **|** | //Integer//
|
|
| | **|** | //Double//
|
|
| | **|** | //Char//
|
|
| | **|** | //String//
|
|
| | **|** | ``(`` //Exp// ``)``
|
|
| //Exp2// | -> | //Exp2// //Exp3//
|
|
| | **|** | //Exp2// //Type//
|
|
| | **|** | //Exp3//
|
|
| //Exp1// | -> | //Exp1// ``+`` //Exp2//
|
|
| | **|** | //Exp1// ``-`` //Exp2//
|
|
| | **|** | //Exp1// ``<`` //Exp2//
|
|
| | **|** | //Exp2//
|
|
| //Exp// | -> | ``if`` //Exp// ``then`` //Exp// ``else`` //Exp//
|
|
| | **|** | ``Λ`` //Ident// ``:`` //Kind// ``.`` //Exp//
|
|
| | **|** | ``λ`` //Ident// ``:`` //Type// ``.`` //Exp//
|
|
| | **|** | //Exp1//
|
|
| //Exp3// | -> | //Exp4//
|
|
|
|
|
|
|
|
%% File generated by the BNF Converter (bnfc 2.9.6.1).
|