on master help sign in
Add syntax messages for the last few variants!
0e669b8Evan Czaplicki
compiler/src/Parse/Expression.hs+2−2
@@ -267,14 +267,14 @@ chompExprEnd :: A.Position -> State -> Space.Parser E.Expr Src.Expr
267chompExprEnd start (State ops expr args end) =
267chompExprEnd start (State ops expr args end) =
268 oneOfWithFallback
268 oneOfWithFallback
269 [ -- argument
269 [ -- argument
270− do Space.checkIndent end E.IndentMoreExpr
270+ do Space.checkIndent end E.Start
271 arg <- term
271 arg <- term
272 newEnd <- getPosition
272 newEnd <- getPosition
273 Space.chomp E.Space
273 Space.chomp E.Space
274 chompExprEnd start (State ops expr (arg:args) newEnd)
274 chompExprEnd start (State ops expr (arg:args) newEnd)
275
275
276 , -- operator
276 , -- operator
277− do Space.checkIndent end E.IndentMoreExpr
277+ do Space.checkIndent end E.Start
278 op@(A.At (A.Region opStart opEnd) opName) <- addLocation (Symbol.operator E.Start E.OperatorReserved)
278 op@(A.At (A.Region opStart opEnd) opName) <- addLocation (Symbol.operator E.Start E.OperatorReserved)
279 Space.chompAndCheckIndent E.Space (E.IndentOperatorRight opName)
279 Space.chompAndCheckIndent E.Space (E.IndentOperatorRight opName)
280 newStart <- getPosition
280 newStart <- getPosition
compiler/src/Reporting/Error/Syntax.hs+57−6
@@ -224,7 +224,6 @@ data Expr
224 | EndlessShader Row Col
224 | EndlessShader Row Col
225 | ShaderProblem [Char.Char] Row Col
225 | ShaderProblem [Char.Char] Row Col
226 | IndentOperatorRight Name.Name Row Col
226 | IndentOperatorRight Name.Name Row Col
227− | IndentMoreExpr Row Col
228
227
229
228
230data Record
229data Record
@@ -2337,9 +2336,6 @@ toExprReport source context expr startRow startCol =
2337 ]
2336 ]
2338 )
2337 )
2339
2338
2340− IndentMoreExpr _ _ ->
2341− error "TODO IndentMoreExpr"
2342−
2343
2339
2344
2340
2345-- CHAR
2341-- CHAR
@@ -4270,8 +4266,41 @@ toPatternReport source context pattern startRow startCol =
4270 "This is a reserved word! Try using some other name?"
4266 "This is a reserved word! Try using some other name?"
4271 )
4267 )
4272
4268
4269+ Code.Operator "-" ->
4270+ let
4271+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4272+ region = toRegion row col
4273+ in
4274+ Report.Report "UNEXPECTED SYMBOL" region [] $
4275+ Code.toSnippet source surroundings (Just region)
4276+ (
4277+ D.reflow $
4278+ "I ran into a minus sign unexpectedly in this pattern:"
4279+ ,
4280+ D.reflow $
4281+ "It is not possible to pattern match on negative numbers at this\
4282+ \ time. Try using an `if` expression for that sort of thing for now."
4283+ )
4284+
4273 _ ->
4285 _ ->
4274− error "TODO PStart"
4286+ let
4287+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4288+ region = toRegion row col
4289+ in
4290+ Report.Report "PROBLEM IN PATTERN" region [] $
4291+ Code.toSnippet source surroundings (Just region)
4292+ (
4293+ D.reflow $
4294+ "I wanted to parse a pattern next, but I got stuck here:"
4295+ ,
4296+ D.fillSep $
4297+ ["I","am","not","sure","why","I","am","getting","stuck","exactly."
4298+ ,"I","just","know","that","I","want","a","pattern","next."
4299+ ,"Something","as","simple","as"
4300+ ,D.dullyellow "maybeHeight","or",D.dullyellow "result"
4301+ ,"would","work!"
4302+ ]
4303+ )
4275
4304
4276 PChar char row col ->
4305 PChar char row col ->
4277 toCharReport source char row col
4306 toCharReport source char row col
@@ -4348,7 +4377,29 @@ toPatternReport source context pattern startRow startCol =
4348 toSpaceReport source space row col
4377 toSpaceReport source space row col
4349
4378
4350 PIndentStart row col ->
4379 PIndentStart row col ->
4351− error "TODO PIndentStart" row col
4380+ let
4381+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4382+ region = toRegion row col
4383+ in
4384+ Report.Report "UNFINISHED PATTERN" region [] $
4385+ Code.toSnippet source surroundings (Just region)
4386+ (
4387+ D.reflow $
4388+ "I wanted to parse a pattern next, but I got stuck here:"
4389+ ,
4390+ D.stack
4391+ [ D.fillSep $
4392+ ["I","am","not","sure","why","I","am","getting","stuck","exactly."
4393+ ,"I","just","know","that","I","want","a","pattern","next."
4394+ ,"Something","as","simple","as"
4395+ ,D.dullyellow "maybeHeight","or",D.dullyellow "result"
4396+ ,"would","work!"
4397+ ]
4398+ , D.toSimpleNote $
4399+ "I can get confused by indentation. If you think there is a pattern next, maybe\
4400+ \ it needs to be indented a bit more?"
4401+ ]
4402+ )
4352
4403
4353 PIndentAlias row col ->
4404 PIndentAlias row col ->
4354 let
4405 let