yapb 0.2.1 → 0.2.2
raw patch · 3 files changed
+15/−8 lines, 3 files
Files
- src/parserlib/LoadAutomaton.hs +8/−1
- src/parserlib/SaveProdRules.hs +5/−5
- yapb.cabal +2/−2
src/parserlib/LoadAutomaton.hs view
@@ -4,6 +4,7 @@ import SaveProdRules(tokenizeLhs) import System.IO import Text.Read (readMaybe)+import Data.Char (isSpace) loadAutomaton :: String -> String -> String -> IO (ActionTable, GotoTable, ProdRules)@@ -35,7 +36,12 @@ tokenizeTerminalInAction :: String -> IO (String, Action, ActionTable) tokenizeTerminalInAction str =- case lex str of+ let str' = dropWhile Data.Char.isSpace str+ terminal = takeWhile (not . Data.Char.isSpace) str'+ str'' = drop (length terminal) str'+ lexRes = if length terminal > 0 then [(terminal,str'')] else [("",str'')]+ in+ case lexRes of [] -> fail "No terminal found (1)" [("", therest)] -> fail "No terminal found (2)" [(terminal, therest)] -> do@@ -56,6 +62,7 @@ "Accept" -> do actTbl <- tokenizeStateNumInAction therest return (Accept, actTbl)+ _ -> fail ("Unexpected action: " ++ action) tokenizeShiftReduceStateNumInAction :: String -> (Int -> Action) -> IO (Action, ActionTable)
src/parserlib/SaveProdRules.hs view
@@ -55,11 +55,11 @@ [(token,therest)] -> error ("No arrow found: " ++ token) tokenizeRhs :: String -> [String]-tokenizeRhs str = - case lex str of- [] -> []- [("",therest)] -> []- [(token,therest)] -> token : tokenizeRhs therest+tokenizeRhs str = words str -- Terminals and nonterminls are space-separated words in RHS+ -- case lex str of+ -- [] -> []+ -- [("",therest)] -> []+ -- [(token,therest)] -> token : tokenizeRhs therest -- Utility concatWith :: [String] -> String -> String
yapb.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 32f1cadd82bb926fdd3eb1f2135b5f51d9810df76c812b40a242371ea1ae14e0+-- hash: d0b9a77c0d67fbcf2f0f940bd558e929e1fa2e0e1ca4d08e171c07c0244e03ad name: yapb-version: 0.2.1+version: 0.2.2 synopsis: Yet Another Parser Builder (YAPB) description: A programmable LALR(1) parser builder system. Please see the README on GitHub at <https://github.com/kwanghoon/yapb#readme> category: parser builder