{- 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 #-} module Text.GrammarCombinators.Test.ASTTest where import Text.GrammarCombinators.Parser.RecursiveDescent import Text.GrammarCombinators.Parser.Packrat import Text.GrammarCombinators.Parser.Parser import Text.GrammarCombinators.Test.Evaluator import Text.GrammarCombinators.Test.Grammar import Generics.MultiRec.Base infixr 9 .: (f .: g) x y = f (g x y) toAST' :: ASTNode ix -> PFAST I0 ix -> I0 ix toAST'= I0 .: toAST test1 = "((2+1)*2)*(3+4)" prParse :: ASTNode ix -> String -> Result ASTNode I0 Char (I0 ix) prParse = parsePackrat grammar toAST' prParseAdditiveExpr = prParse AdditiveExpr prTest1 = prParseAdditiveExpr test1 astGram = grammar toAST' rdTest1 = parseRecDec astGram AdditiveExpr test1