|
|
|
@ -129,7 +129,7 @@ parseInstruction = |
|
|
|
parseSegmentInt "this" SThis, |
|
|
|
parseSegmentInt "this" SThis, |
|
|
|
parseSegmentInt "that" SThat, |
|
|
|
parseSegmentInt "that" SThat, |
|
|
|
parseSegmentInt "constant" SConstant, |
|
|
|
parseSegmentInt "constant" SConstant, |
|
|
|
(string "static" *> space1) *> (SStatic <$> parseId), |
|
|
|
(string "static" *> space1) *> (SStatic <$> (try parseId <|> parseStaticOffset)), |
|
|
|
parseSegmentInt "pointer" SPointer, |
|
|
|
parseSegmentInt "pointer" SPointer, |
|
|
|
parseSegmentInt "temp" STemp |
|
|
|
parseSegmentInt "temp" STemp |
|
|
|
] |
|
|
|
] |
|
|
|
@ -141,6 +141,10 @@ parseInstruction = |
|
|
|
hs <- many (alphaNumChar <|> char '.' <|> char '_') |
|
|
|
hs <- many (alphaNumChar <|> char '.' <|> char '_') |
|
|
|
return $ T.pack (h : hs) |
|
|
|
return $ T.pack (h : hs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parseStaticOffset :: Parser T.Text |
|
|
|
|
|
|
|
parseStaticOffset = do |
|
|
|
|
|
|
|
h <- L.decimal |
|
|
|
|
|
|
|
return $ "STATIC_" <> (T.pack . show) h |
|
|
|
|
|
|
|
|
|
|
|
parseSegmentInt :: T.Text -> (Int -> Segment) -> Parser Segment |
|
|
|
parseSegmentInt :: T.Text -> (Int -> Segment) -> Parser Segment |
|
|
|
parseSegmentInt sname f = try $ do |
|
|
|
parseSegmentInt sname f = try $ do |
|
|
|
|