mirror of
https://github.com/valitydev/yamerl.git
synced 2024-11-06 02:45:23 +00:00
Fix float handling: we must use #yaml_float, not #yaml_int
This commit is contained in:
parent
f9d60f0679
commit
1299ee23f8
@ -52,6 +52,16 @@
|
||||
-type yaml_int() :: #yaml_int{}.
|
||||
-type yaml_simple_int() :: integer().
|
||||
|
||||
%% Float (Core Schema).
|
||||
-record(yaml_float, {
|
||||
module = undefined :: atom(),
|
||||
tag = "!" :: tag_uri(),
|
||||
pres = [] :: list(),
|
||||
value = 0.0 :: float() | '+inf' | '-inf' | 'nan'
|
||||
}).
|
||||
-type yaml_float() :: #yaml_float{}.
|
||||
-type yaml_simple_float() :: float().
|
||||
|
||||
%% Erlang atom.
|
||||
-record(yaml_erlang_atom, {
|
||||
module = undefined :: atom(),
|
||||
@ -146,6 +156,7 @@
|
||||
| yaml_null()
|
||||
| yaml_bool()
|
||||
| yaml_int()
|
||||
| yaml_float()
|
||||
| yaml_timestamp()
|
||||
| yaml_erlang_atom()
|
||||
| yaml_erlang_fun()
|
||||
@ -157,6 +168,7 @@
|
||||
| yaml_simple_null()
|
||||
| yaml_simple_bool()
|
||||
| yaml_simple_int()
|
||||
| yaml_simple_float()
|
||||
| yaml_simple_timestamp()
|
||||
| yaml_simple_erlang_atom()
|
||||
| yaml_simple_erlang_fun()
|
||||
@ -168,6 +180,7 @@
|
||||
| yaml_null()
|
||||
| yaml_bool()
|
||||
| yaml_int()
|
||||
| yaml_float()
|
||||
| yaml_timestamp()
|
||||
| yaml_erlang_atom()
|
||||
| yaml_erlang_fun()
|
||||
@ -176,6 +189,7 @@
|
||||
| yaml_simple_null()
|
||||
| yaml_simple_bool()
|
||||
| yaml_simple_int()
|
||||
| yaml_simple_float()
|
||||
| yaml_simple_timestamp()
|
||||
| yaml_simple_erlang_atom()
|
||||
| yaml_simple_erlang_fun()
|
||||
|
@ -49,7 +49,7 @@ construct_token(#yaml_constr{simple_structs = false},
|
||||
exception(Token);
|
||||
Int ->
|
||||
Pres = yaml_constr:get_pres_details(Token),
|
||||
Node = #yaml_int{
|
||||
Node = #yaml_float{
|
||||
module = ?MODULE,
|
||||
tag = ?TAG,
|
||||
pres = Pres,
|
||||
|
@ -48,7 +48,7 @@ construct_token(#yaml_constr{simple_structs = false},
|
||||
exception(Token);
|
||||
Int ->
|
||||
Pres = yaml_constr:get_pres_details(Token),
|
||||
Node = #yaml_int{
|
||||
Node = #yaml_float{
|
||||
module = ?MODULE,
|
||||
tag = ?TAG,
|
||||
pres = Pres,
|
||||
|
@ -48,7 +48,7 @@ construct_token(#yaml_constr{simple_structs = false},
|
||||
exception(Token);
|
||||
Int ->
|
||||
Pres = yaml_constr:get_pres_details(Token),
|
||||
Node = #yaml_int{
|
||||
Node = #yaml_float{
|
||||
module = ?MODULE,
|
||||
tag = ?TAG,
|
||||
pres = Pres,
|
||||
|
@ -137,7 +137,9 @@ base60_to_integer([$: | Rest], Current, Int) ->
|
||||
Int1 = (Int * 60) + Current,
|
||||
base60_to_integer(Rest, 0, Int1);
|
||||
base60_to_integer([], Current, Int) ->
|
||||
(Int * 60) + Current.
|
||||
(Int * 60) + Current;
|
||||
base60_to_integer(_, _, _) ->
|
||||
error.
|
||||
|
||||
exception(Token) ->
|
||||
Error = #yaml_parsing_error{
|
||||
|
@ -153,7 +153,9 @@ base60_to_integer([$: | Rest], Current, Int) ->
|
||||
base60_to_integer([$_ | Rest], Current, Int) ->
|
||||
base60_to_integer(Rest, Current, Int);
|
||||
base60_to_integer([], Current, Int) ->
|
||||
(Int * 60) + Current.
|
||||
(Int * 60) + Current;
|
||||
base60_to_integer(_, _, _) ->
|
||||
error.
|
||||
|
||||
exception(Token) ->
|
||||
Error = #yaml_parsing_error{
|
||||
|
@ -155,71 +155,71 @@
|
||||
[{yaml_doc,
|
||||
{yaml_seq,yaml_node_seq,"tag:yaml.org,2002:seq",
|
||||
[{line,1},{column,1}],
|
||||
[{yaml_int,yaml_node_float_json,
|
||||
[{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,1},{column,4}],
|
||||
0.0},
|
||||
{yaml_str,yaml_node_str,"tag:yaml.org,2002:str",
|
||||
[{line,2},{column,3}],
|
||||
"+0"},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,3},{column,3}],
|
||||
0.0},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,5},{column,4}],
|
||||
12.34},
|
||||
{yaml_str,yaml_node_str,"tag:yaml.org,2002:str",
|
||||
[{line,6},{column,3}],
|
||||
"+12.34"},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,7},{column,3}],
|
||||
-12.34},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,9},{column,4}],
|
||||
1.2e11},
|
||||
{yaml_str,yaml_node_str,"tag:yaml.org,2002:str",
|
||||
[{line,10},{column,3}],
|
||||
"+12e10"},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,11},{column,3}],
|
||||
-1.2e11},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,13},{column,3}],
|
||||
1.2e11},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,14},{column,3}],
|
||||
1.2e11},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,15},{column,3}],
|
||||
1.2e-11},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,17},{column,3}],
|
||||
1.0e10},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,18},{column,3}],
|
||||
1.0e10},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,20},{column,4}],
|
||||
'+inf'},
|
||||
{yaml_str,yaml_node_str,"tag:yaml.org,2002:str",
|
||||
[{line,21},{column,3}],
|
||||
"+.inf"},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,22},{column,3}],
|
||||
'-inf'},
|
||||
{yaml_int,yaml_node_float_json,
|
||||
{yaml_float,yaml_node_float_json,
|
||||
"tag:yaml.org,2002:float",
|
||||
[{line,23},{column,4}],
|
||||
nan},
|
||||
@ -262,73 +262,73 @@
|
||||
[{yaml_doc,
|
||||
{yaml_seq,yaml_node_seq,"tag:yaml.org,2002:seq",
|
||||
[{line,1},{column,1}],
|
||||
[{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,1},{column,4}],
|
||||
0.0},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,2},{column,3}],
|
||||
0.0},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,3},{column,3}],
|
||||
0.0},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,5},{column,4}],
|
||||
12.34},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,6},{column,3}],
|
||||
12.34},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,7},{column,3}],
|
||||
-12.34},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,9},{column,4}],
|
||||
1.2e11},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,10},{column,3}],
|
||||
1.2e11},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,11},{column,3}],
|
||||
-1.2e11},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,13},{column,3}],
|
||||
1.2e11},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,14},{column,3}],
|
||||
1.2e11},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,15},{column,3}],
|
||||
1.2e-11},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,17},{column,3}],
|
||||
1.0e10},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,18},{column,3}],
|
||||
1.0e10},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,20},{column,4}],
|
||||
'+inf'},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,21},{column,3}],
|
||||
'+inf'},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,22},{column,3}],
|
||||
'-inf'},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,23},{column,4}],
|
||||
nan},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,25},{column,3}],
|
||||
'+inf'},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,26},{column,3}],
|
||||
'+inf'},
|
||||
{yaml_str,yaml_node_str,"tag:yaml.org,2002:str",
|
||||
[{line,27},{column,3}],
|
||||
".iNF"},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,29},{column,3}],
|
||||
nan},
|
||||
{yaml_int,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
{yaml_float,yaml_node_float,"tag:yaml.org,2002:float",
|
||||
[{line,30},{column,3}],
|
||||
nan},
|
||||
{yaml_str,yaml_node_str,"tag:yaml.org,2002:str",
|
||||
|
Loading…
Reference in New Issue
Block a user