diff --git a/src/Bergamot/ObjectLanguage.elm b/src/Bergamot/ObjectLanguage.elm index e17b060..624a508 100644 --- a/src/Bergamot/ObjectLanguage.elm +++ b/src/Bergamot/ObjectLanguage.elm @@ -1,6 +1,7 @@ module Bergamot.ObjectLanguage exposing (..) import Bergamot.Syntax as Syntax exposing (Metavariable) +import Bergamot.Parser exposing (strLit) import Parser exposing (Parser, Trailing(..), (|.), (|=)) import Set @@ -13,6 +14,7 @@ type Type type Expr = IntLit Int + | FloatLit Float | StrLit String | Plus Expr Expr | Pair Expr Expr @@ -99,7 +101,15 @@ exprApps = exprBasic : Parser Expr exprBasic = Parser.lazy <| \() -> Parser.oneOf - [ Parser.backtrackable (Parser.succeed IntLit |= Parser.int) + [ Parser.backtrackable <| + Parser.number + { int = Just IntLit + , hex = Nothing + , octal = Nothing + , binary = Nothing + , float = Just FloatLit + } + , Parser.backtrackable (Parser.succeed StrLit |= strLit) , Parser.backtrackable <| Parser.map (\(a, b) -> Pair a b) <| pair expr , Parser.succeed Fst |. Parser.keyword "fst" @@ -137,6 +147,7 @@ exprToTerm : Expr -> Syntax.Term Metavariable exprToTerm e = case e of IntLit i -> Syntax.Call "intlit" [Syntax.IntLit i] + FloatLit f -> Syntax.Call "floatlit" [Syntax.FloatLit f] StrLit s -> Syntax.Call "strlit" [Syntax.StringLit s] Plus e1 e2 -> Syntax.Call "plus" [exprToTerm e1, exprToTerm e2] Pair e1 e2 -> Syntax.Call "pair" [exprToTerm e1, exprToTerm e2]