Skip to content

Commit

Permalink
fixed application associativity
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoTz committed Jun 6, 2024
1 parent 45f0a1b commit cd8b303
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 86 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SPAGO = spago
PACKAGE = one-sided-sc
FFISH = one-sided-examples/stdlib/libToJs.sh

.SILENT: examples build test
.PHONY: examples build test

examples:
Expand Down
7 changes: 2 additions & 5 deletions one-sided-parser/src/Parser/Terms.purs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ import Control.Alt ((<|>))

parseTerm :: SrcParser Term
parseTerm = do
t1 <- (parseT <|> parseParens parseT)
t1 <- (\_-> parseT) unit <|> (\_->parseParens parseT) unit
_ <- sc
t1' <- try (parseSeq t1 <|> parseAnd t1 <|> parseOr t1 <|> parseApp t1) <|> pure t1
pure t1'
where
appTerm :: Term -> List Term -> Term
appTerm t1 Nil = t1
appTerm t1 (Cons t2 ts) = appTerm (App (getLoc t1) t1 t2) ts

parseApp :: Term -> SrcParser Term
parseApp t1 = do
Expand All @@ -45,6 +41,7 @@ parseApp t1 = do
where
appTerm :: Term -> List Term -> Term
appTerm t Nil = t
appTerm t (Cons (App loc t2 t2') ts) = appTerm (App loc t t2) (Cons t2' ts)
appTerm t (Cons t2 ts) = appTerm (App (getLoc t2) t t2) ts

parseSeq :: Term -> SrcParser Term
Expand Down
Loading

0 comments on commit cd8b303

Please sign in to comment.