summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dhall_core/src/parser.rs14
-rw-r--r--dhall_parser/src/dhall.abnf22
2 files changed, 22 insertions, 14 deletions
diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs
index f888f94..55fb177 100644
--- a/dhall_core/src/parser.rs
+++ b/dhall_core/src/parser.rs
@@ -406,7 +406,7 @@ make_parser! {
token_rule!(minus_infinity_literal<()>);
token_rule!(plus_infinity_literal<()>);
- rule!(double_literal<core::Double>;
+ rule!(numeric_double_literal<core::Double>;
captured_str!(s) => {
let s = s.trim();
match s.parse::<f64>() {
@@ -418,6 +418,13 @@ make_parser! {
}
);
+ rule!(double_literal<core::Double>; children!(
+ [numeric_double_literal(n)] => n,
+ [minus_infinity_literal(n)] => std::f64::NEG_INFINITY.into(),
+ [plus_infinity_literal(n)] => std::f64::INFINITY.into(),
+ [NaN(n)] => std::f64::NAN.into(),
+ ));
+
rule!(natural_literal<core::Natural>;
captured_str!(s) => {
s.trim()
@@ -737,11 +744,6 @@ make_parser! {
rule!(literal_expression<ParsedExpr> as expression; children!(
[double_literal(n)] => Expr::DoubleLit(n),
- [minus_infinity_literal(n)] =>
- Expr::DoubleLit(std::f64::NEG_INFINITY.into()),
- [plus_infinity_literal(n)] =>
- Expr::DoubleLit(std::f64::INFINITY.into()),
- [NaN(n)] => Expr::DoubleLit(std::f64::NAN.into()),
[natural_literal(n)] => Expr::NaturalLit(n),
[integer_literal(n)] => Expr::IntegerLit(n),
[double_quote_literal(s)] => Expr::TextLit(s),
diff --git a/dhall_parser/src/dhall.abnf b/dhall_parser/src/dhall.abnf
index ca54215..15fd898 100644
--- a/dhall_parser/src/dhall.abnf
+++ b/dhall_parser/src/dhall.abnf
@@ -305,7 +305,20 @@ arrow = %x2192 / "->"
exponent = "e" [ "+" / "-" ] 1*DIGIT
-double-literal = [ "+" / "-" ] 1*DIGIT ( "." 1*DIGIT [ exponent ] / exponent)
+numeric-double-literal = [ "+" / "-" ] 1*DIGIT ( "." 1*DIGIT [ exponent ] / exponent)
+
+minus-infinity-literal = "-" Infinity
+plus-infinity-literal = Infinity
+
+double-literal =
+ ; "2.0"
+ numeric-double-literal
+ ; "-Infinity"
+ / minus-infinity-literal
+ ; "Infinity"
+ / plus-infinity-literal
+ ; "NaN"
+ / NaN
natural-literal = 1*DIGIT
@@ -627,13 +640,6 @@ literal-expression =
; "+2"
/ integer-literal
- ; "-Infinity"
- / minus-infinity-literal
- ; "Infinity"
- / plus-infinity-literal
- ; "NaN"
- / NaN
-
; '"ABC"'
/ text-literal