{- 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 NoMonomorphismRestriction #-} {-# LANGUAGE FlexibleContexts #-} import Text.GrammarCombinators.Parser.RecursiveDescent import Text.GrammarCombinators.Parser.Packrat import Text.GrammarCombinators.Base import Text.GrammarCombinators.Utils.PrintGrammar import Text.GrammarCombinators.Utils.CalcFirst import Text.GrammarCombinators.Utils.IsReachable import Text.GrammarCombinators.Utils.EnumTokens import Text.GrammarCombinators.Transform.UnfoldRecursion import Text.GrammarCombinators.Transform.LeftCorner import Text.GrammarCombinators.Transform.UniformPaull import Text.GrammarCombinators.Transform.FilterDies import Text.GrammarCombinators.Transform.UnfoldDead import Text.GrammarCombinators.Transform.UnfoldLoops import Text.GrammarCombinators.Transform.PenalizeErrors import Text.GrammarCombinators.Parser.Parsec import Text.GrammarCombinators.Parser.PenaltyParser import Text.GrammarCombinators.Parser.UUParse import Text.GrammarCombinators.Test.Evaluator import Text.GrammarCombinators.Test.Grammar import qualified Text.ParserCombinators.Parsec as Parsec evalPenalty :: Processor ASTNode (MaybeSemanticT NodeValue) evalPenalty = processPenalizedSimple evaluator evalpgram :: ProcessingContextFreeGrammar ASTNode ASTToken (MaybeSemanticT NodeValue) evalpgram = applyProcessor grammar evalPenalty evalpgrame :: ProcessingPenaltyContextFreeGrammar ASTNode ASTToken (MaybeSemanticT NodeValue) evalpgrame = penalizeErrors evalpgram test :: [(Int, MaybeSemanticT NodeValue AdditiveExpr)] test = take 5 $ parsePenalty evalpgrame AdditiveExpr 10 test1 test2 :: IO () test2 = putStr $ printGrammar evalpgrame test1 :: [Char] test1 = "2" testrule :: PenaltyRegularRule ASTNode NodeValue ASTToken Char testrule = (token OPAREN *>>> testrule) ||| token DIGIT -- (head $ toAscList (unPPR testrule) 0) `seq` 1 -- mag niet in infinite loop!