on master help sign in
Correctly parse when .x is an argument

Just check for arguments first. This should be more common, so it’s likely this is a bit faster.

commit220df1ee4c48df986e706fbba73eb2235cc710e0 authorEvan Czaplicki <evancz@users.noreply.github.com> dateSat 17 Dec 2016, 12:51 (10 years ago) parente09f369
1 file changed+10−10
src/Parse/Expression.hs+10−10
src/Parse/Expression.hs+10−10
@@ -270,7 +270,16 @@ data State =
270270exprHelp :: R.Position -> State -> ExprParser
271271exprHelp start (State ops lastExpr end pos) =
272272 oneOf
273− [ -- infix operator
273+ [ -- argument
274+ hint E.Arg $
275+ do checkSpace pos
276+ arg <- term
277+ newEnd <- getPosition
278+ newPos <- whitespace
279+ let newLast = A.merge lastExpr arg (Src.App lastExpr arg)
280+ exprHelp start (State ops newLast newEnd newPos)
281+
282+ , -- infix operator
274283 do checkSpace pos
275284 opStart <- getPosition
276285 opName <- infixOp
@@ -312,15 +321,6 @@ exprHelp start (State ops lastExpr end pos) =
312321 return ( finalExpr, newEnd, newPos )
313322 ]
314323
315− , -- argument
316− hint E.Arg $
317− do checkSpace pos
318− arg <- term
319− newEnd <- getPosition
320− newPos <- whitespace
321− let newLast = A.merge lastExpr arg (Src.App lastExpr arg)
322− exprHelp start (State ops newLast newEnd newPos)
323−
324324 , -- done
325325 case ops of
326326 [] ->