3a_asm: FEATURE/FIX: proper line numbers on parsing error
[calu.git] / 3a_asm / DT.hs
index 519415981a0347bc5eb3b2d699ab070a804652c8..c80186ca399447d171e1eae70e7f17f99427f9ee 100644 (file)
@@ -17,12 +17,12 @@ import Control.Applicative hiding ((<|>))
 
 
 -- parsing --
-instruction :: Dict -> Parser Word32
-instruction dict = foldl1 (<|>) (fmap (\x -> try (x dict)) instructions) <* char '\n'
+instruction :: LineNo -> Dict -> Parser Word32
+instruction lno dict = foldl1 (<|>) (fmap (\x -> try (x dict)) instructions) <* char '\n' <?> (". something at line " ++ show lno ++ " is wrong (ignore line 1 hint above, but pay attention for possible line offset due to #include).")
 
 testins :: String -> IO ()
 testins input =
-       case (parse (instruction dict) "" (input++"\n")) of
+       case (parse (instruction dict) "" (input++"\n")) of
                Left err -> do { putStr "fail :/\n"; print err}
                Right x -> do { printf "0x%08X\n" x }
        where