diff --git a/HLasm.cabal b/HLasm.cabal index 95592cc..2d476bd 100644 --- a/HLasm.cabal +++ b/HLasm.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: HLasm -version: 0.1.0.0 +version: 0.2.0.0 description: Please see the README on GitHub at homepage: https://github.com/vorotynsky/HLasm#readme bug-reports: https://github.com/vorotynsky/HLasm/issues diff --git a/package.yaml b/package.yaml index 2973d8f..6e87dee 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: HLasm -version: 0.1.0.0 +version: 0.2.0.0 github: "vorotynsky/HLasm" license: GPL-3 author: "Vorotynsky Maxim" diff --git a/src/HLasm/Instructions.hs b/src/HLasm/Instructions.hs index 66ca01a..f2f84bd 100644 --- a/src/HLasm/Instructions.hs +++ b/src/HLasm/Instructions.hs @@ -82,7 +82,7 @@ instructions (Node ((If lbl), _, _, _) []) = Right [] instructions (Node ((If lbl), _, _, _) xs) = do (conds, bodies') <- Right $ traverse (uncurry branch) (zip [1..] xs) bodies <- fmap (concat) . sequence $ bodies' - Right $ conds ++ bodies ++ [Label (lbl ++ "end")] + Right $ conds ++ [Jump (lbl ++ "end") Nothing] ++ bodies ++ [Label (lbl ++ "end")] where condition lbl pt (Condition (left, cmp, right)) = let find = valuableTarget pt in [Compare (find left) (find right), Jump lbl (Just cmp)] diff --git a/src/HLasm/Parser.hs b/src/HLasm/Parser.hs index 7bb5272..5d03cb4 100644 --- a/src/HLasm/Parser.hs +++ b/src/HLasm/Parser.hs @@ -52,7 +52,7 @@ value = (IntegerValue <$> aparse nat) <|> (NameValue <$> aparse name) assignment = leafP id (Assignment <$> name <*> (achar '=' *> value)) condition = curry3 Condition <$> value <*> cond <*> value where p x s = const x <$> string s - cond = p Equals "==" <|> p NotEquals "!=" <|> p Greater "<" <|> p Less ">" + cond = p Equals "==" <|> p NotEquals "!=" <|> p Greater ">" <|> p Less "<" instrSet p = ftree <$> treeParser internal (aparse . many $ aparse p) where internal x = pure (Node InstructionSet x, []) @@ -71,7 +71,7 @@ ifstatment p = (condition, label) <- parens ((,) <$> condition <*> (achar ',' *> name)) block <- returnBlock $ Just condition return $ (label, block) - elseif = do keyword "else"; keyword "if" + elseif = do try (keyword "else" *> keyword "if") condition <- parens condition returnBlock $ Just condition elseblk = keyword "else" >>= const (returnBlock Nothing)