-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathalgo.stflow
More file actions
84 lines (78 loc) · 1.92 KB
/
algo.stflow
File metadata and controls
84 lines (78 loc) · 1.92 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
FLOW: toNumber
input: x, options
IF not string
END x
ELSE_IF should skip
END x
ELSE_IF 0
END 0
ELSE_IF hex is supported AND x is hex
END int of x of base 16
ELSE_IF possible e notation
FOLLOW: resolve enotation (x, trimmed x, options)
ELSE
IF match numeric pattern
separate sign, leading zeros, pure number
IF x doesn't starts with "[+-]0."
END number(x)
IF leading zeros are not allowed
IF leading zeros > 1
#00.1
END x
ELSE_IF leading zeros == 1 AND decimal is not adjacent to leading zeros
#06.5
#but not 0.65, .65, 6.0
END x
ELSE_IF str has only zeros
END 0
ELSE
parse x to number
IF parsed x == 0 or -0
END parsed x
ELSE_IF parsed x is eNotation
IF conversion to enotation is allowed
END parsed x
ELSE
END x
ELSE_IF floating number
IF parsed x is 0
END parsed x
ELSE_IF parsed x == number without leading 0s
#0.456. 0.79000
END parsed x
ELSE_IF parsed x is negative AND == parsed x == number without leading 0s
END parsed x
ELSE
END x
ELSE_IF leading 0s are present
IF parsed x == x without leading 0s
END parsed x
ELSE
END x
ELSE
IF parsed x == x (consider sign)
END parsed x
ELSE
END x
ELSE
END x
FLOW: resolve enotation
input: x, trimmed x, options
IF eNotation has not to be evaluated
END x
IF match eNotation pattern
extract sign, eChar, leading zeros
find if eChar adjacent to leading zeros
IF leading zeros > 1 AND eChar adjacent to leading zeros
# 00e, -00e
END x
ELSE_IF exp is `0e`, `0.e`, `-0.e`, `-0e`
END number(x);
ELSE_IF leading zeros are allowed but eChar is not adjacent to leading zeros
# -003e2
remove leading zeros
END number(x)
ELSE
END x
ELSE
END x