blob: af0fbcc7cc494a789fea9323b031880813463b9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
_M_i_r_a_n_d_a_ _l_e_x_i_c_a_l_ _s_y_n_t_a_x
In this section square brackets are used to enclose a set of literal
characters, using lex-style conventions, so eg [a-z] means a lower case
letter. As usual * and ? are used to mean zero-or-more, and
zero-or-one, occurrences of the preceding entity. Parentheses are used
for grouping, and subtraction of one syntactic entity from another means
set difference. We also revert to using `|' for alternatives, as in
standard BNF.
script:= (token | layout)*
layout:= nl | tab | formfeed | space | comment
comment:= vertical_bar vertical_bar (any - nl)* nl
token:= identifier | IDENTIFIER | literal | typevar | delimiter
identifier:= ([a-z] [a-zA-Z0-9_']* ) - delimiter
IDENTIFIER:= [A-Z] [a-zA-Z0-9_']*
literal:= numeral | charconst | stringconst
literal1:= literal - float
numeral:= nat | float
nat:= [0-9] [0-9]* | 0x [0-9a-f] [0-9a-f]* | 0o [0-7] [0-7]*
float:= [0-9]* [.] nat epart? | nat epart
epart:= [e] [+|-]? nat
charconst:= ['] (visible-[\]|escape) [']
stringconst:= ["] (visible-[\"]|escape)* ["]
escape:= [\] ([ntfrb\'"]|nl|decimal_code)
typevar:= [*][*]*
delimiter:= - | prefix1 | infix1 | other
infix1:= ++ | -- | : | \/ | & | > | >= | = | ~= | <= | < | + | * |
/ | div | mod | ^ | . | ! | $identifier | $IDENTIFIER
infix:= infix1 | -
prefix1:= ~ | #
prefix:= prefix1 | -
other:= abstype | if | otherwise | readvals | show | type | where |
with | %export | %free | %include | %insert | %list | %nolist |
= | == | ::= | :: | => | vertical_bar | // | -> | ; | , | ( |
) | [ | ] | { | } | <- | .. | $$ | $- | $:- | $+ | $*
vertical_bar:= |
_N_o_t_e_s
visible means any non-control character, including space (but not
including eg newline), nl means literal newline, and decimal_code is a
nat in the range 0..255 (maximum length 3 digits).
Notice that the syntax of `numeral' does not include negative numbers.
Negative constants, such as -3 or -5.05e-17 are parsed by Miranda as
applications of the prefix operator `-' to a positive numeral. This has
no semantic significance.
Omission - the definition of `layout' does not include the additional
comment rules for LITERATE SCRIPTS (see separate manual section).
|