Skip to content

Commit 1b800df

Browse files
authored
Numeric separators (#109)
fixes #82
1 parent 05f91e6 commit 1b800df

File tree

9 files changed

+663
-126
lines changed

9 files changed

+663
-126
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ bin/guida.min.js
2222
try/public/app.js
2323

2424
# Assets
25-
assets/some-application/index.html
25+
assets/some-application/index.html
26+
27+
# Examples
28+
examples/index.html

examples/src/Underscores.guida

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module Underscores exposing (main)
2+
3+
import Html exposing (text, table, tr, td, div)
4+
import Html.Attributes exposing (style)
5+
6+
ints : List (String, Int)
7+
ints =
8+
[ ("2_000", 2_000)
9+
, ("42_000_000", 42_000_000)
10+
]
11+
12+
13+
floats : List (String, Float)
14+
floats =
15+
[ ("111_000.602", 111_000.602)
16+
, ("1_000.4_205", 1_000.4_205)
17+
, ("0.000_1", 0.000_1)
18+
, ("0.000_000_1", 0.000_000_1)
19+
]
20+
21+
22+
hexadecimals : List (String, Int)
23+
hexadecimals =
24+
[ ("0x1F_2A", 0x1F_2A)
25+
, ("0xDEADBEEF", 0xDEADBEEF)
26+
, ("0xDE_AD_BE_EF", 0xDE_AD_BE_EF)
27+
]
28+
29+
30+
tableRow : (a -> String) -> (String, a) -> Html.Html msg
31+
tableRow toString (label, value) =
32+
tr []
33+
[ td [style "min-width" "150px", style "padding" "7px"] [ text (label) ]
34+
, td [style "min-width" "150px", style "padding" "7px"] [ text (toString value) ]
35+
]
36+
37+
38+
main =
39+
div
40+
[ style "width" "100%"
41+
, style "width" "100%"
42+
, style "display" "flex"
43+
, style "justify-content" "center"
44+
, style "align-item" "center"
45+
]
46+
[ table
47+
[ style "margin" "150px"
48+
, style "padding" "20px"
49+
]
50+
( List.map (tableRow String.fromInt) ints
51+
++ List.map (tableRow String.fromFloat) floats
52+
++ List.map (tableRow String.fromInt) hexadecimals
53+
)
54+
]
55+
56+

src/Compiler/Parse/Expression.elm

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,33 @@ term syntaxVersion =
3131
(\start ->
3232
P.oneOf E.Start
3333
[ variable start |> P.bind (accessible start)
34-
, string start
35-
, number start
34+
, string syntaxVersion start
35+
, number syntaxVersion start
3636
, Shader.shader start
3737
, list syntaxVersion start
3838
, record syntaxVersion start |> P.bind (accessible start)
3939
, tuple syntaxVersion start |> P.bind (accessible start)
4040
, accessor start
41-
, character start
41+
, character syntaxVersion start
4242
]
4343
)
4444

4545

46-
string : A.Position -> P.Parser E.Expr Src.Expr
47-
string start =
48-
String.string E.Start E.String_
46+
string : SyntaxVersion -> A.Position -> P.Parser E.Expr Src.Expr
47+
string syntaxVersion start =
48+
String.string syntaxVersion E.Start E.String_
4949
|> P.bind (\( str, representation ) -> P.addEnd start (Src.Str str representation))
5050

5151

52-
character : A.Position -> P.Parser E.Expr Src.Expr
53-
character start =
54-
String.character E.Start E.Char
52+
character : SyntaxVersion -> A.Position -> P.Parser E.Expr Src.Expr
53+
character syntaxVersion start =
54+
String.character syntaxVersion E.Start E.Char
5555
|> P.bind (\chr -> P.addEnd start (Src.Chr chr))
5656

5757

58-
number : A.Position -> P.Parser E.Expr Src.Expr
59-
number start =
60-
Number.number E.Start E.Number
58+
number : SyntaxVersion -> A.Position -> P.Parser E.Expr Src.Expr
59+
number syntaxVersion start =
60+
Number.number syntaxVersion E.Start E.Number
6161
|> P.bind
6262
(\nmbr ->
6363
P.addEnd start <|

0 commit comments

Comments
 (0)