summaryrefslogtreecommitdiff
path: root/dhall/src/lexer.rs
diff options
context:
space:
mode:
authorNadrieril2019-03-03 00:08:57 +0100
committerNadrieril2019-03-03 00:26:23 +0100
commitb7ce3e60770be41d8ccf773541c586c75d2a4e38 (patch)
tree19fe6bcc070358f2d46a75f5df72adeaba4b08f8 /dhall/src/lexer.rs
parent54d3f23e68bf6e769d8a96e40a2b0c4426e38507 (diff)
Merge builtins in a single enum
Diffstat (limited to '')
-rw-r--r--dhall/src/lexer.rs52
1 files changed, 22 insertions, 30 deletions
diff --git a/dhall/src/lexer.rs b/dhall/src/lexer.rs
index 5b4dcaa..b5cbe6b 100644
--- a/dhall/src/lexer.rs
+++ b/dhall/src/lexer.rs
@@ -1,10 +1,8 @@
use nom::*;
use crate::core::Const;
-use crate::core::BuiltinType;
-use crate::core::BuiltinType::*;
-use crate::core::BuiltinValue;
-use crate::core::BuiltinValue::*;
+use crate::core::Builtin;
+use crate::core::Builtin::*;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Keyword {
@@ -22,12 +20,6 @@ pub enum ListLike {
}
#[derive(Debug, Clone, PartialEq, Eq)]
-pub enum Builtin {
- Type(BuiltinType),
- Value(BuiltinValue),
-}
-
-#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Tok<'i> {
Identifier(&'i str),
Keyword(Keyword),
@@ -209,25 +201,25 @@ named!(list_like<&str, ListLike>, alt!(
));
named!(builtin<&str, Builtin>, alt!(
- value!(Builtin::Value(NaturalFold), ident_tag!("Natural/fold")) |
- value!(Builtin::Value(NaturalBuild), ident_tag!("Natural/build")) |
- value!(Builtin::Value(NaturalIsZero), ident_tag!("Natural/isZero")) |
- value!(Builtin::Value(NaturalEven), ident_tag!("Natural/even")) |
- value!(Builtin::Value(NaturalOdd), ident_tag!("Natural/odd")) |
- value!(Builtin::Value(NaturalShow), ident_tag!("Natural/show")) |
- value!(Builtin::Type(Natural), ident_tag!("Natural")) |
- value!(Builtin::Type(Integer), ident_tag!("Integer")) |
- value!(Builtin::Type(Double), ident_tag!("Double")) |
- value!(Builtin::Type(Text), ident_tag!("Text")) |
- value!(Builtin::Value(ListBuild), ident_tag!("List/build")) |
- value!(Builtin::Value(ListFold), ident_tag!("List/fold")) |
- value!(Builtin::Value(ListLength), ident_tag!("List/length")) |
- value!(Builtin::Value(ListHead), ident_tag!("List/head")) |
- value!(Builtin::Value(ListLast), ident_tag!("List/last")) |
- value!(Builtin::Value(ListIndexed), ident_tag!("List/indexed")) |
- value!(Builtin::Value(ListReverse), ident_tag!("List/reverse")) |
- value!(Builtin::Value(OptionalFold), ident_tag!("Optional/fold")) |
- value!(Builtin::Type(Bool), ident_tag!("Bool"))
+ value!(NaturalFold, ident_tag!("Natural/fold")) |
+ value!(NaturalBuild, ident_tag!("Natural/build")) |
+ value!(NaturalIsZero, ident_tag!("Natural/isZero")) |
+ value!(NaturalEven, ident_tag!("Natural/even")) |
+ value!(NaturalOdd, ident_tag!("Natural/odd")) |
+ value!(NaturalShow, ident_tag!("Natural/show")) |
+ value!(Natural, ident_tag!("Natural")) |
+ value!(Integer, ident_tag!("Integer")) |
+ value!(Double, ident_tag!("Double")) |
+ value!(Text, ident_tag!("Text")) |
+ value!(ListBuild, ident_tag!("List/build")) |
+ value!(ListFold, ident_tag!("List/fold")) |
+ value!(ListLength, ident_tag!("List/length")) |
+ value!(ListHead, ident_tag!("List/head")) |
+ value!(ListLast, ident_tag!("List/last")) |
+ value!(ListIndexed, ident_tag!("List/indexed")) |
+ value!(ListReverse, ident_tag!("List/reverse")) |
+ value!(OptionalFold, ident_tag!("Optional/fold")) |
+ value!(Bool, ident_tag!("Bool"))
));
named!(token<&str, Tok>, alt!(
@@ -360,7 +352,7 @@ fn test_lex() {
ParenL,
Identifier("b"),
Ascription,
- Builtin(self::Builtin::Type(crate::core::BuiltinType::Bool)),
+ Builtin(crate::core::Builtin::Bool),
ParenR,
Arrow,
Identifier("b"),