From c5be7e30b3e4b8a9e96a9c65412cf849edc8e1e3 Mon Sep 17 00:00:00 2001 From: Kwanghoon Choi Date: Sun, 25 Dec 2022 19:31:05 +0900 Subject: [PATCH] revise printing production rules in debug mode --- list_of_users.txt | 2 +- package.yaml | 4 ++-- src/parserlib/AutomatonType.hs | 8 ++++++++ src/parserlib/CommonParserUtil.hs | 2 +- yapb.cabal | 8 ++++---- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/list_of_users.txt b/list_of_users.txt index 75fb70c..f8e887f 100644 --- a/list_of_users.txt +++ b/list_of_users.txt @@ -1,4 +1,4 @@ -Applications using YAPB +A list of applications to maintain using YAPB - arith - smllike - polyrpc diff --git a/package.yaml b/package.yaml index 8762879..2743488 100644 --- a/package.yaml +++ b/package.yaml @@ -1,10 +1,10 @@ name: yapb -version: 0.2.6 +version: 0.2.7 github: "kwanghoon/yapb" license: BSD3 author: "Kwanghoon Choi" maintainer: "lazyswamp@gmail.com" -copyright: "2020-2021 Kwanghoon Choi" +copyright: "2020-2022 Kwanghoon Choi" extra-source-files: - README.md diff --git a/src/parserlib/AutomatonType.hs b/src/parserlib/AutomatonType.hs index 090ef93..cc5e826 100644 --- a/src/parserlib/AutomatonType.hs +++ b/src/parserlib/AutomatonType.hs @@ -6,3 +6,11 @@ type ActionTable = [((Int, String), Action)] -- key: (Int,String), value: Action type GotoTable = [((Int, String), Int)] -- key: (Int,String), value: Int type ProdRules = [(String, [String])] -- key: Int, value: (String, [String]) +prProdRule :: (String, [String]) -> String +prProdRule (x,ys) = x ++ " -> " ++ pr_ys ys + where + pr_ys [] = "" + pr_ys [y] = y + pr_ys (y:ys) = y ++ " " ++ pr_ys ys + + diff --git a/src/parserlib/CommonParserUtil.hs b/src/parserlib/CommonParserUtil.hs index e6ce627..7d99758 100644 --- a/src/parserlib/CommonParserUtil.hs +++ b/src/parserlib/CommonParserUtil.hs @@ -629,7 +629,7 @@ runYapbAutomaton flag (am_spec@(AutomatonSpec { let prodrule = prodRules !! n in - debug flag ("\t" ++ show prodrule) $ + debug flag ("\t" ++ prProdRule prodrule) $ let builderFun = pFunList !! n in let lhs = fst prodrule in diff --git a/yapb.cabal b/yapb.cabal index a6fea53..3fc4675 100644 --- a/yapb.cabal +++ b/yapb.cabal @@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4. +-- This file has been generated from package.yaml by hpack version 0.35.0. -- -- see: https://github.com/sol/hpack -- --- hash: c133b635fac4f9781f13419abca45b81d467bdf36d792e8884b3a6225a28e571 +-- hash: 5a75606bf54164b0ec65ff2140d206d12e6f0515f43690ced0195352f13bab63 name: yapb -version: 0.2.6 +version: 0.2.7 synopsis: Yet Another Parser Builder (YAPB) description: A programmable LALR(1) parser builder system. Please see the README on GitHub at category: parser builder @@ -15,7 +15,7 @@ homepage: https://github.com/kwanghoon/yapb#readme bug-reports: https://github.com/kwanghoon/yapb/issues author: Kwanghoon Choi maintainer: lazyswamp@gmail.com -copyright: 2020-2021 Kwanghoon Choi +copyright: 2020-2022 Kwanghoon Choi license: BSD3 license-file: LICENSE build-type: Simple