{- Copyright 2010 Dominique Devriese This file is part of the grammar-combinators library. The grammar-combinators library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Foobar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Foobar. If not, see . -} {-# LANGUAGE FlexibleContexts #-} import Text.GrammarCombinators.Test.Paper.PaperExample import Text.GrammarCombinators.Base import Text.GrammarCombinators.Utils.ToGraph import Text.GrammarCombinators.Transform.FilterDies import Text.GrammarCombinators.Transform.FoldLoops import Text.GrammarCombinators.Transform.UniformPaull import Text.GrammarCombinators.Utils.PrintGrammar import Text.GrammarCombinators.Transform.UnfoldRecursion import Data.GraphViz.Printing import Data.String.Utils import System (getArgs) selectSomeNTs :: UnfoldDepth (FoldLoopsDomain (UPDomain ArithDomain)) selectSomeNTs = selectNothing `selectNT` FLBase (UPHead Expr) `selectNT` FLBase (UPBase Term) `selectNT` FLBase (UPHead Term) `selectNT` FLBase (UPBase Factor) `selectNT` FLBase (UPHead Factor) `selectNT` FLMany (UPTail Factor) `selectNT` FLBase (UPTail Factor) `selectNT` FLBase (UPBase Digit) `selectNT` FLBase (UPHead Digit) `selectNT` FLMany (UPTail Digit) `selectNT` FLBase (UPTail Digit) `selectNT` FLBase (UPBase Expr) `selectNT` FLBase (UPHead Expr) `selectNT` FLBase (UPBase Term) `selectNT` FLBase (UPHead Term) `selectNT` FLBase (UPBase Factor) `selectNT` FLBase (UPHead Factor) `selectNT` FLMany (UPTail Factor) `selectNT` FLBase (UPTail Factor) `selectNT` FLBase (UPBase Digit) `selectNT` FLBase (UPHead Digit) `selectNT` FLMany (UPTail Digit) `selectNT` FLBase (UPTail Digit) calcGrammarArithUPSel :: ProcessingContextFreeGrammar (FoldLoopsDomain (UPDomain ArithDomain)) Char (FoldLoopsValue (UPValue ArithValue)) calcGrammarArithUPSel = unfoldSelective selectSomeNTs calcGrammarArithUPFF main = do args <- getArgs let outfile = head args graph = ruleToGraph 300 (filterDies calcGrammarArithUPSel) (FLBase (UPBase Expr)) dot = renderDot $ toDot $ graphToGraphviz graph filteredDot = replace "Expr" "expr" $ replace "Digit" "digit" $ replace "_tail" "Tail" $ replace "Term" "term" $ replace "<" "" $ replace ">\"" "\"" dot writeFile outfile filteredDot printGrammarArithUPSel = printRule calcGrammarArithUPSel 200 (FLBase (UPBase Expr))