@@ -1,8 +1,9 @@
1{-# OPTIONS_GHC -Wall #-}
1{-# OPTIONS_GHC -Wall #-}
2−{-# LANGUAGE BangPatterns, UnboxedTuples, OverloadedStrings #-}
2+{-# LANGUAGE BangPatterns, OverloadedStrings #-}
3module Parse.Symbol
3module Parse.Symbol
5− , operator
4+ ( operator
@@ -15,38 +16,22 @@ import Foreign.Ptr (Ptr, plusPtr, minusPtr)
15import GHC.Word (Word8)
16import GHC.Word (Word8)
17import Parse.Primitives (Parser, Row, Col)
18import Parse.Primitives (Parser, Row, Col)
18−import qualified Parse.Variable as Var
19import qualified Parse.Primitives as P
19import qualified Parse.Primitives as P
20−import qualified Reporting.Error.Syntax as E
24−-- UNDERSCORE
23+-- OPERATOR
27−wildcard :: Parser E.Pattern ()
29− P.Parser $ \(P.State pos end indent row col) cok _ cerr eerr ->
30− if pos == end || P.unsafeIndex pos /= 0x5F {- _ -} then
31− eerr row col E.PStart
34− !newPos = plusPtr pos 1
37− if Var.getInnerWidth newPos end > 0 then
38− let (# _, badCol #) = Var.chompInnerChars newPos end newCol in
39− cerr row col (E.PWildcardNotVar (fromIntegral (badCol - col)))
41− let !newState = P.State newPos end indent row newCol in
46−-- OPERATOR
26+data BadOperator
49−operator :: (Row -> Col -> x) -> (E.Operator -> Row -> Col -> x) -> Parser x Name.Name
34+operator :: (Row -> Col -> x) -> (BadOperator -> Row -> Col -> x) -> Parser x Name.Name
50operator toExpectation toError =
35operator toExpectation toError =
51 P.Parser $ \(P.State pos end indent row col) cok _ cerr eerr ->
36 P.Parser $ \(P.State pos end indent row col) cok _ cerr eerr ->
52 let !newPos = chompOps pos end in
37 let !newPos = chompOps pos end in
@@ -55,11 +40,11 @@ operator toExpectation toError =
57 case Name.fromPtr pos newPos of
42 case Name.fromPtr pos newPos of
58− "." -> cerr row col (toError E.OpDot)
43+ "." -> cerr row col (toError BadDot)
59− "|" -> cerr row col (toError E.OpPipe)
44+ "|" -> cerr row col (toError BadPipe)
60− "->" -> cerr row col (toError E.OpArrow)
45+ "->" -> cerr row col (toError BadArrow)
61− "=" -> cerr row col (toError E.OpEquals)
46+ "=" -> cerr row col (toError BadEquals)
62− ":" -> cerr row col (toError E.OpHasType)
47+ ":" -> cerr row col (toError BadHasType)
65 !newCol = col + fromIntegral (minusPtr newPos pos)
50 !newCol = col + fromIntegral (minusPtr newPos pos)