86 lines
3.1 KiB
Plaintext
86 lines
3.1 KiB
Plaintext
The Language grammer
|
|
BNF Converter
|
|
|
|
|
|
%This txt2tags file is machine-generated by the 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 grammer==
|
|
|
|
===Literals===
|
|
|
|
|
|
|
|
Name literals are recognized by the regular expression
|
|
`````(["'_"] | letter) (["'-._"] | digit | letter)*`````
|
|
|
|
NumericLiteral literals are recognized by the regular expression
|
|
`````digit+ '.'? digit* | digit* '.'? digit+ ('e' digit+)?`````
|
|
|
|
|
|
===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 grammer are the following:
|
|
|
|
There are no reserved words in grammer.
|
|
|
|
The symbols used in grammer are the following:
|
|
| {# | #} | : | =
|
|
| -> | {{ | }} | {
|
|
| } | [ | ] | (
|
|
| ) | , | |
|
|
|
|
===Comments===
|
|
Single-line comments begin with --.Multiple-line comments are enclosed with {- and -}.
|
|
|
|
==The syntactic structure of grammer==
|
|
Non-terminals are enclosed between < and >.
|
|
The symbols -> (production), **|** (union)
|
|
and **eps** (empty rule) belong to the BNF notation.
|
|
All other symbols are terminals.
|
|
|
|
| //Module// | -> | //[Binding]//
|
|
| //Binding// | -> | //Declaration//
|
|
| | **|** | //Definition//
|
|
| | **|** | ``{#`` //Pragma// ``#}``
|
|
| //Declaration// | -> | //Name// ``:`` //Type//
|
|
| | **|** | //Type//
|
|
| //Definition// | -> | //Name// ``=`` //Expression//
|
|
| | **|** | //Expression//
|
|
| //Type// | -> | //Name//
|
|
| | **|** | //Type// //Type//
|
|
| | **|** | //Type// ``->`` //Type//
|
|
| | **|** | ``{{`` //[Declaration]// ``}}``
|
|
| | **|** | ``{`` //[Declaration]// ``}``
|
|
| | **|** | ``[`` //[Declaration]// ``]``
|
|
| | **|** | ``(`` //Type// ``)``
|
|
| //Pragma// | -> | //[Name]//
|
|
| //[Binding]// | -> | **eps**
|
|
| | **|** | //Binding//
|
|
| | **|** | //Binding// ``,`` //[Binding]//
|
|
| //[Declaration]// | -> | **eps**
|
|
| | **|** | //Declaration//
|
|
| | **|** | //Declaration// ``,`` //[Declaration]//
|
|
| //[Definition]// | -> | **eps**
|
|
| | **|** | //Definition//
|
|
| | **|** | //Definition// ``,`` //[Definition]//
|
|
| //[Type]// | -> | //Type//
|
|
| | **|** | //Type// ``,`` //[Type]//
|
|
| //[Name]// | -> | //Name//
|
|
| | **|** | //Name// //[Name]//
|
|
| //Expression// | -> | //Name//
|
|
| | **|** | //NumericLiteral//
|
|
| | **|** | //Expression// //Expression//
|
|
| | **|** | //Expression// ``->`` //Expression//
|
|
| | **|** | ``{{`` //Module// ``}}``
|
|
| | **|** | ``{`` //Module// ``}``
|
|
| | **|** | ``[`` //Module// ``]``
|
|
| | **|** | ``(`` //Expression// ``)``
|
|
|
|
|