Skip to content

Commit

Permalink
Merge pull request #405 from smucclaw/20230803-rpnary-map
Browse files Browse the repository at this point in the history
add syntax for MAP operator, but not yet implemented
  • Loading branch information
mengwong authored Aug 3, 2023
2 parents 5a2abf5 + 83ff1eb commit 5c95cfe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/haskell/natural4/src/LS/BasicTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ data MyToken = Every | Party | TokAll
| Then | Else
| TNumber Float
| Other Text.Text
| Do
| Do | FMap
| TokTrue | TokFalse
| Aka -- also known as, for AKA Receiving Party
| Typically -- to provide default values
Expand Down Expand Up @@ -226,6 +226,8 @@ toToken "LIST OF" = pure List1
toToken "LISTOF" = pure List1
toToken "LIST" = pure List1

toToken "MAP" = pure FMap

toToken "AKA" = pure Aka
toToken "TYPICALLY" = pure Typically

Expand Down Expand Up @@ -416,6 +418,8 @@ renderToken Semicolon = ";;"
renderToken SubjectTo = "SUBJECT TO"
renderToken TokSum = "SUM"
renderToken TokProduct = "PRODUCT"
renderToken FMap = "MAP"


renderToken tok = map toUpper (show tok)

Expand Down
1 change: 1 addition & 0 deletions lib/haskell/natural4/src/LS/RelationalPredicates.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ tok2rel = choice
, RPlte <$ pToken TokLTE
, RPgt <$ pToken TokGT -- serves double duty as MaxOflist when in RPnary position
, RPgte <$ pToken TokGTE
, RPmap <$ pToken FMap
, RPelem <$ pToken TokIn
, RPnotElem <$ pToken TokNotIn
, RPsubjectTo <$ pToken SubjectTo
Expand Down
3 changes: 3 additions & 0 deletions lib/haskell/natural4/src/LS/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type BoolStructR = AA.OptionallyLabeledBoolStruct RelationalPredicate

-- | the relations in a RelationalPredicate
data RPRel = RPis | RPhas | RPeq | RPlt | RPlte | RPgt | RPgte | RPelem | RPnotElem | RPnot | RPand | RPor | RPsum | RPproduct | RPsubjectTo
| RPmap
| RPTC TComparison -- ^ temporal constraint as part of a relational predicate; note there is a separate `TemporalConstraint` type.
deriving (Eq, Ord, Show, Generic, ToJSON)

Expand Down Expand Up @@ -288,6 +289,7 @@ rel2txt RPnotElem = "NOT IN" -- "relNotIn"
rel2txt RPnot = "NOT" -- "relNot"
rel2txt RPand = "&&" -- "relAnd"
rel2txt RPor = "||" -- "relOr"
rel2txt RPmap = "MAP"
rel2txt RPsum = "SUM"
rel2txt RPproduct = "PRODUCT"
rel2txt (RPTC TBefore) = "BEFORE"
Expand All @@ -309,6 +311,7 @@ rel2op RPnotElem = "NOT IN"
rel2op RPnot = "NOT"
rel2op RPand = "&&"
rel2op RPor = "||"
rel2op RPmap = "MAP"
rel2op RPsum = "SUM"
rel2op RPproduct = "PRODUCT"
rel2op (RPTC TBefore) = "BEFORE"
Expand Down

0 comments on commit 5c95cfe

Please sign in to comment.