@@ -132,8 +132,11 @@ parensTerm =
132recordTerm :: IParser Source.Expr
132recordTerm :: IParser Source.Expr
133recordTerm =
133recordTerm =
134 addLocation $
134 addLocation $
135− brackets $ choice [ misc, record ]
135+ brackets (choice [ misc, record ])
138+ E.Record <$> commaSep field
138 do label <- rLabel
141 do label <- rLabel
139 patterns <- spacePrefix Pattern.term
142 patterns <- spacePrefix Pattern.term
@@ -141,38 +144,53 @@ recordTerm =
141 body <- expr
144 body <- expr
142 return (label, makeFunction patterns body)
145 return (label, makeFunction patterns body)
145− E.Record <$> commaSep field
148+ do nextParser <- try miscStarter
149− padded (string "<-")
154 whitespace
149 whitespace
155− E.Remove r <$> rLabel
150+ nextParser
157− insert r =
152+ miscStarter =
158− do string "|"
153+ do start <- getMyPosition
154+ record <- addLocation (E.rawVar <$> rLabel)
159 whitespace
155 whitespace
160− E.Insert r <$> rLabel <*> (padded equals >> expr)
156+ choice
157+ [ string "-" >> return (afterMinus start record)
158+ , string "|" >> return (afterBar record)
162− modify r =
161+ afterMinus start record =
163− do string "|"
162+ do field <- rLabel
163+ end <- getMyPosition
164+ let subRecord' = E.Remove record field
165+ maybe <- optionMaybe (try (whitespace >> string "|"))
173+ E.Insert (A.at start end subRecord') field <$> expr
164 whitespace
177 whitespace
165− E.Modify r <$> commaSep1 change
178+ choice
181+ E.Insert record field <$> expr
185+ updates <- spaceyPrefixBy comma update
186+ return (E.Modify record ((field,value) : updates))
191+ padded (string "<-")
169− record <- addLocation (E.rawVar <$> rLabel)
170− opt <- padded (optionMaybe (addLocation (remove record)))
172− Just e@(A.A _ e') ->
173− try (insert e) <|> return e'
175− try (insert record) <|> try (modify record)
178term :: IParser Source.Expr
196term :: IParser Source.Expr