-
Notifications
You must be signed in to change notification settings - Fork 0
/
free-pascal.ebnf
53 lines (44 loc) · 2.62 KB
/
free-pascal.ebnf
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
(*
Pascal EBNF, written from http://downloads.freepascal.org/fpc/docs-pdf/ref.pdf
EBNF syntax from ?
Other attempt: https://github.com/rochus-keller/FreePascal/blob/master/syntax/FreePascal.ebnf
*)
letter = ? lowercase and uppercase letters ? ;
digit = '0' | '1' | '2' '3' | '4' |'5' | '6' | '7' | '8' | '9' ;
hex_digit = digit | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' ;
octal_digit = '0' | '1' | '2' '3' | '4' |'5' | '6' | '7' ;
binary_digit = '0' | '1' ;
(*
' + - * / = < > [ ] . , ( ) : ^ @ { } $ # & %
<< >> ** <> >< <= >= := += -= *= /= (* \*) (. .) //
*)
identifier = letter | '_' , [ letter | digit | '_' ]* ;
hex_digit_sequence = hex_digit , [ hex_digit ]* ;
octal_digit_sequence = octal_digit , [ octal_digit ]* ;
binary_digit_sequence = hex_digit , [ hex_digit ]* ;
digit_sequence = binary_digit , [ binary_digit ]* ;
unsigned_integer = digit_sequence | '$' hex_digit_sequence | '&' octal_digit_sequence | '%' binary_digit_sequence ;
sign = '+' | '-' ;
scale_factor = 'E' | 'e' , [ sign ] , digit_sequence ;
unsigned_real = digit_sequence [ '.' digit_sequence ] [ scale_factor ] ;
unsigned_number = unsigned_real | unsigned_integer ;
signed_number = sign unsigned_number ;
label = 'LABEL' , digit_sequence | identifier ;
character_string = quoted_string | control_string ;
quoted_string = "'" , [ string_character ]* , "'" ;
string_character = "''" | ? Any character except ' or CR ? ;
control_string = '#' , unsigned_integer ;
constant_declaration = identifier = expression hintdirectives ;
(* IGNORED typed_constant_declaration = .. *)
type_declaration = identifier = type hint_directives ;
type = simple_type | string_type | structured_type | pointer_type |
procedural_type | generic_type | specialized_type | type_alias ;
simple_type = ordinal_type | real_type ;
real_type = real_type_identifier ;
ordinal_type = 'INTEGER' | 'SHORTINT' | 'SMALLINT' | 'LONGINT' | 'LONGWORD' | 'INT64' |
'BYTE' | 'WORD' | 'CARDINAL' | 'QWORD' | 'BYTEBOOL' | 'WORDBOOL' | 'LONGBOOL' | 'QWORDBOOL' ;
boolean_type = 'BOOLEAN' | 'BOOLEAN16' | 'BOOLEAN32' | 'BOOLEAN64' ;
enumerated_type = '(' identifier_list ')' ;
identifier_list = [ identifier ][ , identifier , ]* ;
(* IGNORED assigned_enum_list *)
```