blob: 8adfa3c5caa193a6311794504a99a6b9bedd931f (
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
|
/*
guppy is a pattern-matching language by Joey Adams that's not implemented or formalized yet.
See http://www.funsitelots.com/pub/guppy.g for a near self-definition
This is a guppy representation of integer and floating point formatting in C.
It is based on http://c0x.coding-guidelines.com/6.4.4.1.html and http://c0x.coding-guidelines.com/6.4.4.2.html
*/
number_constant: [
integer_constant()
floating_constant()
]
integer_constant: [
([1-9] [0-9]*) //decimal
(0 [0-7]*) //octal
(0 [X x] [0-9 A-F a-f]*) //hexadecimal
]
integer_suffix: [
([U u] [L l]*0..2)
([L l]*1..2 [U u]*0..1)
]
floating_constant: [
decimal_floating_constant()
hexadecimal_floating_constant()
]
decimal_floating_constant: [
([0-9]* '.' [0-9]+ exponent_part()*0..1 floating_suffix())
([0-9]+ '.' exponent_part()*0..1 floating_suffix())
([0-9]+ exponent_part() floating_suffix())
]
exponent_part:
([E e] ['+' '-']*0..1 [0-9]+)
hexadecimal_floating_constant:
(0 [X x] [
[0-9 A-F a-f]* '.' [0-9 A-F a-f]+
[0-9 A-F a-f]+ '.'
[0-9 A-F a-f]+
] [P p] ['+' '-']*0..1 [0-9]+ floating_suffix())
floating_suffix: [F L f l]*0..1
scan_number:
(
[
(0 [X x] [0-9 A-F a-f '.']*)
(0 [B b] [0-1] [0-9 '.']*)
([0-9 '.']*)
]
( [E P e p] ['+' '-']*0..1 [0-9]* )*0..1
[0-9 A-Z a-z '.' '_' '$']*
)
/*
Notes:
A numeric constant can begin with any of:
0-9 '.'
and can contain any of:
0-9 a-f e f l p u x '.' '+' '-'
along with capital equivalents.
If scanning finds something starting with a '.' but no decimal digit after it, it is the '.' operator and not a number.
*/
|