packages feed

BNFC 2.7.1 → 2.8

raw patch · 76 files changed

+4139/−7833 lines, 76 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

BNFC.cabal view
@@ -1,5 +1,5 @@ Name: BNFC-Version: 2.7.1+Version: 2.8 cabal-version: >= 1.8 build-type: Simple category: Development@@ -55,7 +55,7 @@   Main-is: Main.hs   HS-source-dirs: src/   ghc-options:     -W-  extensions: OverloadedStrings+  extensions: OverloadedStrings RecordWildCards FlexibleContexts   Other-modules:     -- generated by cabal     Paths_BNFC,@@ -72,7 +72,9 @@     BNFC.MultiView,     BNFC.TypeChecker,     BNFC.GetCF,+    BNFC.Lexing,     BNFC.Backend.Base+    BNFC.Backend.Common,     BNFC.Backend.Common.Makefile,     BNFC.Backend.Common.NamedVariables,     BNFC.Backend.Common.OOAbstract,@@ -80,6 +82,8 @@     BNFC.Options,     BNFC.WarningM,     Data.Pair,+    BNFC.Backend.Utils,+    BNFC.PrettyPrint,      -- Documentation backends     BNFC.Backend.Latex,@@ -100,13 +104,13 @@     BNFC.Backend.Haskell.MkErrM,     BNFC.Backend.Haskell.MkSharedString,     BNFC.Backend.Haskell.HsOpts,+    BNFC.Backend.Haskell.Utils,     -- Profile     BNFC.Backend.HaskellProfile,     BNFC.Backend.HaskellProfile.CFtoHappyProfile,     -- Haskell GADT     BNFC.Backend.HaskellGADT,     BNFC.Backend.HaskellGADT.HaskellGADTCommon,-    BNFC.Backend.HaskellGADT.CFtoPrinterGADT,     BNFC.Backend.HaskellGADT.CFtoTemplateGADT,     BNFC.Backend.HaskellGADT.CFtoAbstractGADT, @@ -132,10 +136,10 @@      -- C++ backend     BNFC.Backend.CPP.NoSTL,+    BNFC.Backend.CPP.PrettyPrinter,     BNFC.Backend.CPP.NoSTL.RegToFlex,     BNFC.Backend.CPP.NoSTL.CFtoFlex,     BNFC.Backend.CPP.NoSTL.CFtoBison,-    BNFC.Backend.CPP.NoSTL.CFtoCPPPrinter,     BNFC.Backend.CPP.NoSTL.CFtoCPPAbs,      -- C++ STL backend@@ -144,7 +148,6 @@     BNFC.Backend.CPP.STL.CFtoSTLAbs,     BNFC.Backend.CPP.STL.STLUtils,     BNFC.Backend.CPP.STL.CFtoCVisitSkelSTL,-    BNFC.Backend.CPP.STL.CFtoSTLPrinter,      -- C# backend     BNFC.Backend.CSharp,@@ -173,6 +176,8 @@     -- XML backend     BNFC.Backend.XML +    -- Pygments backend+    BNFC.Backend.Pygments  -- --- Testing -------------------------------------------------------------- Test-suite unit-tests@@ -181,10 +186,13 @@                  hspec, QuickCheck >= 2.5, HUnit,                  temporary, containers, deepseq   Main-is: unit-tests.hs-  HS-source-dirs: src test/-  extensions: OverloadedStrings+  HS-source-dirs: src test+  extensions: OverloadedStrings RecordWildCards FlexibleContexts   Other-modules:    BNFC.Backend.Common.MakefileSpec+   BNFC.Backend.Haskell.CFtoHappySpec+   BNFC.Backend.HaskellGADTSpec+   BNFC.Backend.HaskellSpec    BNFC.OptionsSpec    BNFC.WarningMSpec    -- need to be there for alex to work@@ -196,4 +204,4 @@   ghc-options:    -threaded   main-is:        doctests.hs   build-depends:  base, doctest >= 0.8-  HS-source-dirs: test/+  HS-source-dirs: test
changelog view
@@ -1,3 +1,12 @@+2.8 Grégoire Détrez <gregoire.detrez@gu.se>  May 2015+	* Builds with ghc 7.10.1+	* Add support for JFlex (java)+	* Add an option to generate files in an other directory+	* Add an experimental option that turns the AST into a parametrized+	  functor (in Haskell only)+	* New pygment backend to generate syntax highlighters+	* Bug fixes+ 2.7.1 Grégoire Détrez <gregoire.detrez@gu.se> October 2014 	* Generated haskell code is now warning free 	* Removed unused terminal in happy
− dist/build/bnfc/bnfc-tmp/LexBNF.hs
@@ -1,412 +0,0 @@-{-# LANGUAGE CPP,MagicHash #-}-{-# LINE 3 "src/LexBNF.x" #-}--{-# OPTIONS -fno-warn-incomplete-patterns #-}-{-# OPTIONS_GHC -w #-}-module LexBNF where----import qualified Data.Bits-import Data.Word (Word8)--#if __GLASGOW_HASKELL__ >= 603-#include "ghcconfig.h"-#elif defined(__GLASGOW_HASKELL__)-#include "config.h"-#endif-#if __GLASGOW_HASKELL__ >= 503-import Data.Array-import Data.Char (ord)-import Data.Array.Base (unsafeAt)-#else-import Array-import Char (ord)-#endif-#if __GLASGOW_HASKELL__ >= 503-import GHC.Exts-#else-import GlaExts-#endif-alex_base :: AlexAddr-alex_base = AlexA# "\xf8\xff\xff\xff\x49\x00\x00\x00\xc9\xff\xff\xff\xe0\xff\xff\xff\xc9\x00\x00\x00\x9c\x01\x00\x00\x2d\x00\x00\x00\x1c\x02\x00\x00\x1c\x03\x00\x00\x0a\x01\x00\x00\x00\x00\x00\x00\x0d\x03\x00\x00\x0d\x04\x00\x00\xcd\x03\x00\x00\xcd\x04\x00\x00\x91\x05\x00\x00\xef\x05\x00\x00\x8d\x04\x00\x00\x00\x00\x00\x00\xa5\x05\x00\x00\xdb\xff\xff\xff\x47\x00\x00\x00\x5a\x00\x00\x00\xa5\x06\x00\x00\xa6\x06\x00\x00\x69\x07\x00\x00\x29\x07\x00\x00\x00\x00\x00\x00\x1f\x08\x00\x00\x00\x00\x00\x00\x78\x00\x00\x00\xdc\xff\xff\xff\xdd\xff\xff\xff\x00\x00\x00\x00\xdf\xff\xff\xff\xf8\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x72\x00\x00\x00\xe7\x05\x00\x00\x7c\x00\x00\x00"#--alex_table :: AlexAddr-alex_table = AlexA# "\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x21\x00\x25\x00\x16\x00\x1c\x00\x05\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x02\x00\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x21\x00\x21\x00\x21\x00\x21\x00\x21\x00\x1f\x00\x21\x00\x00\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x22\x00\x21\x00\x00\x00\x21\x00\x00\x00\x21\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x21\x00\x03\x00\x21\x00\x00\x00\x21\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x20\x00\x21\x00\x21\x00\x01\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x03\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15\x00\x03\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x08\x00\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x19\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x01\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x08\x00\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x04\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x13\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x00\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x06\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x0c\x00\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x1a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x24\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x10\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x0f\x00\x11\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x19\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1a\x00\x04\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x13\x00\x07\x00\x0a\x00\x0a\x00\x0a\x00\x0b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#--alex_check :: AlexAddr-alex_check = AlexA# "\xff\xff\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x3d\x00\x27\x00\x2d\x00\x2d\x00\x2d\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\x20\x00\x3a\x00\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\xff\xff\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\xff\xff\x3d\x00\xff\xff\x3f\x00\xff\xff\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x27\x00\x5d\x00\xff\xff\x5f\x00\xff\xff\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x2d\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\xff\xff\xff\xff\xff\xff\x5c\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\x6e\x00\xff\xff\xff\xff\xff\xff\xff\xff\x2e\x00\x74\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc3\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7d\x00\xff\xff\xff\xff\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x2d\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\xff\xff\xff\xff\xc2\x00\xc3\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\x27\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\x65\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x6e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x74\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\xff\xff\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\xff\xff\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\xff\xff\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xff\xff\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xff\xff\xc2\x00\xc3\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x0a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x27\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\xff\xff\xff\xff\xff\xff\xff\xff\x5f\x00\xff\xff\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc3\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#--alex_deflt :: AlexAddr-alex_deflt = AlexA# "\xff\xff\x05\x00\xff\xff\xff\xff\xff\xff\x05\x00\xff\xff\xff\xff\x05\x00\x05\x00\x12\x00\x12\x00\x03\x00\x03\x00\xff\xff\x17\x00\xff\xff\x17\x00\x1b\x00\x1b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1c\x00\x1c\x00\x1c\x00\x1c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#--alex_accept = listArray (0::Int,40) [AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccSkip,AlexAccSkip,AlexAccSkip,AlexAcc (alex_action_3),AlexAcc (alex_action_3),AlexAcc (alex_action_3),AlexAcc (alex_action_3),AlexAcc (alex_action_4),AlexAcc (alex_action_5),AlexAcc (alex_action_6),AlexAcc (alex_action_7),AlexAcc (alex_action_8),AlexAcc (alex_action_8)]-{-# LINE 38 "src/LexBNF.x" #-}---tok :: (Posn -> String -> Token) -> (Posn -> String -> Token)-tok f p s = f p s--share :: String -> String-share = id--data Tok =-   TS !String !Int    -- reserved words and symbols- | TL !String         -- string literals- | TI !String         -- integer literals- | TV !String         -- identifiers- | TD !String         -- double precision float literals- | TC !String         -- character literals-- deriving (Eq,Show,Ord)--data Token =-   PT  Posn Tok- | Err Posn-  deriving (Eq,Show,Ord)--tokenPos :: [Token] -> String-tokenPos (PT (Pn _ l _) _ :_) = "line " ++ show l-tokenPos (Err (Pn _ l _) :_) = "line " ++ show l-tokenPos _ = "end of file"--tokenPosn :: Token -> Posn-tokenPosn (PT p _) = p-tokenPosn (Err p) = p--tokenLineCol :: Token -> (Int, Int)-tokenLineCol = posLineCol . tokenPosn--posLineCol :: Posn -> (Int, Int)-posLineCol (Pn _ l c) = (l,c)--mkPosToken :: Token -> ((Int, Int), String)-mkPosToken t@(PT p _) = (posLineCol p, prToken t)--prToken :: Token -> String-prToken t = case t of-  PT _ (TS s _) -> s-  PT _ (TL s)   -> s-  PT _ (TI s)   -> s-  PT _ (TV s)   -> s-  PT _ (TD s)   -> s-  PT _ (TC s)   -> s---data BTree = N | B String Tok BTree BTree deriving (Show)--eitherResIdent :: (String -> Tok) -> String -> Tok-eitherResIdent tv s = treeFind resWords-  where-  treeFind N = tv s-  treeFind (B a t left right) | s < a  = treeFind left-                              | s > a  = treeFind right-                              | s == a = t--resWords :: BTree-resWords = b "digit" 21 (b "=" 11 (b "-" 6 (b "*" 3 (b ")" 2 (b "(" 1 N N) N) (b "," 5 (b "+" 4 N N) N)) (b "::=" 9 (b ":" 8 (b "." 7 N N) N) (b ";" 10 N N))) (b "char" 16 (b "]" 14 (b "[" 13 (b "?" 12 N N) N) (b "_" 15 N N)) (b "define" 19 (b "comment" 18 (b "coercions" 17 N N) N) (b "delimiters" 20 N N)))) (b "separator" 31 (b "letter" 26 (b "internal" 24 (b "eps" 23 (b "entrypoints" 22 N N) N) (b "layout" 25 N N)) (b "position" 29 (b "nonempty" 28 (b "lower" 27 N N) N) (b "rules" 30 N N))) (b "upper" 36 (b "token" 34 (b "terminator" 33 (b "stop" 32 N N) N) (b "toplevel" 35 N N)) (b "|" 39 (b "{" 38 (b "views" 37 N N) N) (b "}" 40 N N))))-   where b s n = let bs = id s-                  in B bs (TS bs n)--unescapeInitTail :: String -> String-unescapeInitTail = id . unesc . tail . id where-  unesc s = case s of-    '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs-    '\\':'n':cs  -> '\n' : unesc cs-    '\\':'t':cs  -> '\t' : unesc cs-    '"':[]    -> []-    c:cs      -> c : unesc cs-    _         -> []------------------------------------------------------------------------ Alex wrapper code.--- A modified "posn" wrapper.----------------------------------------------------------------------data Posn = Pn !Int !Int !Int-      deriving (Eq, Show,Ord)--alexStartPos :: Posn-alexStartPos = Pn 0 1 1--alexMove :: Posn -> Char -> Posn-alexMove (Pn a l c) '\t' = Pn (a+1)  l     (((c+7) `div` 8)*8+1)-alexMove (Pn a l c) '\n' = Pn (a+1) (l+1)   1-alexMove (Pn a l c) _    = Pn (a+1)  l     (c+1)--type Byte = Word8--type AlexInput = (Posn,     -- current position,-                  Char,     -- previous char-                  [Byte],   -- pending bytes on the current char-                  String)   -- current input string--tokens :: String -> [Token]-tokens str = go (alexStartPos, '\n', [], str)-    where-      go :: AlexInput -> [Token]-      go inp@(pos, _, _, str) =-               case alexScan inp 0 of-                AlexEOF                   -> []-                AlexError (pos, _, _, _)  -> [Err pos]-                AlexSkip  inp' len        -> go inp'-                AlexToken inp' len act    -> act pos (take len str) : (go inp')--alexGetByte :: AlexInput -> Maybe (Byte,AlexInput)-alexGetByte (p, c, (b:bs), s) = Just (b, (p, c, bs, s))-alexGetByte (p, _, [], s) =-  case  s of-    []  -> Nothing-    (c:s) ->-             let p'     = alexMove p c-                 (b:bs) = utf8Encode c-              in p' `seq` Just (b, (p', c, bs, s))--alexInputPrevChar :: AlexInput -> Char-alexInputPrevChar (p, c, bs, s) = c---- | Encode a Haskell String to a list of Word8 values, in UTF8 format.-utf8Encode :: Char -> [Word8]-utf8Encode = map fromIntegral . go . ord- where-  go oc-   | oc <= 0x7f       = [oc]--   | oc <= 0x7ff      = [ 0xc0 + (oc `Data.Bits.shiftR` 6)-                        , 0x80 + oc Data.Bits..&. 0x3f-                        ]--   | oc <= 0xffff     = [ 0xe0 + (oc `Data.Bits.shiftR` 12)-                        , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f)-                        , 0x80 + oc Data.Bits..&. 0x3f-                        ]-   | otherwise        = [ 0xf0 + (oc `Data.Bits.shiftR` 18)-                        , 0x80 + ((oc `Data.Bits.shiftR` 12) Data.Bits..&. 0x3f)-                        , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f)-                        , 0x80 + oc Data.Bits..&. 0x3f-                        ]--alex_action_3 =  tok (\p s -> PT p (eitherResIdent (TV . share) s)) -alex_action_4 =  tok (\p s -> PT p (eitherResIdent (TV . share) s)) -alex_action_5 =  tok (\p s -> PT p (TL $ share $ unescapeInitTail s)) -alex_action_6 =  tok (\p s -> PT p (TC $ share s))  -alex_action_7 =  tok (\p s -> PT p (TI $ share s))    -alex_action_8 =  tok (\p s -> PT p (TD $ share s)) -{-# LINE 1 "templates/GenericTemplate.hs" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}-{-# LINE 1 "<built-in>" #-}-{-# LINE 1 "<command-line>" #-}--------# 1 "/usr/include/stdc-predef.h" 1 3 4--# 17 "/usr/include/stdc-predef.h" 3 4------------------------{-# LINE 7 "<command-line>" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}--- -------------------------------------------------------------------------------- ALEX TEMPLATE------ This code is in the PUBLIC DOMAIN; you may copy it freely and use--- it for any purpose whatsoever.---- -------------------------------------------------------------------------------- INTERNALS and main scanner engine--{-# LINE 21 "templates/GenericTemplate.hs" #-}-------- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.-#if __GLASGOW_HASKELL__ > 706-#define GTE(n,m) (tagToEnum# (n >=# m))-#define EQ(n,m) (tagToEnum# (n ==# m))-#else-#define GTE(n,m) (n >=# m)-#define EQ(n,m) (n ==# m)-#endif-{-# LINE 51 "templates/GenericTemplate.hs" #-}---data AlexAddr = AlexA# Addr#--- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.-#if __GLASGOW_HASKELL__ < 503-uncheckedShiftL# = shiftL#-#endif--{-# INLINE alexIndexInt16OffAddr #-}-alexIndexInt16OffAddr (AlexA# arr) off =-#ifdef WORDS_BIGENDIAN-  narrow16Int# i-  where-        i    = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low)-        high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))-        low  = int2Word# (ord# (indexCharOffAddr# arr off'))-        off' = off *# 2#-#else-  indexInt16OffAddr# arr off-#endif------{-# INLINE alexIndexInt32OffAddr #-}-alexIndexInt32OffAddr (AlexA# arr) off = -#ifdef WORDS_BIGENDIAN-  narrow32Int# i-  where-   i    = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#`-		     (b2 `uncheckedShiftL#` 16#) `or#`-		     (b1 `uncheckedShiftL#` 8#) `or#` b0)-   b3   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#)))-   b2   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#)))-   b1   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))-   b0   = int2Word# (ord# (indexCharOffAddr# arr off'))-   off' = off *# 4#-#else-  indexInt32OffAddr# arr off-#endif-------#if __GLASGOW_HASKELL__ < 503-quickIndex arr i = arr ! i-#else--- GHC >= 503, unsafeAt is available from Data.Array.Base.-quickIndex = unsafeAt-#endif------- -------------------------------------------------------------------------------- Main lexing routines--data AlexReturn a-  = AlexEOF-  | AlexError  !AlexInput-  | AlexSkip   !AlexInput !Int-  | AlexToken  !AlexInput !Int a---- alexScan :: AlexInput -> StartCode -> AlexReturn a-alexScan input (I# (sc))-  = alexScanUser undefined input (I# (sc))--alexScanUser user input (I# (sc))-  = case alex_scan_tkn user input 0# input sc AlexNone of-	(AlexNone, input') ->-		case alexGetByte input of-			Nothing -> ----				   AlexEOF-			Just _ ->----				   AlexError input'--	(AlexLastSkip input'' len, _) ->----		AlexSkip input'' len--	(AlexLastAcc k input''' len, _) ->----		AlexToken input''' len k----- Push the input through the DFA, remembering the most recent accepting--- state it encountered.--alex_scan_tkn user orig_input len input s last_acc =-  input `seq` -- strict in the input-  let -	new_acc = (check_accs (alex_accept `quickIndex` (I# (s))))-  in-  new_acc `seq`-  case alexGetByte input of-     Nothing -> (new_acc, input)-     Just (c, new_input) -> ----      case fromIntegral c of { (I# (ord_c)) ->-        let-                base   = alexIndexInt32OffAddr alex_base s-                offset = (base +# ord_c)-                check  = alexIndexInt16OffAddr alex_check offset-		-                new_s = if GTE(offset,0#) && EQ(check,ord_c)-			  then alexIndexInt16OffAddr alex_table offset-			  else alexIndexInt16OffAddr alex_deflt s-	in-        case new_s of-	    -1# -> (new_acc, input)-		-- on an error, we want to keep the input *before* the-		-- character that failed, not after.-    	    _ -> alex_scan_tkn user orig_input (if c < 0x80 || c >= 0xC0 then (len +# 1#) else len)-                                                -- note that the length is increased ONLY if this is the 1st byte in a char encoding)-			new_input new_s new_acc-      }-  where-	check_accs (AlexAccNone) = last_acc-	check_accs (AlexAcc a  ) = AlexLastAcc a input (I# (len))-	check_accs (AlexAccSkip) = AlexLastSkip  input (I# (len))-{-# LINE 198 "templates/GenericTemplate.hs" #-}--data AlexLastAcc a-  = AlexNone-  | AlexLastAcc a !AlexInput !Int-  | AlexLastSkip  !AlexInput !Int--instance Functor AlexLastAcc where-    fmap f AlexNone = AlexNone-    fmap f (AlexLastAcc x y z) = AlexLastAcc (f x) y z-    fmap f (AlexLastSkip x y) = AlexLastSkip x y--data AlexAcc a user-  = AlexAccNone-  | AlexAcc a-  | AlexAccSkip-{-# LINE 242 "templates/GenericTemplate.hs" #-}---- used by wrappers-iUnbox (I# (i)) = i
− dist/build/bnfc/bnfc-tmp/ParBNF.hs
@@ -1,1751 +0,0 @@-{-# OPTIONS_GHC -w #-}-{-# OPTIONS -fglasgow-exts -cpp #-}-{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-}-module ParBNF where-import AbsBNF-import LexBNF-import ErrM-import qualified Data.Array as Happy_Data_Array-import qualified GHC.Exts as Happy_GHC_Exts-import Control.Applicative(Applicative(..))---- parser produced by Happy Version 1.19.4--newtype HappyAbsSyn  = HappyAbsSyn HappyAny-#if __GLASGOW_HASKELL__ >= 607-type HappyAny = Happy_GHC_Exts.Any-#else-type HappyAny = forall a . a-#endif-happyIn36 :: (String) -> (HappyAbsSyn )-happyIn36 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn36 #-}-happyOut36 :: (HappyAbsSyn ) -> (String)-happyOut36 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut36 #-}-happyIn37 :: (Ident) -> (HappyAbsSyn )-happyIn37 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn37 #-}-happyOut37 :: (HappyAbsSyn ) -> (Ident)-happyOut37 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut37 #-}-happyIn38 :: (Integer) -> (HappyAbsSyn )-happyIn38 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn38 #-}-happyOut38 :: (HappyAbsSyn ) -> (Integer)-happyOut38 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut38 #-}-happyIn39 :: (Char) -> (HappyAbsSyn )-happyIn39 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn39 #-}-happyOut39 :: (HappyAbsSyn ) -> (Char)-happyOut39 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut39 #-}-happyIn40 :: (Double) -> (HappyAbsSyn )-happyIn40 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn40 #-}-happyOut40 :: (HappyAbsSyn ) -> (Double)-happyOut40 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut40 #-}-happyIn41 :: (LGrammar) -> (HappyAbsSyn )-happyIn41 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn41 #-}-happyOut41 :: (HappyAbsSyn ) -> (LGrammar)-happyOut41 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut41 #-}-happyIn42 :: (LDef) -> (HappyAbsSyn )-happyIn42 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn42 #-}-happyOut42 :: (HappyAbsSyn ) -> (LDef)-happyOut42 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut42 #-}-happyIn43 :: ([LDef]) -> (HappyAbsSyn )-happyIn43 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn43 #-}-happyOut43 :: (HappyAbsSyn ) -> ([LDef])-happyOut43 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut43 #-}-happyIn44 :: (Grammar) -> (HappyAbsSyn )-happyIn44 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn44 #-}-happyOut44 :: (HappyAbsSyn ) -> (Grammar)-happyOut44 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut44 #-}-happyIn45 :: ([Def]) -> (HappyAbsSyn )-happyIn45 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn45 #-}-happyOut45 :: (HappyAbsSyn ) -> ([Def])-happyOut45 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut45 #-}-happyIn46 :: ([Item]) -> (HappyAbsSyn )-happyIn46 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn46 #-}-happyOut46 :: (HappyAbsSyn ) -> ([Item])-happyOut46 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut46 #-}-happyIn47 :: (Def) -> (HappyAbsSyn )-happyIn47 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn47 #-}-happyOut47 :: (HappyAbsSyn ) -> (Def)-happyOut47 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut47 #-}-happyIn48 :: (Item) -> (HappyAbsSyn )-happyIn48 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn48 #-}-happyOut48 :: (HappyAbsSyn ) -> (Item)-happyOut48 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut48 #-}-happyIn49 :: (Cat) -> (HappyAbsSyn )-happyIn49 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn49 #-}-happyOut49 :: (HappyAbsSyn ) -> (Cat)-happyOut49 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut49 #-}-happyIn50 :: (Label) -> (HappyAbsSyn )-happyIn50 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn50 #-}-happyOut50 :: (HappyAbsSyn ) -> (Label)-happyOut50 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut50 #-}-happyIn51 :: (LabelId) -> (HappyAbsSyn )-happyIn51 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn51 #-}-happyOut51 :: (HappyAbsSyn ) -> (LabelId)-happyOut51 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut51 #-}-happyIn52 :: (ProfItem) -> (HappyAbsSyn )-happyIn52 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn52 #-}-happyOut52 :: (HappyAbsSyn ) -> (ProfItem)-happyOut52 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut52 #-}-happyIn53 :: (IntList) -> (HappyAbsSyn )-happyIn53 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn53 #-}-happyOut53 :: (HappyAbsSyn ) -> (IntList)-happyOut53 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut53 #-}-happyIn54 :: ([Integer]) -> (HappyAbsSyn )-happyIn54 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn54 #-}-happyOut54 :: (HappyAbsSyn ) -> ([Integer])-happyOut54 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut54 #-}-happyIn55 :: ([IntList]) -> (HappyAbsSyn )-happyIn55 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn55 #-}-happyOut55 :: (HappyAbsSyn ) -> ([IntList])-happyOut55 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut55 #-}-happyIn56 :: ([ProfItem]) -> (HappyAbsSyn )-happyIn56 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn56 #-}-happyOut56 :: (HappyAbsSyn ) -> ([ProfItem])-happyOut56 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut56 #-}-happyIn57 :: (Separation) -> (HappyAbsSyn )-happyIn57 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn57 #-}-happyOut57 :: (HappyAbsSyn ) -> (Separation)-happyOut57 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut57 #-}-happyIn58 :: (Arg) -> (HappyAbsSyn )-happyIn58 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn58 #-}-happyOut58 :: (HappyAbsSyn ) -> (Arg)-happyOut58 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut58 #-}-happyIn59 :: ([Arg]) -> (HappyAbsSyn )-happyIn59 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn59 #-}-happyOut59 :: (HappyAbsSyn ) -> ([Arg])-happyOut59 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut59 #-}-happyIn60 :: (Exp) -> (HappyAbsSyn )-happyIn60 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn60 #-}-happyOut60 :: (HappyAbsSyn ) -> (Exp)-happyOut60 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut60 #-}-happyIn61 :: (Exp) -> (HappyAbsSyn )-happyIn61 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn61 #-}-happyOut61 :: (HappyAbsSyn ) -> (Exp)-happyOut61 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut61 #-}-happyIn62 :: (Exp) -> (HappyAbsSyn )-happyIn62 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn62 #-}-happyOut62 :: (HappyAbsSyn ) -> (Exp)-happyOut62 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut62 #-}-happyIn63 :: ([Exp]) -> (HappyAbsSyn )-happyIn63 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn63 #-}-happyOut63 :: (HappyAbsSyn ) -> ([Exp])-happyOut63 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut63 #-}-happyIn64 :: ([Exp]) -> (HappyAbsSyn )-happyIn64 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn64 #-}-happyOut64 :: (HappyAbsSyn ) -> ([Exp])-happyOut64 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut64 #-}-happyIn65 :: ([String]) -> (HappyAbsSyn )-happyIn65 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn65 #-}-happyOut65 :: (HappyAbsSyn ) -> ([String])-happyOut65 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut65 #-}-happyIn66 :: ([RHS]) -> (HappyAbsSyn )-happyIn66 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn66 #-}-happyOut66 :: (HappyAbsSyn ) -> ([RHS])-happyOut66 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut66 #-}-happyIn67 :: (RHS) -> (HappyAbsSyn )-happyIn67 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn67 #-}-happyOut67 :: (HappyAbsSyn ) -> (RHS)-happyOut67 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut67 #-}-happyIn68 :: (MinimumSize) -> (HappyAbsSyn )-happyIn68 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn68 #-}-happyOut68 :: (HappyAbsSyn ) -> (MinimumSize)-happyOut68 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut68 #-}-happyIn69 :: (Reg) -> (HappyAbsSyn )-happyIn69 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn69 #-}-happyOut69 :: (HappyAbsSyn ) -> (Reg)-happyOut69 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut69 #-}-happyIn70 :: (Reg) -> (HappyAbsSyn )-happyIn70 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn70 #-}-happyOut70 :: (HappyAbsSyn ) -> (Reg)-happyOut70 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut70 #-}-happyIn71 :: (Reg) -> (HappyAbsSyn )-happyIn71 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn71 #-}-happyOut71 :: (HappyAbsSyn ) -> (Reg)-happyOut71 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut71 #-}-happyIn72 :: (Reg) -> (HappyAbsSyn )-happyIn72 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn72 #-}-happyOut72 :: (HappyAbsSyn ) -> (Reg)-happyOut72 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut72 #-}-happyIn73 :: ([Ident]) -> (HappyAbsSyn )-happyIn73 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn73 #-}-happyOut73 :: (HappyAbsSyn ) -> ([Ident])-happyOut73 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut73 #-}-happyInTok :: (Token) -> (HappyAbsSyn )-happyInTok x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyInTok #-}-happyOutTok :: (HappyAbsSyn ) -> (Token)-happyOutTok x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOutTok #-}---happyActOffsets :: HappyAddr-happyActOffsets = HappyA# "\x45\x00\x45\x00\x45\x00\x64\x00\x64\x00\x00\x00\x64\x00\xbc\x00\xbd\x00\x71\x00\x71\x00\xda\x01\xd9\x01\xd8\x01\xd6\x01\xd7\x01\x7e\x01\xd5\x01\x00\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\xd4\x01\x00\x00\x00\x00\xd3\x01\x29\x00\x29\x00\x29\x00\x29\x00\xd2\x01\xcc\x01\x00\x00\xd1\x01\xcb\x01\x00\x00\x00\x00\x11\x00\xd0\x01\x89\x01\xc8\x01\x29\x00\xc9\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc9\x01\x00\x00\x3e\x00\xe2\xff\x01\x00\xc5\x01\x00\x00\xbc\x00\xc5\x01\xc5\x01\xc4\x01\xcf\x01\xc3\x01\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\xce\x01\xca\x01\x00\x00\xc2\x01\x07\x00\x07\x00\x00\x00\x00\x00\x00\x00\x07\x00\xc2\x01\xc2\x01\xc2\x01\xc2\x01\x6a\x01\x00\x00\xc2\x01\xc2\x01\xc1\x01\xc1\x01\xcd\x01\xbf\x01\xc0\x01\xc7\x01\xbe\x01\xbc\x01\xc6\x01\xba\x01\xba\x01\xba\x01\x00\x00\xba\x01\xbd\x01\xb9\x01\x00\x00\xb4\x01\x5e\x00\x00\x00\xb4\x01\xbd\x00\x00\x00\xb4\x01\x00\x00\xb4\x01\xbb\x01\xb6\x01\xb5\x01\xb3\x01\xbd\x00\xb3\x01\x44\x00\x68\x01\xaf\x01\xad\x01\xa8\x01\xa8\x01\xa6\x01\x7c\x00\x9c\x01\xb7\x01\x9b\x01\x00\x00\x8b\x00\xb0\x01\x9a\x01\x00\x00\xb8\x01\x99\x01\x98\x01\x98\x01\x00\x00\x00\x00\x64\x00\x45\x00\x93\x01\x64\x00\x00\x00\x29\x00\xbd\x00\xbd\x00\xb2\x01\x8e\x01\x00\x00\x96\x01\x00\x00\xae\x01\x00\x00\x95\x01\x00\x00\x95\x01\x91\x01\xbd\x00\xab\x01\xb1\x01\x00\x00\xfe\xff\x00\x00\x6e\x00\x84\x01\xa9\x01\xa7\x01\xa7\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa5\x01\xac\x01\x07\x00\x07\x00\x00\x00\x8d\x01\x00\x00\x10\x01\x29\x00\x00\x00\x00\x00\x00\x00\x85\x01\xa3\x01\xaa\x01\x29\x00\x29\x00\x00\x00\x00\x00\x00\x00\x29\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa2\x01\x00\x00\x00\x00\x00\x00\x00\x00\x9d\x01\x00\x00\x00\x00\xa1\x01\x00\x00\x00\x00\xf6\xff\x80\x01\xbd\x00\x00\x00\x29\x00\x00\x00\x80\x01\x80\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9e\x01\x7e\x01\x07\x00\x00\x00\xa4\x01\xa0\x01\x97\x01\x00\x00\xbc\x00\x00\x00\x8c\x01\x00\x00\xbc\x00\x00\x00\x78\x01\x94\x01\x9f\x01\x00\x00\x00\x00"#--happyGotoOffsets :: HappyAddr-happyGotoOffsets = HappyA# "\x86\x00\xa3\x00\xa1\x00\x58\x01\x6e\x01\x90\x01\x70\x01\x82\x01\x86\x01\x77\x01\x06\x00\x87\x01\x8f\x01\xb2\x00\x8b\x01\x48\x01\x74\x01\x0c\x00\x7f\x01\x30\x01\x4b\x01\x50\x01\x05\x01\xf6\x00\xc7\x00\x3c\x01\x31\x00\x3e\x01\xc0\x00\xb0\x00\x46\x00\xaa\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x9e\x00\x92\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8a\x01\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2b\x01\xd9\x00\x00\x00\x00\x00\x00\x00\xfb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x7a\x01\x6b\x01\x28\x01\x00\x00\x00\x00\x00\x00\x00\x00\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x01\x00\x00\x00\x00\x83\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x73\x01\x5d\x01\x56\x01\x61\x01\x22\x00\x72\x01\xc5\x00\x00\x00\x46\x01\x1d\x01\xfe\x00\x0b\x01\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5e\x01\x91\x00\x04\x00\x67\x01\x00\x00\x9a\x00\x35\x01\x0a\x01\x00\x00\xee\x00\x00\x00\x79\x00\x00\x00\x00\x00\x00\x00\xe9\x00\xfc\xff\xe0\x00\xce\x00\xe7\x00\x00\x00\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7d\x00\x00\x00\x88\x01\x24\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x26\x01\xd4\x00\x00\x00\x4b\x00\x37\x01\x00\x00\x39\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xcf\x00\x02\x00\x00\x00\x96\x00\x42\x00\xb5\x00\x4e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8e\x00\x21\x01\x94\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\x00\x00\x00\xec\xff\x13\x00\xde\x00\x00\x00\x72\x00\x00\x00\x00\x00\x00\x00\x00\x00"#--happyDefActions :: HappyAddr-happyDefActions = HappyA# "\xd5\xff\x00\x00\xd5\xff\xd1\xff\xd1\xff\xce\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xad\xff\xaa\xff\x00\x00\xa5\xff\x00\x00\xa1\xff\x00\x00\x00\x00\x00\x00\x00\x00\x92\xff\x00\x00\xce\xff\xce\xff\x89\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xff\x75\xff\x00\x00\xdd\xff\x7f\xff\x84\xff\x76\xff\x87\xff\x00\x00\x00\x00\x00\x00\x78\xff\x7c\xff\x80\xff\x7b\xff\x79\xff\x7a\xff\x00\x00\xdb\xff\x00\x00\x00\x00\x00\x00\x00\x00\x8a\xff\x8b\xff\x00\x00\x00\x00\x8d\xff\x8f\xff\x00\x00\x98\xff\x9b\xff\x9a\xff\x99\xff\x97\xff\x91\xff\x9e\xff\x9c\xff\x00\x00\x00\x00\x92\xff\xdc\xff\xda\xff\x9b\xff\x94\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa2\xff\x00\x00\x00\x00\x00\x00\x00\x00\xa7\xff\x00\x00\x00\x00\xa9\xff\x00\x00\xad\xff\xac\xff\x00\x00\x00\x00\x00\x00\xb4\xff\x00\x00\x00\x00\x00\x00\xb3\xff\x00\x00\xb8\xff\xb9\xff\x00\x00\x00\x00\xbc\xff\x00\x00\xbb\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x89\xff\x89\xff\x00\x00\x00\x00\x00\x00\xd0\xff\x00\x00\xd2\xff\xb4\xff\xd4\xff\x00\x00\xd8\xff\x00\x00\x00\x00\x00\x00\x00\x00\xd9\xff\xd6\xff\x00\x00\xd5\xff\x00\x00\xd1\xff\xcd\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbf\xff\x00\x00\xbd\xff\x00\x00\xc6\xff\x00\x00\xa1\xff\xcb\xff\x00\x00\x00\x00\x00\x00\xb5\xff\xb7\xff\x00\x00\xb2\xff\x00\x00\xad\xff\x00\x00\xaa\xff\xaa\xff\xa6\xff\xa4\xff\xa3\xff\xa0\xff\x93\xff\x00\x00\x00\x00\x00\x00\x92\xff\x9d\xff\x00\x00\xce\xff\x88\xff\x00\x00\x83\xff\x82\xff\x81\xff\x00\x00\x00\x00\x00\x00\x00\x00\x85\xff\x77\xff\x7e\xff\x7d\xff\x86\xff\x8c\xff\x8e\xff\x90\xff\x9f\xff\x95\xff\x96\xff\x00\x00\xa8\xff\xae\xff\xab\xff\xb1\xff\x00\x00\xb6\xff\xba\xff\x00\x00\xc2\xff\xca\xff\x00\x00\x00\x00\x00\x00\xbe\xff\x00\x00\xce\xff\x00\x00\x00\x00\xc8\xff\xcf\xff\x74\xff\xd3\xff\xd7\xff\xc4\xff\xc5\xff\xc1\xff\xc7\xff\x00\x00\xa5\xff\x00\x00\xce\xff\x00\x00\x00\x00\x00\x00\xb0\xff\xcc\xff\xc0\xff\x89\xff\xce\xff\xc9\xff\xc3\xff\xad\xff\x00\x00\x00\x00\xaf\xff"#--happyCheck :: HappyAddr-happyCheck = HappyA# "\xff\xff\x0b\x00\x01\x00\x01\x00\x01\x00\x01\x00\x08\x00\x01\x00\x01\x00\x27\x00\x01\x00\x0d\x00\x20\x00\x01\x00\x0d\x00\x0d\x00\x2e\x00\x10\x00\x01\x00\x17\x00\x0d\x00\x0f\x00\x15\x00\x06\x00\x17\x00\x16\x00\x03\x00\x1a\x00\x1b\x00\x0a\x00\x0d\x00\x03\x00\x2a\x00\x10\x00\x16\x00\x01\x00\x01\x00\x24\x00\x15\x00\x26\x00\x17\x00\x25\x00\x01\x00\x1a\x00\x1b\x00\x2c\x00\x25\x00\x2e\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x24\x00\x0d\x00\x26\x00\x21\x00\x10\x00\x23\x00\x0a\x00\x03\x00\x2c\x00\x15\x00\x23\x00\x17\x00\x03\x00\x04\x00\x1a\x00\x1b\x00\x01\x00\x01\x00\x25\x00\x25\x00\x03\x00\x0c\x00\x00\x00\x0a\x00\x24\x00\x00\x00\x26\x00\x1f\x00\x0d\x00\x0d\x00\x0f\x00\x0f\x00\x2c\x00\x11\x00\x12\x00\x13\x00\x14\x00\x21\x00\x16\x00\x23\x00\x18\x00\x19\x00\x01\x00\x1e\x00\x1f\x00\x1d\x00\x1e\x00\x1f\x00\x01\x00\x21\x00\x22\x00\x1d\x00\x23\x00\x25\x00\x0d\x00\x2e\x00\x0f\x00\x2a\x00\x2a\x00\x02\x00\x0d\x00\x01\x00\x0f\x00\x02\x00\x11\x00\x12\x00\x13\x00\x14\x00\x00\x00\x16\x00\x0d\x00\x18\x00\x19\x00\x0d\x00\x02\x00\x0f\x00\x1d\x00\x1e\x00\x1f\x00\x12\x00\x21\x00\x22\x00\x01\x00\x2a\x00\x0d\x00\x02\x00\x05\x00\x06\x00\x07\x00\x2a\x00\x12\x00\x05\x00\x0b\x00\x01\x00\x08\x00\x0e\x00\x0f\x00\x1d\x00\x06\x00\x07\x00\x03\x00\x12\x00\x2a\x00\x0b\x00\x03\x00\x0a\x00\x0e\x00\x0f\x00\x03\x00\x01\x00\x15\x00\x01\x00\x29\x00\x2a\x00\x06\x00\x07\x00\x06\x00\x2e\x00\x25\x00\x0b\x00\x03\x00\x0b\x00\x0e\x00\x0f\x00\x0e\x00\x0f\x00\x03\x00\x02\x00\x00\x00\x25\x00\x21\x00\x22\x00\x23\x00\x24\x00\x21\x00\x22\x00\x23\x00\x24\x00\x21\x00\x22\x00\x23\x00\x24\x00\x03\x00\x12\x00\x00\x00\x25\x00\x00\x00\x25\x00\x0d\x00\x0d\x00\x21\x00\x22\x00\x23\x00\x24\x00\x00\x00\x02\x00\x21\x00\x22\x00\x23\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x00\x00\x21\x00\x1d\x00\x23\x00\x1d\x00\x29\x00\x2a\x00\x2a\x00\x01\x00\x00\x00\x0c\x00\x0d\x00\x18\x00\x19\x00\x1a\x00\x01\x00\x1c\x00\x18\x00\x19\x00\x1a\x00\x0d\x00\x1c\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x01\x00\x01\x00\x01\x00\x10\x00\x18\x00\x19\x00\x1a\x00\x14\x00\x1c\x00\x03\x00\x04\x00\x1a\x00\x1b\x00\x0d\x00\x0f\x00\x10\x00\x1a\x00\x1b\x00\x0c\x00\x14\x00\x20\x00\x1a\x00\x1b\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x11\x00\x01\x00\x13\x00\x10\x00\x18\x00\x19\x00\x1a\x00\x14\x00\x20\x00\x18\x00\x19\x00\x1a\x00\x0a\x00\x0d\x00\x18\x00\x19\x00\x1a\x00\x0a\x00\x01\x00\x18\x00\x19\x00\x1a\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x1e\x00\x1f\x00\x01\x00\x10\x00\x01\x00\x1e\x00\x1f\x00\x14\x00\x00\x00\x20\x00\x01\x00\x08\x00\x09\x00\x01\x00\x0b\x00\x19\x00\x1a\x00\x0e\x00\x0f\x00\x01\x00\x0b\x00\x1a\x00\x00\x00\x0e\x00\x0f\x00\x0d\x00\x01\x00\x09\x00\x01\x00\x0b\x00\x01\x00\x01\x00\x0e\x00\x0f\x00\x09\x00\x01\x00\x0b\x00\x00\x00\x0b\x00\x0e\x00\x0f\x00\x0e\x00\x0f\x00\x0e\x00\x0f\x00\x00\x00\x01\x00\x01\x00\x0e\x00\x0f\x00\x01\x00\x20\x00\x15\x00\x00\x00\x23\x00\x03\x00\x04\x00\x0c\x00\x0d\x00\x0d\x00\x29\x00\x00\x00\x0d\x00\x2a\x00\x0c\x00\x17\x00\x10\x00\x2e\x00\x11\x00\x0a\x00\x13\x00\x11\x00\x1f\x00\x13\x00\x21\x00\x11\x00\x02\x00\x0e\x00\x2b\x00\x0d\x00\x05\x00\x02\x00\x09\x00\x1c\x00\x29\x00\x09\x00\x0e\x00\x02\x00\x28\x00\x02\x00\x2b\x00\x0e\x00\x0e\x00\x01\x00\x0e\x00\x0d\x00\x07\x00\x29\x00\x0e\x00\x2a\x00\x0e\x00\x0a\x00\x09\x00\x2b\x00\x2a\x00\x29\x00\x29\x00\x08\x00\x0a\x00\x07\x00\x2a\x00\x1c\x00\x08\x00\x2e\x00\x0e\x00\x2e\x00\x2e\x00\x2e\x00\x05\x00\x05\x00\x0d\x00\x01\x00\xff\xff\x2a\x00\x22\x00\x08\x00\x05\x00\x05\x00\xff\xff\x05\x00\x2a\x00\x01\x00\xff\xff\xff\xff\x01\x00\xff\xff\x2a\x00\x29\x00\xff\xff\x2a\x00\xff\xff\x2e\x00\x0d\x00\xff\xff\xff\xff\x0d\x00\x2b\x00\x2e\x00\xff\xff\x29\x00\x27\x00\x2e\x00\x2e\x00\xff\xff\x1c\x00\x2e\x00\x2e\x00\x29\x00\x2e\x00\xff\xff\x29\x00\x2e\x00\x27\x00\xff\xff\x2e\x00\xff\xff\xff\xff\x2a\x00\x29\x00\xff\xff\x2a\x00\xff\xff\xff\xff\xff\xff\x2b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#--happyTable :: HappyAddr-happyTable = HappyA# "\x00\x00\xea\x00\x2c\x00\x6a\x00\x54\x00\x23\x00\xa7\x00\x63\x00\x4a\x00\xb9\x00\x23\x00\xab\x00\xf4\x00\x54\x00\x2d\x00\xe7\x00\xff\xff\x2e\x00\x2c\x00\xd6\x00\x4b\x00\x64\x00\x2f\x00\xc0\x00\x30\x00\xae\x00\x26\x00\x31\x00\x32\x00\xf3\x00\x2d\x00\x26\x00\x26\x00\x2e\x00\x55\x00\x23\x00\x23\x00\x33\x00\x2f\x00\x34\x00\x30\x00\xe0\x00\x2c\x00\x31\x00\x32\x00\x35\x00\x8c\x00\xff\xff\x23\x00\x26\x00\x4c\x00\x35\x00\x4d\x00\x33\x00\x2d\x00\x34\x00\xc0\x00\x2e\x00\x29\x00\x3a\x00\x26\x00\x35\x00\x2f\x00\xb7\x00\x30\x00\xba\x00\xbb\x00\x31\x00\x32\x00\x66\x00\x66\x00\x9b\x00\x24\x00\x26\x00\xbc\x00\x3e\x00\x3a\x00\x33\x00\xe3\x00\x34\x00\x3b\x00\x67\x00\x67\x00\x68\x00\x68\x00\x35\x00\x73\x00\x74\x00\x75\x00\x76\x00\xc4\x00\x77\x00\x29\x00\x78\x00\x79\x00\xa5\x00\xe5\x00\x3d\x00\x7a\x00\x7b\x00\x7c\x00\x66\x00\x7d\x00\x7e\x00\xc6\x00\x35\x00\x89\x00\x67\x00\xff\xff\x68\x00\x26\x00\x26\x00\xd0\x00\x67\x00\x66\x00\x68\x00\x5f\x00\x73\x00\x74\x00\x75\x00\x76\x00\x3e\x00\x77\x00\xd1\x00\x78\x00\x79\x00\x67\x00\x5f\x00\x68\x00\x7a\x00\x7b\x00\x7c\x00\xf6\x00\x7d\x00\x7e\x00\x83\x00\x26\x00\x6d\x00\x5f\x00\x8a\x00\x84\x00\x8b\x00\x26\x00\xce\x00\x90\x00\x86\x00\x83\x00\x75\xff\x71\x00\x69\x00\xd9\x00\x84\x00\xe1\x00\x26\x00\xa8\x00\x26\x00\x86\x00\x26\x00\xef\x00\x71\x00\x69\x00\x26\x00\x83\x00\xf1\x00\x83\x00\x23\x00\x26\x00\x84\x00\x85\x00\x89\x00\xff\xff\x87\x00\x86\x00\x26\x00\x86\x00\x71\x00\x69\x00\x71\x00\x69\x00\x26\x00\x5f\x00\xe4\x00\x87\x00\x27\x00\x28\x00\x29\x00\xe6\x00\x27\x00\x28\x00\x29\x00\xde\x00\x27\x00\x28\x00\x29\x00\xbe\x00\x26\x00\x60\x00\x3e\x00\x87\x00\x3e\x00\x87\x00\x6d\x00\x6d\x00\x27\x00\x28\x00\x29\x00\x2a\x00\xe8\x00\xd4\x00\x27\x00\x36\x00\x29\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x6d\x00\x6a\x00\xd5\x00\x37\x00\x97\x00\x29\x00\x3f\x00\x23\x00\x26\x00\x26\x00\x6a\x00\xd7\x00\x91\x00\x6f\x00\x45\x00\x46\x00\x47\x00\xda\x00\xc7\x00\x45\x00\x46\x00\x47\x00\xd3\x00\xb0\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x4d\x00\x42\x00\x43\x00\x44\x00\x40\x00\x4d\x00\x42\x00\x43\x00\x44\x00\x40\x00\x4d\x00\x42\x00\x43\x00\x44\x00\x63\x00\x6a\x00\x92\x00\x59\x00\x45\x00\x46\x00\x47\x00\xd1\x00\x48\x00\xba\x00\xbb\x00\x4e\x00\xaf\x00\xdc\x00\xa2\x00\x59\x00\x4e\x00\xb4\x00\xbc\x00\xa3\x00\x93\x00\x4e\x00\x4f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x5c\x00\x6a\x00\xcb\x00\x59\x00\xf0\x00\x46\x00\x47\x00\xab\x00\x94\x00\xc8\x00\x46\x00\x47\x00\x3a\x00\xdd\x00\xb1\x00\x46\x00\x47\x00\x3a\x00\x95\x00\x52\x00\x46\x00\x47\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x4d\x00\x42\x00\x43\x00\x44\x00\xc5\x00\x3d\x00\x9d\x00\x59\x00\x63\x00\x3c\x00\x3d\x00\x5a\x00\x9e\x00\x38\x00\x63\x00\x81\x00\x82\x00\x6a\x00\x80\x00\x51\x00\x47\x00\x71\x00\x69\x00\x63\x00\xe2\x00\x50\x00\xac\x00\x71\x00\x69\x00\x9c\x00\x63\x00\xdf\x00\x63\x00\x80\x00\x63\x00\x9f\x00\x71\x00\x69\x00\x7f\x00\x63\x00\x80\x00\xad\x00\x70\x00\x71\x00\x69\x00\x71\x00\x69\x00\x9a\x00\x69\x00\x6d\x00\x6a\x00\x6a\x00\x68\x00\x69\x00\x6a\x00\x99\x00\x56\x00\xbc\x00\x9a\x00\xba\x00\xbb\x00\x6e\x00\x6f\x00\xa1\x00\x23\x00\xbd\x00\x6b\x00\x26\x00\xbc\x00\x53\x00\x62\x00\xff\xff\x5c\x00\x7e\x00\xcc\x00\x5c\x00\x58\x00\x5d\x00\x59\x00\x61\x00\xf9\x00\xf8\x00\x4c\x00\xf6\x00\xee\x00\xef\x00\xf3\x00\x3a\x00\x23\x00\xeb\x00\xec\x00\xc2\x00\xc4\x00\xca\x00\x4c\x00\xed\x00\xc3\x00\x5c\x00\xcb\x00\x5f\x00\xd9\x00\x23\x00\xce\x00\x26\x00\xd3\x00\x8f\x00\xdc\x00\x4c\x00\x26\x00\x23\x00\x23\x00\x8e\x00\x91\x00\xa1\x00\x26\x00\x3a\x00\xa7\x00\xff\xff\xa6\x00\xff\xff\xff\xff\xff\xff\xa8\x00\xaa\x00\xab\x00\x5c\x00\x00\x00\x26\x00\x97\x00\xb3\x00\xb4\x00\xb6\x00\x00\x00\x90\x00\x26\x00\x5c\x00\x00\x00\x00\x00\x5c\x00\x00\x00\x26\x00\x23\x00\x00\x00\x26\x00\x00\x00\xff\xff\x5f\x00\x00\x00\x00\x00\x5f\x00\x4c\x00\xff\xff\x00\x00\x23\x00\xb7\x00\xff\xff\xff\xff\x00\x00\x3a\x00\xff\xff\xff\xff\x23\x00\xff\xff\x00\x00\x23\x00\xff\xff\xb9\x00\x00\x00\xff\xff\x00\x00\x00\x00\x26\x00\x23\x00\x00\x00\x26\x00\x00\x00\x00\x00\x00\x00\x4c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#--happyReduceArr = Happy_Data_Array.array (33, 139) [-	(33 , happyReduce_33),-	(34 , happyReduce_34),-	(35 , happyReduce_35),-	(36 , happyReduce_36),-	(37 , happyReduce_37),-	(38 , happyReduce_38),-	(39 , happyReduce_39),-	(40 , happyReduce_40),-	(41 , happyReduce_41),-	(42 , happyReduce_42),-	(43 , happyReduce_43),-	(44 , happyReduce_44),-	(45 , happyReduce_45),-	(46 , happyReduce_46),-	(47 , happyReduce_47),-	(48 , happyReduce_48),-	(49 , happyReduce_49),-	(50 , happyReduce_50),-	(51 , happyReduce_51),-	(52 , happyReduce_52),-	(53 , happyReduce_53),-	(54 , happyReduce_54),-	(55 , happyReduce_55),-	(56 , happyReduce_56),-	(57 , happyReduce_57),-	(58 , happyReduce_58),-	(59 , happyReduce_59),-	(60 , happyReduce_60),-	(61 , happyReduce_61),-	(62 , happyReduce_62),-	(63 , happyReduce_63),-	(64 , happyReduce_64),-	(65 , happyReduce_65),-	(66 , happyReduce_66),-	(67 , happyReduce_67),-	(68 , happyReduce_68),-	(69 , happyReduce_69),-	(70 , happyReduce_70),-	(71 , happyReduce_71),-	(72 , happyReduce_72),-	(73 , happyReduce_73),-	(74 , happyReduce_74),-	(75 , happyReduce_75),-	(76 , happyReduce_76),-	(77 , happyReduce_77),-	(78 , happyReduce_78),-	(79 , happyReduce_79),-	(80 , happyReduce_80),-	(81 , happyReduce_81),-	(82 , happyReduce_82),-	(83 , happyReduce_83),-	(84 , happyReduce_84),-	(85 , happyReduce_85),-	(86 , happyReduce_86),-	(87 , happyReduce_87),-	(88 , happyReduce_88),-	(89 , happyReduce_89),-	(90 , happyReduce_90),-	(91 , happyReduce_91),-	(92 , happyReduce_92),-	(93 , happyReduce_93),-	(94 , happyReduce_94),-	(95 , happyReduce_95),-	(96 , happyReduce_96),-	(97 , happyReduce_97),-	(98 , happyReduce_98),-	(99 , happyReduce_99),-	(100 , happyReduce_100),-	(101 , happyReduce_101),-	(102 , happyReduce_102),-	(103 , happyReduce_103),-	(104 , happyReduce_104),-	(105 , happyReduce_105),-	(106 , happyReduce_106),-	(107 , happyReduce_107),-	(108 , happyReduce_108),-	(109 , happyReduce_109),-	(110 , happyReduce_110),-	(111 , happyReduce_111),-	(112 , happyReduce_112),-	(113 , happyReduce_113),-	(114 , happyReduce_114),-	(115 , happyReduce_115),-	(116 , happyReduce_116),-	(117 , happyReduce_117),-	(118 , happyReduce_118),-	(119 , happyReduce_119),-	(120 , happyReduce_120),-	(121 , happyReduce_121),-	(122 , happyReduce_122),-	(123 , happyReduce_123),-	(124 , happyReduce_124),-	(125 , happyReduce_125),-	(126 , happyReduce_126),-	(127 , happyReduce_127),-	(128 , happyReduce_128),-	(129 , happyReduce_129),-	(130 , happyReduce_130),-	(131 , happyReduce_131),-	(132 , happyReduce_132),-	(133 , happyReduce_133),-	(134 , happyReduce_134),-	(135 , happyReduce_135),-	(136 , happyReduce_136),-	(137 , happyReduce_137),-	(138 , happyReduce_138),-	(139 , happyReduce_139)-	]--happy_n_terms = 47 :: Int-happy_n_nonterms = 38 :: Int--happyReduce_33 = happySpecReduce_1  0# happyReduction_33-happyReduction_33 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TL happy_var_1)) -> -	happyIn36-		 (happy_var_1-	)}--happyReduce_34 = happySpecReduce_1  1# happyReduction_34-happyReduction_34 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TV happy_var_1)) -> -	happyIn37-		 (Ident happy_var_1-	)}--happyReduce_35 = happySpecReduce_1  2# happyReduction_35-happyReduction_35 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TI happy_var_1)) -> -	happyIn38-		 ((read ( happy_var_1)) :: Integer-	)}--happyReduce_36 = happySpecReduce_1  3# happyReduction_36-happyReduction_36 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TC happy_var_1)) -> -	happyIn39-		 ((read ( happy_var_1)) :: Char-	)}--happyReduce_37 = happySpecReduce_1  4# happyReduction_37-happyReduction_37 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TD happy_var_1)) -> -	happyIn40-		 ((read ( happy_var_1)) :: Double-	)}--happyReduce_38 = happySpecReduce_1  5# happyReduction_38-happyReduction_38 happy_x_1-	 =  case happyOut43 happy_x_1 of { happy_var_1 -> -	happyIn41-		 (LGr happy_var_1-	)}--happyReduce_39 = happySpecReduce_1  6# happyReduction_39-happyReduction_39 happy_x_1-	 =  case happyOut47 happy_x_1 of { happy_var_1 -> -	happyIn42-		 (DefAll happy_var_1-	)}--happyReduce_40 = happySpecReduce_3  6# happyReduction_40-happyReduction_40 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut73 happy_x_1 of { happy_var_1 -> -	case happyOut47 happy_x_3 of { happy_var_3 -> -	happyIn42-		 (DefSome happy_var_1 happy_var_3-	)}}--happyReduce_41 = happySpecReduce_2  6# happyReduction_41-happyReduction_41 happy_x_2-	happy_x_1-	 =  case happyOut73 happy_x_2 of { happy_var_2 -> -	happyIn42-		 (LDefView happy_var_2-	)}--happyReduce_42 = happySpecReduce_0  7# happyReduction_42-happyReduction_42  =  happyIn43-		 ([]-	)--happyReduce_43 = happySpecReduce_1  7# happyReduction_43-happyReduction_43 happy_x_1-	 =  case happyOut42 happy_x_1 of { happy_var_1 -> -	happyIn43-		 ((:[]) happy_var_1-	)}--happyReduce_44 = happySpecReduce_3  7# happyReduction_44-happyReduction_44 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut42 happy_x_1 of { happy_var_1 -> -	case happyOut43 happy_x_3 of { happy_var_3 -> -	happyIn43-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_45 = happySpecReduce_1  8# happyReduction_45-happyReduction_45 happy_x_1-	 =  case happyOut45 happy_x_1 of { happy_var_1 -> -	happyIn44-		 (Grammar happy_var_1-	)}--happyReduce_46 = happySpecReduce_0  9# happyReduction_46-happyReduction_46  =  happyIn45-		 ([]-	)--happyReduce_47 = happySpecReduce_1  9# happyReduction_47-happyReduction_47 happy_x_1-	 =  case happyOut47 happy_x_1 of { happy_var_1 -> -	happyIn45-		 ((:[]) happy_var_1-	)}--happyReduce_48 = happySpecReduce_3  9# happyReduction_48-happyReduction_48 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut47 happy_x_1 of { happy_var_1 -> -	case happyOut45 happy_x_3 of { happy_var_3 -> -	happyIn45-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_49 = happySpecReduce_0  10# happyReduction_49-happyReduction_49  =  happyIn46-		 ([]-	)--happyReduce_50 = happySpecReduce_2  10# happyReduction_50-happyReduction_50 happy_x_2-	happy_x_1-	 =  case happyOut46 happy_x_1 of { happy_var_1 -> -	case happyOut48 happy_x_2 of { happy_var_2 -> -	happyIn46-		 (flip (:) happy_var_1 happy_var_2-	)}}--happyReduce_51 = happyReduce 5# 11# happyReduction_51-happyReduction_51 (happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut50 happy_x_1 of { happy_var_1 -> -	case happyOut49 happy_x_3 of { happy_var_3 -> -	case happyOut46 happy_x_5 of { happy_var_5 -> -	happyIn47-		 (Rule happy_var_1 happy_var_3 (reverse happy_var_5)-	) `HappyStk` happyRest}}}--happyReduce_52 = happySpecReduce_2  11# happyReduction_52-happyReduction_52 happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn47-		 (Comment happy_var_2-	)}--happyReduce_53 = happySpecReduce_3  11# happyReduction_53-happyReduction_53 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	case happyOut36 happy_x_3 of { happy_var_3 -> -	happyIn47-		 (Comments happy_var_2 happy_var_3-	)}}--happyReduce_54 = happyReduce 6# 11# happyReduction_54-happyReduction_54 (happy_x_6 `HappyStk`-	happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut50 happy_x_2 of { happy_var_2 -> -	case happyOut49 happy_x_4 of { happy_var_4 -> -	case happyOut46 happy_x_6 of { happy_var_6 -> -	happyIn47-		 (Internal happy_var_2 happy_var_4 (reverse happy_var_6)-	) `HappyStk` happyRest}}}--happyReduce_55 = happySpecReduce_3  11# happyReduction_55-happyReduction_55 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut37 happy_x_2 of { happy_var_2 -> -	case happyOut72 happy_x_3 of { happy_var_3 -> -	happyIn47-		 (Token happy_var_2 happy_var_3-	)}}--happyReduce_56 = happyReduce 4# 11# happyReduction_56-happyReduction_56 (happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut37 happy_x_3 of { happy_var_3 -> -	case happyOut72 happy_x_4 of { happy_var_4 -> -	happyIn47-		 (PosToken happy_var_3 happy_var_4-	) `HappyStk` happyRest}}--happyReduce_57 = happySpecReduce_2  11# happyReduction_57-happyReduction_57 happy_x_2-	happy_x_1-	 =  case happyOut73 happy_x_2 of { happy_var_2 -> -	happyIn47-		 (Entryp happy_var_2-	)}--happyReduce_58 = happyReduce 4# 11# happyReduction_58-happyReduction_58 (happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut68 happy_x_2 of { happy_var_2 -> -	case happyOut49 happy_x_3 of { happy_var_3 -> -	case happyOut36 happy_x_4 of { happy_var_4 -> -	happyIn47-		 (Separator happy_var_2 happy_var_3 happy_var_4-	) `HappyStk` happyRest}}}--happyReduce_59 = happyReduce 4# 11# happyReduction_59-happyReduction_59 (happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut68 happy_x_2 of { happy_var_2 -> -	case happyOut49 happy_x_3 of { happy_var_3 -> -	case happyOut36 happy_x_4 of { happy_var_4 -> -	happyIn47-		 (Terminator happy_var_2 happy_var_3 happy_var_4-	) `HappyStk` happyRest}}}--happyReduce_60 = happyReduce 6# 11# happyReduction_60-happyReduction_60 (happy_x_6 `HappyStk`-	happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut49 happy_x_2 of { happy_var_2 -> -	case happyOut36 happy_x_3 of { happy_var_3 -> -	case happyOut36 happy_x_4 of { happy_var_4 -> -	case happyOut57 happy_x_5 of { happy_var_5 -> -	case happyOut68 happy_x_6 of { happy_var_6 -> -	happyIn47-		 (Delimiters happy_var_2 happy_var_3 happy_var_4 happy_var_5 happy_var_6-	) `HappyStk` happyRest}}}}}--happyReduce_61 = happySpecReduce_3  11# happyReduction_61-happyReduction_61 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut37 happy_x_2 of { happy_var_2 -> -	case happyOut38 happy_x_3 of { happy_var_3 -> -	happyIn47-		 (Coercions happy_var_2 happy_var_3-	)}}--happyReduce_62 = happyReduce 4# 11# happyReduction_62-happyReduction_62 (happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut37 happy_x_2 of { happy_var_2 -> -	case happyOut66 happy_x_4 of { happy_var_4 -> -	happyIn47-		 (Rules happy_var_2 happy_var_4-	) `HappyStk` happyRest}}--happyReduce_63 = happyReduce 5# 11# happyReduction_63-happyReduction_63 (happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut37 happy_x_2 of { happy_var_2 -> -	case happyOut59 happy_x_3 of { happy_var_3 -> -	case happyOut60 happy_x_5 of { happy_var_5 -> -	happyIn47-		 (Function happy_var_2 (reverse happy_var_3) happy_var_5-	) `HappyStk` happyRest}}}--happyReduce_64 = happySpecReduce_2  11# happyReduction_64-happyReduction_64 happy_x_2-	happy_x_1-	 =  case happyOut65 happy_x_2 of { happy_var_2 -> -	happyIn47-		 (Layout happy_var_2-	)}--happyReduce_65 = happySpecReduce_3  11# happyReduction_65-happyReduction_65 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut65 happy_x_3 of { happy_var_3 -> -	happyIn47-		 (LayoutStop happy_var_3-	)}--happyReduce_66 = happySpecReduce_2  11# happyReduction_66-happyReduction_66 happy_x_2-	happy_x_1-	 =  happyIn47-		 (LayoutTop-	)--happyReduce_67 = happySpecReduce_1  12# happyReduction_67-happyReduction_67 happy_x_1-	 =  case happyOut36 happy_x_1 of { happy_var_1 -> -	happyIn48-		 (Terminal happy_var_1-	)}--happyReduce_68 = happySpecReduce_1  12# happyReduction_68-happyReduction_68 happy_x_1-	 =  case happyOut49 happy_x_1 of { happy_var_1 -> -	happyIn48-		 (NTerminal happy_var_1-	)}--happyReduce_69 = happySpecReduce_3  13# happyReduction_69-happyReduction_69 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut49 happy_x_2 of { happy_var_2 -> -	happyIn49-		 (ListCat happy_var_2-	)}--happyReduce_70 = happySpecReduce_1  13# happyReduction_70-happyReduction_70 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn49-		 (IdCat happy_var_1-	)}--happyReduce_71 = happySpecReduce_1  14# happyReduction_71-happyReduction_71 happy_x_1-	 =  case happyOut51 happy_x_1 of { happy_var_1 -> -	happyIn50-		 (LabNoP happy_var_1-	)}--happyReduce_72 = happySpecReduce_2  14# happyReduction_72-happyReduction_72 happy_x_2-	happy_x_1-	 =  case happyOut51 happy_x_1 of { happy_var_1 -> -	case happyOut56 happy_x_2 of { happy_var_2 -> -	happyIn50-		 (LabP happy_var_1 happy_var_2-	)}}--happyReduce_73 = happySpecReduce_3  14# happyReduction_73-happyReduction_73 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut51 happy_x_1 of { happy_var_1 -> -	case happyOut51 happy_x_2 of { happy_var_2 -> -	case happyOut56 happy_x_3 of { happy_var_3 -> -	happyIn50-		 (LabPF happy_var_1 happy_var_2 happy_var_3-	)}}}--happyReduce_74 = happySpecReduce_2  14# happyReduction_74-happyReduction_74 happy_x_2-	happy_x_1-	 =  case happyOut51 happy_x_1 of { happy_var_1 -> -	case happyOut51 happy_x_2 of { happy_var_2 -> -	happyIn50-		 (LabF happy_var_1 happy_var_2-	)}}--happyReduce_75 = happySpecReduce_1  15# happyReduction_75-happyReduction_75 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn51-		 (Id happy_var_1-	)}--happyReduce_76 = happySpecReduce_1  15# happyReduction_76-happyReduction_76 happy_x_1-	 =  happyIn51-		 (Wild-	)--happyReduce_77 = happySpecReduce_2  15# happyReduction_77-happyReduction_77 happy_x_2-	happy_x_1-	 =  happyIn51-		 (ListE-	)--happyReduce_78 = happySpecReduce_3  15# happyReduction_78-happyReduction_78 happy_x_3-	happy_x_2-	happy_x_1-	 =  happyIn51-		 (ListCons-	)--happyReduce_79 = happyReduce 5# 15# happyReduction_79-happyReduction_79 (happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = happyIn51-		 (ListOne-	) `HappyStk` happyRest--happyReduce_80 = happyReduce 9# 16# happyReduction_80-happyReduction_80 (happy_x_9 `HappyStk`-	happy_x_8 `HappyStk`-	happy_x_7 `HappyStk`-	happy_x_6 `HappyStk`-	happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut55 happy_x_3 of { happy_var_3 -> -	case happyOut54 happy_x_7 of { happy_var_7 -> -	happyIn52-		 (ProfIt happy_var_3 happy_var_7-	) `HappyStk` happyRest}}--happyReduce_81 = happySpecReduce_3  17# happyReduction_81-happyReduction_81 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut54 happy_x_2 of { happy_var_2 -> -	happyIn53-		 (Ints happy_var_2-	)}--happyReduce_82 = happySpecReduce_0  18# happyReduction_82-happyReduction_82  =  happyIn54-		 ([]-	)--happyReduce_83 = happySpecReduce_1  18# happyReduction_83-happyReduction_83 happy_x_1-	 =  case happyOut38 happy_x_1 of { happy_var_1 -> -	happyIn54-		 ((:[]) happy_var_1-	)}--happyReduce_84 = happySpecReduce_3  18# happyReduction_84-happyReduction_84 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut38 happy_x_1 of { happy_var_1 -> -	case happyOut54 happy_x_3 of { happy_var_3 -> -	happyIn54-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_85 = happySpecReduce_0  19# happyReduction_85-happyReduction_85  =  happyIn55-		 ([]-	)--happyReduce_86 = happySpecReduce_1  19# happyReduction_86-happyReduction_86 happy_x_1-	 =  case happyOut53 happy_x_1 of { happy_var_1 -> -	happyIn55-		 ((:[]) happy_var_1-	)}--happyReduce_87 = happySpecReduce_3  19# happyReduction_87-happyReduction_87 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut53 happy_x_1 of { happy_var_1 -> -	case happyOut55 happy_x_3 of { happy_var_3 -> -	happyIn55-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_88 = happySpecReduce_1  20# happyReduction_88-happyReduction_88 happy_x_1-	 =  case happyOut52 happy_x_1 of { happy_var_1 -> -	happyIn56-		 ((:[]) happy_var_1-	)}--happyReduce_89 = happySpecReduce_2  20# happyReduction_89-happyReduction_89 happy_x_2-	happy_x_1-	 =  case happyOut52 happy_x_1 of { happy_var_1 -> -	case happyOut56 happy_x_2 of { happy_var_2 -> -	happyIn56-		 ((:) happy_var_1 happy_var_2-	)}}--happyReduce_90 = happySpecReduce_0  21# happyReduction_90-happyReduction_90  =  happyIn57-		 (SepNone-	)--happyReduce_91 = happySpecReduce_2  21# happyReduction_91-happyReduction_91 happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn57-		 (SepTerm happy_var_2-	)}--happyReduce_92 = happySpecReduce_2  21# happyReduction_92-happyReduction_92 happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn57-		 (SepSepar happy_var_2-	)}--happyReduce_93 = happySpecReduce_1  22# happyReduction_93-happyReduction_93 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn58-		 (Arg happy_var_1-	)}--happyReduce_94 = happySpecReduce_0  23# happyReduction_94-happyReduction_94  =  happyIn59-		 ([]-	)--happyReduce_95 = happySpecReduce_2  23# happyReduction_95-happyReduction_95 happy_x_2-	happy_x_1-	 =  case happyOut59 happy_x_1 of { happy_var_1 -> -	case happyOut58 happy_x_2 of { happy_var_2 -> -	happyIn59-		 (flip (:) happy_var_1 happy_var_2-	)}}--happyReduce_96 = happySpecReduce_3  24# happyReduction_96-happyReduction_96 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut61 happy_x_1 of { happy_var_1 -> -	case happyOut60 happy_x_3 of { happy_var_3 -> -	happyIn60-		 (Cons happy_var_1 happy_var_3-	)}}--happyReduce_97 = happySpecReduce_1  24# happyReduction_97-happyReduction_97 happy_x_1-	 =  case happyOut61 happy_x_1 of { happy_var_1 -> -	happyIn60-		 (happy_var_1-	)}--happyReduce_98 = happySpecReduce_2  25# happyReduction_98-happyReduction_98 happy_x_2-	happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	case happyOut63 happy_x_2 of { happy_var_2 -> -	happyIn61-		 (App happy_var_1 happy_var_2-	)}}--happyReduce_99 = happySpecReduce_1  25# happyReduction_99-happyReduction_99 happy_x_1-	 =  case happyOut62 happy_x_1 of { happy_var_1 -> -	happyIn61-		 (happy_var_1-	)}--happyReduce_100 = happySpecReduce_1  26# happyReduction_100-happyReduction_100 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (Var happy_var_1-	)}--happyReduce_101 = happySpecReduce_1  26# happyReduction_101-happyReduction_101 happy_x_1-	 =  case happyOut38 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (LitInt happy_var_1-	)}--happyReduce_102 = happySpecReduce_1  26# happyReduction_102-happyReduction_102 happy_x_1-	 =  case happyOut39 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (LitChar happy_var_1-	)}--happyReduce_103 = happySpecReduce_1  26# happyReduction_103-happyReduction_103 happy_x_1-	 =  case happyOut36 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (LitString happy_var_1-	)}--happyReduce_104 = happySpecReduce_1  26# happyReduction_104-happyReduction_104 happy_x_1-	 =  case happyOut40 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (LitDouble happy_var_1-	)}--happyReduce_105 = happySpecReduce_3  26# happyReduction_105-happyReduction_105 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut64 happy_x_2 of { happy_var_2 -> -	happyIn62-		 (List happy_var_2-	)}--happyReduce_106 = happySpecReduce_3  26# happyReduction_106-happyReduction_106 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut60 happy_x_2 of { happy_var_2 -> -	happyIn62-		 (happy_var_2-	)}--happyReduce_107 = happySpecReduce_1  27# happyReduction_107-happyReduction_107 happy_x_1-	 =  case happyOut62 happy_x_1 of { happy_var_1 -> -	happyIn63-		 ((:[]) happy_var_1-	)}--happyReduce_108 = happySpecReduce_2  27# happyReduction_108-happyReduction_108 happy_x_2-	happy_x_1-	 =  case happyOut62 happy_x_1 of { happy_var_1 -> -	case happyOut63 happy_x_2 of { happy_var_2 -> -	happyIn63-		 ((:) happy_var_1 happy_var_2-	)}}--happyReduce_109 = happySpecReduce_0  28# happyReduction_109-happyReduction_109  =  happyIn64-		 ([]-	)--happyReduce_110 = happySpecReduce_1  28# happyReduction_110-happyReduction_110 happy_x_1-	 =  case happyOut60 happy_x_1 of { happy_var_1 -> -	happyIn64-		 ((:[]) happy_var_1-	)}--happyReduce_111 = happySpecReduce_3  28# happyReduction_111-happyReduction_111 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut60 happy_x_1 of { happy_var_1 -> -	case happyOut64 happy_x_3 of { happy_var_3 -> -	happyIn64-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_112 = happySpecReduce_1  29# happyReduction_112-happyReduction_112 happy_x_1-	 =  case happyOut36 happy_x_1 of { happy_var_1 -> -	happyIn65-		 ((:[]) happy_var_1-	)}--happyReduce_113 = happySpecReduce_3  29# happyReduction_113-happyReduction_113 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_1 of { happy_var_1 -> -	case happyOut65 happy_x_3 of { happy_var_3 -> -	happyIn65-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_114 = happySpecReduce_1  30# happyReduction_114-happyReduction_114 happy_x_1-	 =  case happyOut67 happy_x_1 of { happy_var_1 -> -	happyIn66-		 ((:[]) happy_var_1-	)}--happyReduce_115 = happySpecReduce_3  30# happyReduction_115-happyReduction_115 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut67 happy_x_1 of { happy_var_1 -> -	case happyOut66 happy_x_3 of { happy_var_3 -> -	happyIn66-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_116 = happySpecReduce_1  31# happyReduction_116-happyReduction_116 happy_x_1-	 =  case happyOut46 happy_x_1 of { happy_var_1 -> -	happyIn67-		 (RHS (reverse happy_var_1)-	)}--happyReduce_117 = happySpecReduce_1  32# happyReduction_117-happyReduction_117 happy_x_1-	 =  happyIn68-		 (MNonempty-	)--happyReduce_118 = happySpecReduce_0  32# happyReduction_118-happyReduction_118  =  happyIn68-		 (MEmpty-	)--happyReduce_119 = happySpecReduce_2  33# happyReduction_119-happyReduction_119 happy_x_2-	happy_x_1-	 =  case happyOut69 happy_x_1 of { happy_var_1 -> -	case happyOut71 happy_x_2 of { happy_var_2 -> -	happyIn69-		 (RSeq happy_var_1 happy_var_2-	)}}--happyReduce_120 = happySpecReduce_1  33# happyReduction_120-happyReduction_120 happy_x_1-	 =  case happyOut71 happy_x_1 of { happy_var_1 -> -	happyIn69-		 (happy_var_1-	)}--happyReduce_121 = happySpecReduce_3  34# happyReduction_121-happyReduction_121 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut70 happy_x_1 of { happy_var_1 -> -	case happyOut69 happy_x_3 of { happy_var_3 -> -	happyIn70-		 (RAlt happy_var_1 happy_var_3-	)}}--happyReduce_122 = happySpecReduce_3  34# happyReduction_122-happyReduction_122 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut69 happy_x_1 of { happy_var_1 -> -	case happyOut69 happy_x_3 of { happy_var_3 -> -	happyIn70-		 (RMinus happy_var_1 happy_var_3-	)}}--happyReduce_123 = happySpecReduce_1  34# happyReduction_123-happyReduction_123 happy_x_1-	 =  case happyOut69 happy_x_1 of { happy_var_1 -> -	happyIn70-		 (happy_var_1-	)}--happyReduce_124 = happySpecReduce_2  35# happyReduction_124-happyReduction_124 happy_x_2-	happy_x_1-	 =  case happyOut71 happy_x_1 of { happy_var_1 -> -	happyIn71-		 (RStar happy_var_1-	)}--happyReduce_125 = happySpecReduce_2  35# happyReduction_125-happyReduction_125 happy_x_2-	happy_x_1-	 =  case happyOut71 happy_x_1 of { happy_var_1 -> -	happyIn71-		 (RPlus happy_var_1-	)}--happyReduce_126 = happySpecReduce_2  35# happyReduction_126-happyReduction_126 happy_x_2-	happy_x_1-	 =  case happyOut71 happy_x_1 of { happy_var_1 -> -	happyIn71-		 (ROpt happy_var_1-	)}--happyReduce_127 = happySpecReduce_1  35# happyReduction_127-happyReduction_127 happy_x_1-	 =  happyIn71-		 (REps-	)--happyReduce_128 = happySpecReduce_1  35# happyReduction_128-happyReduction_128 happy_x_1-	 =  case happyOut39 happy_x_1 of { happy_var_1 -> -	happyIn71-		 (RChar happy_var_1-	)}--happyReduce_129 = happySpecReduce_3  35# happyReduction_129-happyReduction_129 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn71-		 (RAlts happy_var_2-	)}--happyReduce_130 = happySpecReduce_3  35# happyReduction_130-happyReduction_130 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn71-		 (RSeqs happy_var_2-	)}--happyReduce_131 = happySpecReduce_1  35# happyReduction_131-happyReduction_131 happy_x_1-	 =  happyIn71-		 (RDigit-	)--happyReduce_132 = happySpecReduce_1  35# happyReduction_132-happyReduction_132 happy_x_1-	 =  happyIn71-		 (RLetter-	)--happyReduce_133 = happySpecReduce_1  35# happyReduction_133-happyReduction_133 happy_x_1-	 =  happyIn71-		 (RUpper-	)--happyReduce_134 = happySpecReduce_1  35# happyReduction_134-happyReduction_134 happy_x_1-	 =  happyIn71-		 (RLower-	)--happyReduce_135 = happySpecReduce_1  35# happyReduction_135-happyReduction_135 happy_x_1-	 =  happyIn71-		 (RAny-	)--happyReduce_136 = happySpecReduce_3  35# happyReduction_136-happyReduction_136 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut72 happy_x_2 of { happy_var_2 -> -	happyIn71-		 (happy_var_2-	)}--happyReduce_137 = happySpecReduce_1  36# happyReduction_137-happyReduction_137 happy_x_1-	 =  case happyOut70 happy_x_1 of { happy_var_1 -> -	happyIn72-		 (happy_var_1-	)}--happyReduce_138 = happySpecReduce_1  37# happyReduction_138-happyReduction_138 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn73-		 ((:[]) happy_var_1-	)}--happyReduce_139 = happySpecReduce_3  37# happyReduction_139-happyReduction_139 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	case happyOut73 happy_x_3 of { happy_var_3 -> -	happyIn73-		 ((:) happy_var_1 happy_var_3-	)}}--happyNewToken action sts stk [] =-	happyDoAction 46# notHappyAtAll action sts stk []--happyNewToken action sts stk (tk:tks) =-	let cont i = happyDoAction i tk action sts stk tks in-	case tk of {-	PT _ (TS _ 1) -> cont 1#;-	PT _ (TS _ 2) -> cont 2#;-	PT _ (TS _ 3) -> cont 3#;-	PT _ (TS _ 4) -> cont 4#;-	PT _ (TS _ 5) -> cont 5#;-	PT _ (TS _ 6) -> cont 6#;-	PT _ (TS _ 7) -> cont 7#;-	PT _ (TS _ 8) -> cont 8#;-	PT _ (TS _ 9) -> cont 9#;-	PT _ (TS _ 10) -> cont 10#;-	PT _ (TS _ 11) -> cont 11#;-	PT _ (TS _ 12) -> cont 12#;-	PT _ (TS _ 13) -> cont 13#;-	PT _ (TS _ 14) -> cont 14#;-	PT _ (TS _ 15) -> cont 15#;-	PT _ (TS _ 16) -> cont 16#;-	PT _ (TS _ 17) -> cont 17#;-	PT _ (TS _ 18) -> cont 18#;-	PT _ (TS _ 19) -> cont 19#;-	PT _ (TS _ 20) -> cont 20#;-	PT _ (TS _ 21) -> cont 21#;-	PT _ (TS _ 22) -> cont 22#;-	PT _ (TS _ 23) -> cont 23#;-	PT _ (TS _ 24) -> cont 24#;-	PT _ (TS _ 25) -> cont 25#;-	PT _ (TS _ 26) -> cont 26#;-	PT _ (TS _ 27) -> cont 27#;-	PT _ (TS _ 28) -> cont 28#;-	PT _ (TS _ 29) -> cont 29#;-	PT _ (TS _ 30) -> cont 30#;-	PT _ (TS _ 31) -> cont 31#;-	PT _ (TS _ 32) -> cont 32#;-	PT _ (TS _ 33) -> cont 33#;-	PT _ (TS _ 34) -> cont 34#;-	PT _ (TS _ 35) -> cont 35#;-	PT _ (TS _ 36) -> cont 36#;-	PT _ (TS _ 37) -> cont 37#;-	PT _ (TS _ 38) -> cont 38#;-	PT _ (TS _ 39) -> cont 39#;-	PT _ (TS _ 40) -> cont 40#;-	PT _ (TL happy_dollar_dollar) -> cont 41#;-	PT _ (TV happy_dollar_dollar) -> cont 42#;-	PT _ (TI happy_dollar_dollar) -> cont 43#;-	PT _ (TC happy_dollar_dollar) -> cont 44#;-	PT _ (TD happy_dollar_dollar) -> cont 45#;-	_ -> happyError' (tk:tks)-	}--happyError_ 46# tk tks = happyError' tks-happyError_ _ tk tks = happyError' (tk:tks)--happyThen :: () => Err a -> (a -> Err b) -> Err b-happyThen = (thenM)-happyReturn :: () => a -> Err a-happyReturn = (returnM)-happyThen1 m k tks = (thenM) m (\a -> k a tks)-happyReturn1 :: () => a -> b -> Err a-happyReturn1 = \a tks -> (returnM) a-happyError' :: () => [(Token)] -> Err a-happyError' = happyError--pLGrammar tks = happySomeParser where-  happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut41 x))--pLDef tks = happySomeParser where-  happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut42 x))--pListLDef tks = happySomeParser where-  happySomeParser = happyThen (happyParse 2# tks) (\x -> happyReturn (happyOut43 x))--pGrammar tks = happySomeParser where-  happySomeParser = happyThen (happyParse 3# tks) (\x -> happyReturn (happyOut44 x))--pListDef tks = happySomeParser where-  happySomeParser = happyThen (happyParse 4# tks) (\x -> happyReturn (happyOut45 x))--pListItem tks = happySomeParser where-  happySomeParser = happyThen (happyParse 5# tks) (\x -> happyReturn (happyOut46 x))--pDef tks = happySomeParser where-  happySomeParser = happyThen (happyParse 6# tks) (\x -> happyReturn (happyOut47 x))--pItem tks = happySomeParser where-  happySomeParser = happyThen (happyParse 7# tks) (\x -> happyReturn (happyOut48 x))--pCat tks = happySomeParser where-  happySomeParser = happyThen (happyParse 8# tks) (\x -> happyReturn (happyOut49 x))--pLabel tks = happySomeParser where-  happySomeParser = happyThen (happyParse 9# tks) (\x -> happyReturn (happyOut50 x))--pLabelId tks = happySomeParser where-  happySomeParser = happyThen (happyParse 10# tks) (\x -> happyReturn (happyOut51 x))--pProfItem tks = happySomeParser where-  happySomeParser = happyThen (happyParse 11# tks) (\x -> happyReturn (happyOut52 x))--pIntList tks = happySomeParser where-  happySomeParser = happyThen (happyParse 12# tks) (\x -> happyReturn (happyOut53 x))--pListInteger tks = happySomeParser where-  happySomeParser = happyThen (happyParse 13# tks) (\x -> happyReturn (happyOut54 x))--pListIntList tks = happySomeParser where-  happySomeParser = happyThen (happyParse 14# tks) (\x -> happyReturn (happyOut55 x))--pListProfItem tks = happySomeParser where-  happySomeParser = happyThen (happyParse 15# tks) (\x -> happyReturn (happyOut56 x))--pSeparation tks = happySomeParser where-  happySomeParser = happyThen (happyParse 16# tks) (\x -> happyReturn (happyOut57 x))--pArg tks = happySomeParser where-  happySomeParser = happyThen (happyParse 17# tks) (\x -> happyReturn (happyOut58 x))--pListArg tks = happySomeParser where-  happySomeParser = happyThen (happyParse 18# tks) (\x -> happyReturn (happyOut59 x))--pExp tks = happySomeParser where-  happySomeParser = happyThen (happyParse 19# tks) (\x -> happyReturn (happyOut60 x))--pExp1 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 20# tks) (\x -> happyReturn (happyOut61 x))--pExp2 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 21# tks) (\x -> happyReturn (happyOut62 x))--pListExp2 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 22# tks) (\x -> happyReturn (happyOut63 x))--pListExp tks = happySomeParser where-  happySomeParser = happyThen (happyParse 23# tks) (\x -> happyReturn (happyOut64 x))--pListString tks = happySomeParser where-  happySomeParser = happyThen (happyParse 24# tks) (\x -> happyReturn (happyOut65 x))--pListRHS tks = happySomeParser where-  happySomeParser = happyThen (happyParse 25# tks) (\x -> happyReturn (happyOut66 x))--pRHS tks = happySomeParser where-  happySomeParser = happyThen (happyParse 26# tks) (\x -> happyReturn (happyOut67 x))--pMinimumSize tks = happySomeParser where-  happySomeParser = happyThen (happyParse 27# tks) (\x -> happyReturn (happyOut68 x))--pReg2 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 28# tks) (\x -> happyReturn (happyOut69 x))--pReg1 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 29# tks) (\x -> happyReturn (happyOut70 x))--pReg3 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 30# tks) (\x -> happyReturn (happyOut71 x))--pReg tks = happySomeParser where-  happySomeParser = happyThen (happyParse 31# tks) (\x -> happyReturn (happyOut72 x))--pListIdent tks = happySomeParser where-  happySomeParser = happyThen (happyParse 32# tks) (\x -> happyReturn (happyOut73 x))--happySeq = happyDontSeq---returnM :: a -> Err a-returnM = return--thenM :: Err a -> (a -> Err b) -> Err b-thenM = (>>=)--happyError :: [Token] -> Err a-happyError ts =-  Bad $ "syntax error at " ++ tokenPos ts ++ -  case ts of-    [] -> []-    [Err _] -> " due to lexer error"-    _ -> " before " ++ unwords (map (id . prToken) (take 4 ts))--myLexer = tokens-{-# LINE 1 "templates/GenericTemplate.hs" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}-{-# LINE 1 "<built-in>" #-}-{-# LINE 1 "<command-line>" #-}-{-# LINE 8 "<command-line>" #-}-# 1 "/usr/include/stdc-predef.h" 1 3 4--# 17 "/usr/include/stdc-predef.h" 3 4------------------------{-# LINE 8 "<command-line>" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}--- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp --{-# LINE 13 "templates/GenericTemplate.hs" #-}-------- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.-#if __GLASGOW_HASKELL__ > 706-#define LT(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.<# m)) :: Bool)-#define GTE(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.>=# m)) :: Bool)-#define EQ(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.==# m)) :: Bool)-#else-#define LT(n,m) (n Happy_GHC_Exts.<# m)-#define GTE(n,m) (n Happy_GHC_Exts.>=# m)-#define EQ(n,m) (n Happy_GHC_Exts.==# m)-#endif-{-# LINE 46 "templates/GenericTemplate.hs" #-}---data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList------{-# LINE 67 "templates/GenericTemplate.hs" #-}--{-# LINE 77 "templates/GenericTemplate.hs" #-}--{-# LINE 86 "templates/GenericTemplate.hs" #-}--infixr 9 `HappyStk`-data HappyStk a = HappyStk a (HappyStk a)---------------------------------------------------------------------------------- starting the parse--happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll---------------------------------------------------------------------------------- Accepting the parse---- If the current token is 0#, it means we've just accepted a partial--- parse (a %partial parser).  We must ignore the saved token on the top of--- the stack in this case.-happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) =-        happyReturn1 ans-happyAccept j tk st sts (HappyStk ans _) = -        (happyTcHack j (happyTcHack st)) (happyReturn1 ans)---------------------------------------------------------------------------------- Arrays only: do the next action----happyDoAction i tk st-        = {- nothing -}---          case action of-                0#           -> {- nothing -}-                                     happyFail i tk st-                -1#          -> {- nothing -}-                                     happyAccept i tk st-                n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}--                                                   (happyReduceArr Happy_Data_Array.! rule) i tk st-                                                   where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))-                n                 -> {- nothing -}---                                     happyShift new_state i tk st-                                     where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))-   where off    = indexShortOffAddr happyActOffsets st-         off_i  = (off Happy_GHC_Exts.+# i)-         check  = if GTE(off_i,(0# :: Happy_GHC_Exts.Int#))-                  then EQ(indexShortOffAddr happyCheck off_i, i)-                  else False-         action-          | check     = indexShortOffAddr happyTable off_i-          | otherwise = indexShortOffAddr happyDefActions st---indexShortOffAddr (HappyA# arr) off =-        Happy_GHC_Exts.narrow16Int# i-  where-        i = Happy_GHC_Exts.word2Int# (Happy_GHC_Exts.or# (Happy_GHC_Exts.uncheckedShiftL# high 8#) low)-        high = Happy_GHC_Exts.int2Word# (Happy_GHC_Exts.ord# (Happy_GHC_Exts.indexCharOffAddr# arr (off' Happy_GHC_Exts.+# 1#)))-        low  = Happy_GHC_Exts.int2Word# (Happy_GHC_Exts.ord# (Happy_GHC_Exts.indexCharOffAddr# arr off'))-        off' = off Happy_GHC_Exts.*# 2#------data HappyAddr = HappyA# Happy_GHC_Exts.Addr#------------------------------------------------------------------------------------- HappyState data type (not arrays)--{-# LINE 170 "templates/GenericTemplate.hs" #-}---------------------------------------------------------------------------------- Shifting a token--happyShift new_state 0# tk st sts stk@(x `HappyStk` _) =-     let i = (case Happy_GHC_Exts.unsafeCoerce# x of { (Happy_GHC_Exts.I# (i)) -> i }) in---     trace "shifting the error token" $-     happyDoAction i tk new_state (HappyCons (st) (sts)) (stk)--happyShift new_state i tk st sts stk =-     happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk)---- happyReduce is specialised for the common cases.--happySpecReduce_0 i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happySpecReduce_0 nt fn j tk st@((action)) sts stk-     = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk)--happySpecReduce_1 i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk')-     = let r = fn v1 in-       happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))--happySpecReduce_2 i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk')-     = let r = fn v1 v2 in-       happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))--happySpecReduce_3 i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk')-     = let r = fn v1 v2 v3 in-       happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))--happyReduce k i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happyReduce k nt fn j tk st sts stk-     = case happyDrop (k Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) sts of-         sts1@((HappyCons (st1@(action)) (_))) ->-                let r = fn stk in  -- it doesn't hurt to always seq here...-                happyDoSeq r (happyGoto nt j tk st1 sts1 r)--happyMonadReduce k nt fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happyMonadReduce k nt fn j tk st sts stk =-      case happyDrop k (HappyCons (st) (sts)) of-        sts1@((HappyCons (st1@(action)) (_))) ->-          let drop_stk = happyDropStk k stk in-          happyThen1 (fn stk tk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk))--happyMonad2Reduce k nt fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happyMonad2Reduce k nt fn j tk st sts stk =-      case happyDrop k (HappyCons (st) (sts)) of-        sts1@((HappyCons (st1@(action)) (_))) ->-         let drop_stk = happyDropStk k stk--             off = indexShortOffAddr happyGotoOffsets st1-             off_i = (off Happy_GHC_Exts.+# nt)-             new_state = indexShortOffAddr happyTable off_i----          in-          happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk))--happyDrop 0# l = l-happyDrop n (HappyCons (_) (t)) = happyDrop (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) t--happyDropStk 0# l = l-happyDropStk n (x `HappyStk` xs) = happyDropStk (n Happy_GHC_Exts.-# (1#::Happy_GHC_Exts.Int#)) xs---------------------------------------------------------------------------------- Moving to a new state after a reduction---happyGoto nt j tk st = -   {- nothing -}-   happyDoAction j tk new_state-   where off = indexShortOffAddr happyGotoOffsets st-         off_i = (off Happy_GHC_Exts.+# nt)-         new_state = indexShortOffAddr happyTable off_i------------------------------------------------------------------------------------- Error recovery (0# is the error token)---- parse error if we are in recovery and we fail again-happyFail 0# tk old_st _ stk@(x `HappyStk` _) =-     let i = (case Happy_GHC_Exts.unsafeCoerce# x of { (Happy_GHC_Exts.I# (i)) -> i }) in---      trace "failing" $ -        happyError_ i tk--{-  We don't need state discarding for our restricted implementation of-    "error".  In fact, it can cause some bogus parses, so I've disabled it-    for now --SDM---- discard a state-happyFail  0# tk old_st (HappyCons ((action)) (sts)) -                                                (saved_tok `HappyStk` _ `HappyStk` stk) =---      trace ("discarding state, depth " ++ show (length stk))  $-        happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk))--}---- Enter error recovery: generate an error token,---                       save the old token and carry on.-happyFail  i tk (action) sts stk =---      trace "entering error recovery" $-        happyDoAction 0# tk action sts ( (Happy_GHC_Exts.unsafeCoerce# (Happy_GHC_Exts.I# (i))) `HappyStk` stk)---- Internal happy errors:--notHappyAtAll :: a-notHappyAtAll = error "Internal Happy error\n"---------------------------------------------------------------------------------- Hack to get the typechecker to accept our action functions---happyTcHack :: Happy_GHC_Exts.Int# -> a -> a-happyTcHack x y = y-{-# INLINE happyTcHack #-}----------------------------------------------------------------------------------- Seq-ing.  If the --strict flag is given, then Happy emits ---      happySeq = happyDoSeq--- otherwise it emits---      happySeq = happyDontSeq--happyDoSeq, happyDontSeq :: a -> b -> b-happyDoSeq   a b = a `seq` b-happyDontSeq a b = b---------------------------------------------------------------------------------- Don't inline any functions from the template.  GHC has a nasty habit--- of deciding to inline happyGoto everywhere, which increases the size of--- the generated parser quite a bit.---{-# NOINLINE happyDoAction #-}-{-# NOINLINE happyTable #-}-{-# NOINLINE happyCheck #-}-{-# NOINLINE happyActOffsets #-}-{-# NOINLINE happyGotoOffsets #-}-{-# NOINLINE happyDefActions #-}--{-# NOINLINE happyShift #-}-{-# NOINLINE happySpecReduce_0 #-}-{-# NOINLINE happySpecReduce_1 #-}-{-# NOINLINE happySpecReduce_2 #-}-{-# NOINLINE happySpecReduce_3 #-}-{-# NOINLINE happyReduce #-}-{-# NOINLINE happyMonadReduce #-}-{-# NOINLINE happyGoto #-}-{-# NOINLINE happyFail #-}---- end of Happy Template.
− dist/build/unit-tests/unit-tests-tmp/LexBNF.hs
@@ -1,412 +0,0 @@-{-# LANGUAGE CPP,MagicHash #-}-{-# LINE 3 "src/LexBNF.x" #-}--{-# OPTIONS -fno-warn-incomplete-patterns #-}-{-# OPTIONS_GHC -w #-}-module LexBNF where----import qualified Data.Bits-import Data.Word (Word8)--#if __GLASGOW_HASKELL__ >= 603-#include "ghcconfig.h"-#elif defined(__GLASGOW_HASKELL__)-#include "config.h"-#endif-#if __GLASGOW_HASKELL__ >= 503-import Data.Array-import Data.Char (ord)-import Data.Array.Base (unsafeAt)-#else-import Array-import Char (ord)-#endif-#if __GLASGOW_HASKELL__ >= 503-import GHC.Exts-#else-import GlaExts-#endif-alex_base :: AlexAddr-alex_base = AlexA# "\xf8\xff\xff\xff\x49\x00\x00\x00\xc9\xff\xff\xff\xe0\xff\xff\xff\xc9\x00\x00\x00\x9c\x01\x00\x00\x2d\x00\x00\x00\x1c\x02\x00\x00\x1c\x03\x00\x00\x0a\x01\x00\x00\x00\x00\x00\x00\x0d\x03\x00\x00\x0d\x04\x00\x00\xcd\x03\x00\x00\xcd\x04\x00\x00\x91\x05\x00\x00\xef\x05\x00\x00\x8d\x04\x00\x00\x00\x00\x00\x00\xa5\x05\x00\x00\xdb\xff\xff\xff\x47\x00\x00\x00\x5a\x00\x00\x00\xa5\x06\x00\x00\xa6\x06\x00\x00\x69\x07\x00\x00\x29\x07\x00\x00\x00\x00\x00\x00\x1f\x08\x00\x00\x00\x00\x00\x00\x78\x00\x00\x00\xdc\xff\xff\xff\xdd\xff\xff\xff\x00\x00\x00\x00\xdf\xff\xff\xff\xf8\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x72\x00\x00\x00\xe7\x05\x00\x00\x7c\x00\x00\x00"#--alex_table :: AlexAddr-alex_table = AlexA# "\x00\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x21\x00\x25\x00\x16\x00\x1c\x00\x05\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x02\x00\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x21\x00\x21\x00\x21\x00\x21\x00\x21\x00\x1f\x00\x21\x00\x00\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x22\x00\x21\x00\x00\x00\x21\x00\x00\x00\x21\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x21\x00\x03\x00\x21\x00\x00\x00\x21\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x20\x00\x21\x00\x21\x00\x01\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x03\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15\x00\x03\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x26\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x28\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x08\x00\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x19\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x01\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x08\x00\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x04\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x13\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x00\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x06\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\x03\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x0c\x00\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x27\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x1a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x24\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x10\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x17\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x0f\x00\x11\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x19\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1b\x00\x1a\x00\x04\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x12\x00\x13\x00\x07\x00\x0a\x00\x0a\x00\x0a\x00\x0b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\x00\x00\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#--alex_check :: AlexAddr-alex_check = AlexA# "\xff\xff\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x3d\x00\x27\x00\x2d\x00\x2d\x00\x2d\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\x20\x00\x3a\x00\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\xff\xff\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\xff\xff\x3d\x00\xff\xff\x3f\x00\xff\xff\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x27\x00\x5d\x00\xff\xff\x5f\x00\xff\xff\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x2d\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\xff\xff\xff\xff\xff\xff\x5c\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\x6e\x00\xff\xff\xff\xff\xff\xff\xff\xff\x2e\x00\x74\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc3\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7d\x00\xff\xff\xff\xff\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x2d\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\xff\xff\xff\xff\xc2\x00\xc3\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\x27\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\x65\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x6e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x74\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\xff\xff\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\xff\xff\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\xff\xff\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xff\xff\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xff\xff\xc2\x00\xc3\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\x27\x00\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\x3a\x00\x3b\x00\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\x5b\x00\x5c\x00\x5d\x00\x5e\x00\x5f\x00\x60\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x0a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x80\x00\x81\x00\x82\x00\x83\x00\x84\x00\x85\x00\x86\x00\x87\x00\x88\x00\x89\x00\x8a\x00\x8b\x00\x8c\x00\x8d\x00\x8e\x00\x8f\x00\x90\x00\x91\x00\x92\x00\x93\x00\x94\x00\x95\x00\x96\x00\x97\x00\x98\x00\x99\x00\x9a\x00\x9b\x00\x9c\x00\x9d\x00\x9e\x00\x9f\x00\xa0\x00\xa1\x00\xa2\x00\xa3\x00\xa4\x00\xa5\x00\xa6\x00\xa7\x00\xa8\x00\xa9\x00\xaa\x00\xab\x00\xac\x00\xad\x00\xae\x00\xaf\x00\xb0\x00\xb1\x00\xb2\x00\xb3\x00\xb4\x00\xb5\x00\xb6\x00\xb7\x00\xb8\x00\xb9\x00\xba\x00\xbb\x00\xbc\x00\xbd\x00\xbe\x00\xbf\x00\xc0\x00\xc1\x00\xc2\x00\xc3\x00\xc4\x00\xc5\x00\xc6\x00\xc7\x00\xc8\x00\xc9\x00\xca\x00\xcb\x00\xcc\x00\xcd\x00\xce\x00\xcf\x00\xd0\x00\xd1\x00\xd2\x00\xd3\x00\xd4\x00\xd5\x00\xd6\x00\xd7\x00\xd8\x00\xd9\x00\xda\x00\xdb\x00\xdc\x00\xdd\x00\xde\x00\xdf\x00\xe0\x00\xe1\x00\xe2\x00\xe3\x00\xe4\x00\xe5\x00\xe6\x00\xe7\x00\xe8\x00\xe9\x00\xea\x00\xeb\x00\xec\x00\xed\x00\xee\x00\xef\x00\xf0\x00\xf1\x00\xf2\x00\xf3\x00\xf4\x00\xf5\x00\xf6\x00\xf7\x00\xf8\x00\xf9\x00\xfa\x00\xfb\x00\xfc\x00\xfd\x00\xfe\x00\xff\x00\x27\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x30\x00\x31\x00\x32\x00\x33\x00\x34\x00\x35\x00\x36\x00\x37\x00\x38\x00\x39\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x48\x00\x49\x00\x4a\x00\x4b\x00\x4c\x00\x4d\x00\x4e\x00\x4f\x00\x50\x00\x51\x00\x52\x00\x53\x00\x54\x00\x55\x00\x56\x00\x57\x00\x58\x00\x59\x00\x5a\x00\xff\xff\xff\xff\xff\xff\xff\xff\x5f\x00\xff\xff\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00\x6c\x00\x6d\x00\x6e\x00\x6f\x00\x70\x00\x71\x00\x72\x00\x73\x00\x74\x00\x75\x00\x76\x00\x77\x00\x78\x00\x79\x00\x7a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc3\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#--alex_deflt :: AlexAddr-alex_deflt = AlexA# "\xff\xff\x05\x00\xff\xff\xff\xff\xff\xff\x05\x00\xff\xff\xff\xff\x05\x00\x05\x00\x12\x00\x12\x00\x03\x00\x03\x00\xff\xff\x17\x00\xff\xff\x17\x00\x1b\x00\x1b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1c\x00\x1c\x00\x1c\x00\x1c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#--alex_accept = listArray (0::Int,40) [AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccNone,AlexAccSkip,AlexAccSkip,AlexAccSkip,AlexAcc (alex_action_3),AlexAcc (alex_action_3),AlexAcc (alex_action_3),AlexAcc (alex_action_3),AlexAcc (alex_action_4),AlexAcc (alex_action_5),AlexAcc (alex_action_6),AlexAcc (alex_action_7),AlexAcc (alex_action_8),AlexAcc (alex_action_8)]-{-# LINE 38 "src/LexBNF.x" #-}---tok :: (Posn -> String -> Token) -> (Posn -> String -> Token)-tok f p s = f p s--share :: String -> String-share = id--data Tok =-   TS !String !Int    -- reserved words and symbols- | TL !String         -- string literals- | TI !String         -- integer literals- | TV !String         -- identifiers- | TD !String         -- double precision float literals- | TC !String         -- character literals-- deriving (Eq,Show,Ord)--data Token =-   PT  Posn Tok- | Err Posn-  deriving (Eq,Show,Ord)--tokenPos :: [Token] -> String-tokenPos (PT (Pn _ l _) _ :_) = "line " ++ show l-tokenPos (Err (Pn _ l _) :_) = "line " ++ show l-tokenPos _ = "end of file"--tokenPosn :: Token -> Posn-tokenPosn (PT p _) = p-tokenPosn (Err p) = p--tokenLineCol :: Token -> (Int, Int)-tokenLineCol = posLineCol . tokenPosn--posLineCol :: Posn -> (Int, Int)-posLineCol (Pn _ l c) = (l,c)--mkPosToken :: Token -> ((Int, Int), String)-mkPosToken t@(PT p _) = (posLineCol p, prToken t)--prToken :: Token -> String-prToken t = case t of-  PT _ (TS s _) -> s-  PT _ (TL s)   -> s-  PT _ (TI s)   -> s-  PT _ (TV s)   -> s-  PT _ (TD s)   -> s-  PT _ (TC s)   -> s---data BTree = N | B String Tok BTree BTree deriving (Show)--eitherResIdent :: (String -> Tok) -> String -> Tok-eitherResIdent tv s = treeFind resWords-  where-  treeFind N = tv s-  treeFind (B a t left right) | s < a  = treeFind left-                              | s > a  = treeFind right-                              | s == a = t--resWords :: BTree-resWords = b "digit" 21 (b "=" 11 (b "-" 6 (b "*" 3 (b ")" 2 (b "(" 1 N N) N) (b "," 5 (b "+" 4 N N) N)) (b "::=" 9 (b ":" 8 (b "." 7 N N) N) (b ";" 10 N N))) (b "char" 16 (b "]" 14 (b "[" 13 (b "?" 12 N N) N) (b "_" 15 N N)) (b "define" 19 (b "comment" 18 (b "coercions" 17 N N) N) (b "delimiters" 20 N N)))) (b "separator" 31 (b "letter" 26 (b "internal" 24 (b "eps" 23 (b "entrypoints" 22 N N) N) (b "layout" 25 N N)) (b "position" 29 (b "nonempty" 28 (b "lower" 27 N N) N) (b "rules" 30 N N))) (b "upper" 36 (b "token" 34 (b "terminator" 33 (b "stop" 32 N N) N) (b "toplevel" 35 N N)) (b "|" 39 (b "{" 38 (b "views" 37 N N) N) (b "}" 40 N N))))-   where b s n = let bs = id s-                  in B bs (TS bs n)--unescapeInitTail :: String -> String-unescapeInitTail = id . unesc . tail . id where-  unesc s = case s of-    '\\':c:cs | elem c ['\"', '\\', '\''] -> c : unesc cs-    '\\':'n':cs  -> '\n' : unesc cs-    '\\':'t':cs  -> '\t' : unesc cs-    '"':[]    -> []-    c:cs      -> c : unesc cs-    _         -> []------------------------------------------------------------------------ Alex wrapper code.--- A modified "posn" wrapper.----------------------------------------------------------------------data Posn = Pn !Int !Int !Int-      deriving (Eq, Show,Ord)--alexStartPos :: Posn-alexStartPos = Pn 0 1 1--alexMove :: Posn -> Char -> Posn-alexMove (Pn a l c) '\t' = Pn (a+1)  l     (((c+7) `div` 8)*8+1)-alexMove (Pn a l c) '\n' = Pn (a+1) (l+1)   1-alexMove (Pn a l c) _    = Pn (a+1)  l     (c+1)--type Byte = Word8--type AlexInput = (Posn,     -- current position,-                  Char,     -- previous char-                  [Byte],   -- pending bytes on the current char-                  String)   -- current input string--tokens :: String -> [Token]-tokens str = go (alexStartPos, '\n', [], str)-    where-      go :: AlexInput -> [Token]-      go inp@(pos, _, _, str) =-               case alexScan inp 0 of-                AlexEOF                   -> []-                AlexError (pos, _, _, _)  -> [Err pos]-                AlexSkip  inp' len        -> go inp'-                AlexToken inp' len act    -> act pos (take len str) : (go inp')--alexGetByte :: AlexInput -> Maybe (Byte,AlexInput)-alexGetByte (p, c, (b:bs), s) = Just (b, (p, c, bs, s))-alexGetByte (p, _, [], s) =-  case  s of-    []  -> Nothing-    (c:s) ->-             let p'     = alexMove p c-                 (b:bs) = utf8Encode c-              in p' `seq` Just (b, (p', c, bs, s))--alexInputPrevChar :: AlexInput -> Char-alexInputPrevChar (p, c, bs, s) = c---- | Encode a Haskell String to a list of Word8 values, in UTF8 format.-utf8Encode :: Char -> [Word8]-utf8Encode = map fromIntegral . go . ord- where-  go oc-   | oc <= 0x7f       = [oc]--   | oc <= 0x7ff      = [ 0xc0 + (oc `Data.Bits.shiftR` 6)-                        , 0x80 + oc Data.Bits..&. 0x3f-                        ]--   | oc <= 0xffff     = [ 0xe0 + (oc `Data.Bits.shiftR` 12)-                        , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f)-                        , 0x80 + oc Data.Bits..&. 0x3f-                        ]-   | otherwise        = [ 0xf0 + (oc `Data.Bits.shiftR` 18)-                        , 0x80 + ((oc `Data.Bits.shiftR` 12) Data.Bits..&. 0x3f)-                        , 0x80 + ((oc `Data.Bits.shiftR` 6) Data.Bits..&. 0x3f)-                        , 0x80 + oc Data.Bits..&. 0x3f-                        ]--alex_action_3 =  tok (\p s -> PT p (eitherResIdent (TV . share) s)) -alex_action_4 =  tok (\p s -> PT p (eitherResIdent (TV . share) s)) -alex_action_5 =  tok (\p s -> PT p (TL $ share $ unescapeInitTail s)) -alex_action_6 =  tok (\p s -> PT p (TC $ share s))  -alex_action_7 =  tok (\p s -> PT p (TI $ share s))    -alex_action_8 =  tok (\p s -> PT p (TD $ share s)) -{-# LINE 1 "templates/GenericTemplate.hs" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}-{-# LINE 1 "<built-in>" #-}-{-# LINE 1 "<command-line>" #-}--------# 1 "/usr/include/stdc-predef.h" 1 3 4--# 17 "/usr/include/stdc-predef.h" 3 4------------------------{-# LINE 7 "<command-line>" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}--- -------------------------------------------------------------------------------- ALEX TEMPLATE------ This code is in the PUBLIC DOMAIN; you may copy it freely and use--- it for any purpose whatsoever.---- -------------------------------------------------------------------------------- INTERNALS and main scanner engine--{-# LINE 21 "templates/GenericTemplate.hs" #-}-------- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.-#if __GLASGOW_HASKELL__ > 706-#define GTE(n,m) (tagToEnum# (n >=# m))-#define EQ(n,m) (tagToEnum# (n ==# m))-#else-#define GTE(n,m) (n >=# m)-#define EQ(n,m) (n ==# m)-#endif-{-# LINE 51 "templates/GenericTemplate.hs" #-}---data AlexAddr = AlexA# Addr#--- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.-#if __GLASGOW_HASKELL__ < 503-uncheckedShiftL# = shiftL#-#endif--{-# INLINE alexIndexInt16OffAddr #-}-alexIndexInt16OffAddr (AlexA# arr) off =-#ifdef WORDS_BIGENDIAN-  narrow16Int# i-  where-        i    = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low)-        high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))-        low  = int2Word# (ord# (indexCharOffAddr# arr off'))-        off' = off *# 2#-#else-  indexInt16OffAddr# arr off-#endif------{-# INLINE alexIndexInt32OffAddr #-}-alexIndexInt32OffAddr (AlexA# arr) off = -#ifdef WORDS_BIGENDIAN-  narrow32Int# i-  where-   i    = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#`-		     (b2 `uncheckedShiftL#` 16#) `or#`-		     (b1 `uncheckedShiftL#` 8#) `or#` b0)-   b3   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#)))-   b2   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#)))-   b1   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))-   b0   = int2Word# (ord# (indexCharOffAddr# arr off'))-   off' = off *# 4#-#else-  indexInt32OffAddr# arr off-#endif-------#if __GLASGOW_HASKELL__ < 503-quickIndex arr i = arr ! i-#else--- GHC >= 503, unsafeAt is available from Data.Array.Base.-quickIndex = unsafeAt-#endif------- -------------------------------------------------------------------------------- Main lexing routines--data AlexReturn a-  = AlexEOF-  | AlexError  !AlexInput-  | AlexSkip   !AlexInput !Int-  | AlexToken  !AlexInput !Int a---- alexScan :: AlexInput -> StartCode -> AlexReturn a-alexScan input (I# (sc))-  = alexScanUser undefined input (I# (sc))--alexScanUser user input (I# (sc))-  = case alex_scan_tkn user input 0# input sc AlexNone of-	(AlexNone, input') ->-		case alexGetByte input of-			Nothing -> ----				   AlexEOF-			Just _ ->----				   AlexError input'--	(AlexLastSkip input'' len, _) ->----		AlexSkip input'' len--	(AlexLastAcc k input''' len, _) ->----		AlexToken input''' len k----- Push the input through the DFA, remembering the most recent accepting--- state it encountered.--alex_scan_tkn user orig_input len input s last_acc =-  input `seq` -- strict in the input-  let -	new_acc = (check_accs (alex_accept `quickIndex` (I# (s))))-  in-  new_acc `seq`-  case alexGetByte input of-     Nothing -> (new_acc, input)-     Just (c, new_input) -> ----      case fromIntegral c of { (I# (ord_c)) ->-        let-                base   = alexIndexInt32OffAddr alex_base s-                offset = (base +# ord_c)-                check  = alexIndexInt16OffAddr alex_check offset-		-                new_s = if GTE(offset,0#) && EQ(check,ord_c)-			  then alexIndexInt16OffAddr alex_table offset-			  else alexIndexInt16OffAddr alex_deflt s-	in-        case new_s of-	    -1# -> (new_acc, input)-		-- on an error, we want to keep the input *before* the-		-- character that failed, not after.-    	    _ -> alex_scan_tkn user orig_input (if c < 0x80 || c >= 0xC0 then (len +# 1#) else len)-                                                -- note that the length is increased ONLY if this is the 1st byte in a char encoding)-			new_input new_s new_acc-      }-  where-	check_accs (AlexAccNone) = last_acc-	check_accs (AlexAcc a  ) = AlexLastAcc a input (I# (len))-	check_accs (AlexAccSkip) = AlexLastSkip  input (I# (len))-{-# LINE 198 "templates/GenericTemplate.hs" #-}--data AlexLastAcc a-  = AlexNone-  | AlexLastAcc a !AlexInput !Int-  | AlexLastSkip  !AlexInput !Int--instance Functor AlexLastAcc where-    fmap f AlexNone = AlexNone-    fmap f (AlexLastAcc x y z) = AlexLastAcc (f x) y z-    fmap f (AlexLastSkip x y) = AlexLastSkip x y--data AlexAcc a user-  = AlexAccNone-  | AlexAcc a-  | AlexAccSkip-{-# LINE 242 "templates/GenericTemplate.hs" #-}---- used by wrappers-iUnbox (I# (i)) = i
− dist/build/unit-tests/unit-tests-tmp/ParBNF.hs
@@ -1,1751 +0,0 @@-{-# OPTIONS_GHC -w #-}-{-# OPTIONS -fglasgow-exts -cpp #-}-{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-}-module ParBNF where-import AbsBNF-import LexBNF-import ErrM-import qualified Data.Array as Happy_Data_Array-import qualified GHC.Exts as Happy_GHC_Exts-import Control.Applicative(Applicative(..))---- parser produced by Happy Version 1.19.4--newtype HappyAbsSyn  = HappyAbsSyn HappyAny-#if __GLASGOW_HASKELL__ >= 607-type HappyAny = Happy_GHC_Exts.Any-#else-type HappyAny = forall a . a-#endif-happyIn36 :: (String) -> (HappyAbsSyn )-happyIn36 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn36 #-}-happyOut36 :: (HappyAbsSyn ) -> (String)-happyOut36 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut36 #-}-happyIn37 :: (Ident) -> (HappyAbsSyn )-happyIn37 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn37 #-}-happyOut37 :: (HappyAbsSyn ) -> (Ident)-happyOut37 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut37 #-}-happyIn38 :: (Integer) -> (HappyAbsSyn )-happyIn38 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn38 #-}-happyOut38 :: (HappyAbsSyn ) -> (Integer)-happyOut38 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut38 #-}-happyIn39 :: (Char) -> (HappyAbsSyn )-happyIn39 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn39 #-}-happyOut39 :: (HappyAbsSyn ) -> (Char)-happyOut39 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut39 #-}-happyIn40 :: (Double) -> (HappyAbsSyn )-happyIn40 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn40 #-}-happyOut40 :: (HappyAbsSyn ) -> (Double)-happyOut40 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut40 #-}-happyIn41 :: (LGrammar) -> (HappyAbsSyn )-happyIn41 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn41 #-}-happyOut41 :: (HappyAbsSyn ) -> (LGrammar)-happyOut41 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut41 #-}-happyIn42 :: (LDef) -> (HappyAbsSyn )-happyIn42 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn42 #-}-happyOut42 :: (HappyAbsSyn ) -> (LDef)-happyOut42 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut42 #-}-happyIn43 :: ([LDef]) -> (HappyAbsSyn )-happyIn43 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn43 #-}-happyOut43 :: (HappyAbsSyn ) -> ([LDef])-happyOut43 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut43 #-}-happyIn44 :: (Grammar) -> (HappyAbsSyn )-happyIn44 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn44 #-}-happyOut44 :: (HappyAbsSyn ) -> (Grammar)-happyOut44 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut44 #-}-happyIn45 :: ([Def]) -> (HappyAbsSyn )-happyIn45 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn45 #-}-happyOut45 :: (HappyAbsSyn ) -> ([Def])-happyOut45 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut45 #-}-happyIn46 :: ([Item]) -> (HappyAbsSyn )-happyIn46 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn46 #-}-happyOut46 :: (HappyAbsSyn ) -> ([Item])-happyOut46 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut46 #-}-happyIn47 :: (Def) -> (HappyAbsSyn )-happyIn47 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn47 #-}-happyOut47 :: (HappyAbsSyn ) -> (Def)-happyOut47 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut47 #-}-happyIn48 :: (Item) -> (HappyAbsSyn )-happyIn48 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn48 #-}-happyOut48 :: (HappyAbsSyn ) -> (Item)-happyOut48 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut48 #-}-happyIn49 :: (Cat) -> (HappyAbsSyn )-happyIn49 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn49 #-}-happyOut49 :: (HappyAbsSyn ) -> (Cat)-happyOut49 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut49 #-}-happyIn50 :: (Label) -> (HappyAbsSyn )-happyIn50 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn50 #-}-happyOut50 :: (HappyAbsSyn ) -> (Label)-happyOut50 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut50 #-}-happyIn51 :: (LabelId) -> (HappyAbsSyn )-happyIn51 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn51 #-}-happyOut51 :: (HappyAbsSyn ) -> (LabelId)-happyOut51 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut51 #-}-happyIn52 :: (ProfItem) -> (HappyAbsSyn )-happyIn52 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn52 #-}-happyOut52 :: (HappyAbsSyn ) -> (ProfItem)-happyOut52 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut52 #-}-happyIn53 :: (IntList) -> (HappyAbsSyn )-happyIn53 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn53 #-}-happyOut53 :: (HappyAbsSyn ) -> (IntList)-happyOut53 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut53 #-}-happyIn54 :: ([Integer]) -> (HappyAbsSyn )-happyIn54 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn54 #-}-happyOut54 :: (HappyAbsSyn ) -> ([Integer])-happyOut54 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut54 #-}-happyIn55 :: ([IntList]) -> (HappyAbsSyn )-happyIn55 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn55 #-}-happyOut55 :: (HappyAbsSyn ) -> ([IntList])-happyOut55 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut55 #-}-happyIn56 :: ([ProfItem]) -> (HappyAbsSyn )-happyIn56 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn56 #-}-happyOut56 :: (HappyAbsSyn ) -> ([ProfItem])-happyOut56 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut56 #-}-happyIn57 :: (Separation) -> (HappyAbsSyn )-happyIn57 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn57 #-}-happyOut57 :: (HappyAbsSyn ) -> (Separation)-happyOut57 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut57 #-}-happyIn58 :: (Arg) -> (HappyAbsSyn )-happyIn58 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn58 #-}-happyOut58 :: (HappyAbsSyn ) -> (Arg)-happyOut58 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut58 #-}-happyIn59 :: ([Arg]) -> (HappyAbsSyn )-happyIn59 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn59 #-}-happyOut59 :: (HappyAbsSyn ) -> ([Arg])-happyOut59 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut59 #-}-happyIn60 :: (Exp) -> (HappyAbsSyn )-happyIn60 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn60 #-}-happyOut60 :: (HappyAbsSyn ) -> (Exp)-happyOut60 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut60 #-}-happyIn61 :: (Exp) -> (HappyAbsSyn )-happyIn61 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn61 #-}-happyOut61 :: (HappyAbsSyn ) -> (Exp)-happyOut61 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut61 #-}-happyIn62 :: (Exp) -> (HappyAbsSyn )-happyIn62 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn62 #-}-happyOut62 :: (HappyAbsSyn ) -> (Exp)-happyOut62 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut62 #-}-happyIn63 :: ([Exp]) -> (HappyAbsSyn )-happyIn63 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn63 #-}-happyOut63 :: (HappyAbsSyn ) -> ([Exp])-happyOut63 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut63 #-}-happyIn64 :: ([Exp]) -> (HappyAbsSyn )-happyIn64 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn64 #-}-happyOut64 :: (HappyAbsSyn ) -> ([Exp])-happyOut64 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut64 #-}-happyIn65 :: ([String]) -> (HappyAbsSyn )-happyIn65 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn65 #-}-happyOut65 :: (HappyAbsSyn ) -> ([String])-happyOut65 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut65 #-}-happyIn66 :: ([RHS]) -> (HappyAbsSyn )-happyIn66 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn66 #-}-happyOut66 :: (HappyAbsSyn ) -> ([RHS])-happyOut66 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut66 #-}-happyIn67 :: (RHS) -> (HappyAbsSyn )-happyIn67 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn67 #-}-happyOut67 :: (HappyAbsSyn ) -> (RHS)-happyOut67 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut67 #-}-happyIn68 :: (MinimumSize) -> (HappyAbsSyn )-happyIn68 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn68 #-}-happyOut68 :: (HappyAbsSyn ) -> (MinimumSize)-happyOut68 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut68 #-}-happyIn69 :: (Reg) -> (HappyAbsSyn )-happyIn69 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn69 #-}-happyOut69 :: (HappyAbsSyn ) -> (Reg)-happyOut69 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut69 #-}-happyIn70 :: (Reg) -> (HappyAbsSyn )-happyIn70 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn70 #-}-happyOut70 :: (HappyAbsSyn ) -> (Reg)-happyOut70 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut70 #-}-happyIn71 :: (Reg) -> (HappyAbsSyn )-happyIn71 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn71 #-}-happyOut71 :: (HappyAbsSyn ) -> (Reg)-happyOut71 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut71 #-}-happyIn72 :: (Reg) -> (HappyAbsSyn )-happyIn72 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn72 #-}-happyOut72 :: (HappyAbsSyn ) -> (Reg)-happyOut72 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut72 #-}-happyIn73 :: ([Ident]) -> (HappyAbsSyn )-happyIn73 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyIn73 #-}-happyOut73 :: (HappyAbsSyn ) -> ([Ident])-happyOut73 x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOut73 #-}-happyInTok :: (Token) -> (HappyAbsSyn )-happyInTok x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyInTok #-}-happyOutTok :: (HappyAbsSyn ) -> (Token)-happyOutTok x = Happy_GHC_Exts.unsafeCoerce# x-{-# INLINE happyOutTok #-}---happyActOffsets :: HappyAddr-happyActOffsets = HappyA# "\x45\x00\x45\x00\x45\x00\x64\x00\x64\x00\x00\x00\x64\x00\xbc\x00\xbd\x00\x71\x00\x71\x00\xda\x01\xd9\x01\xd8\x01\xd6\x01\xd7\x01\x7e\x01\xd5\x01\x00\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\xd4\x01\x00\x00\x00\x00\xd3\x01\x29\x00\x29\x00\x29\x00\x29\x00\xd2\x01\xcc\x01\x00\x00\xd1\x01\xcb\x01\x00\x00\x00\x00\x11\x00\xd0\x01\x89\x01\xc8\x01\x29\x00\xc9\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc9\x01\x00\x00\x3e\x00\xe2\xff\x01\x00\xc5\x01\x00\x00\xbc\x00\xc5\x01\xc5\x01\xc4\x01\xcf\x01\xc3\x01\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\xce\x01\xca\x01\x00\x00\xc2\x01\x07\x00\x07\x00\x00\x00\x00\x00\x00\x00\x07\x00\xc2\x01\xc2\x01\xc2\x01\xc2\x01\x6a\x01\x00\x00\xc2\x01\xc2\x01\xc1\x01\xc1\x01\xcd\x01\xbf\x01\xc0\x01\xc7\x01\xbe\x01\xbc\x01\xc6\x01\xba\x01\xba\x01\xba\x01\x00\x00\xba\x01\xbd\x01\xb9\x01\x00\x00\xb4\x01\x5e\x00\x00\x00\xb4\x01\xbd\x00\x00\x00\xb4\x01\x00\x00\xb4\x01\xbb\x01\xb6\x01\xb5\x01\xb3\x01\xbd\x00\xb3\x01\x44\x00\x68\x01\xaf\x01\xad\x01\xa8\x01\xa8\x01\xa6\x01\x7c\x00\x9c\x01\xb7\x01\x9b\x01\x00\x00\x8b\x00\xb0\x01\x9a\x01\x00\x00\xb8\x01\x99\x01\x98\x01\x98\x01\x00\x00\x00\x00\x64\x00\x45\x00\x93\x01\x64\x00\x00\x00\x29\x00\xbd\x00\xbd\x00\xb2\x01\x8e\x01\x00\x00\x96\x01\x00\x00\xae\x01\x00\x00\x95\x01\x00\x00\x95\x01\x91\x01\xbd\x00\xab\x01\xb1\x01\x00\x00\xfe\xff\x00\x00\x6e\x00\x84\x01\xa9\x01\xa7\x01\xa7\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa5\x01\xac\x01\x07\x00\x07\x00\x00\x00\x8d\x01\x00\x00\x10\x01\x29\x00\x00\x00\x00\x00\x00\x00\x85\x01\xa3\x01\xaa\x01\x29\x00\x29\x00\x00\x00\x00\x00\x00\x00\x29\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa2\x01\x00\x00\x00\x00\x00\x00\x00\x00\x9d\x01\x00\x00\x00\x00\xa1\x01\x00\x00\x00\x00\xf6\xff\x80\x01\xbd\x00\x00\x00\x29\x00\x00\x00\x80\x01\x80\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9e\x01\x7e\x01\x07\x00\x00\x00\xa4\x01\xa0\x01\x97\x01\x00\x00\xbc\x00\x00\x00\x8c\x01\x00\x00\xbc\x00\x00\x00\x78\x01\x94\x01\x9f\x01\x00\x00\x00\x00"#--happyGotoOffsets :: HappyAddr-happyGotoOffsets = HappyA# "\x86\x00\xa3\x00\xa1\x00\x58\x01\x6e\x01\x90\x01\x70\x01\x82\x01\x86\x01\x77\x01\x06\x00\x87\x01\x8f\x01\xb2\x00\x8b\x01\x48\x01\x74\x01\x0c\x00\x7f\x01\x30\x01\x4b\x01\x50\x01\x05\x01\xf6\x00\xc7\x00\x3c\x01\x31\x00\x3e\x01\xc0\x00\xb0\x00\x46\x00\xaa\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x9e\x00\x92\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8a\x01\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2b\x01\xd9\x00\x00\x00\x00\x00\x00\x00\xfb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x7a\x01\x6b\x01\x28\x01\x00\x00\x00\x00\x00\x00\x00\x00\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x01\x00\x00\x00\x00\x83\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x73\x01\x5d\x01\x56\x01\x61\x01\x22\x00\x72\x01\xc5\x00\x00\x00\x46\x01\x1d\x01\xfe\x00\x0b\x01\xde\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5e\x01\x91\x00\x04\x00\x67\x01\x00\x00\x9a\x00\x35\x01\x0a\x01\x00\x00\xee\x00\x00\x00\x79\x00\x00\x00\x00\x00\x00\x00\xe9\x00\xfc\xff\xe0\x00\xce\x00\xe7\x00\x00\x00\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7d\x00\x00\x00\x88\x01\x24\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x26\x01\xd4\x00\x00\x00\x4b\x00\x37\x01\x00\x00\x39\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xcf\x00\x02\x00\x00\x00\x96\x00\x42\x00\xb5\x00\x4e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8e\x00\x21\x01\x94\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\x00\x00\x00\xec\xff\x13\x00\xde\x00\x00\x00\x72\x00\x00\x00\x00\x00\x00\x00\x00\x00"#--happyDefActions :: HappyAddr-happyDefActions = HappyA# "\xd5\xff\x00\x00\xd5\xff\xd1\xff\xd1\xff\xce\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xad\xff\xaa\xff\x00\x00\xa5\xff\x00\x00\xa1\xff\x00\x00\x00\x00\x00\x00\x00\x00\x92\xff\x00\x00\xce\xff\xce\xff\x89\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xff\x75\xff\x00\x00\xdd\xff\x7f\xff\x84\xff\x76\xff\x87\xff\x00\x00\x00\x00\x00\x00\x78\xff\x7c\xff\x80\xff\x7b\xff\x79\xff\x7a\xff\x00\x00\xdb\xff\x00\x00\x00\x00\x00\x00\x00\x00\x8a\xff\x8b\xff\x00\x00\x00\x00\x8d\xff\x8f\xff\x00\x00\x98\xff\x9b\xff\x9a\xff\x99\xff\x97\xff\x91\xff\x9e\xff\x9c\xff\x00\x00\x00\x00\x92\xff\xdc\xff\xda\xff\x9b\xff\x94\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa2\xff\x00\x00\x00\x00\x00\x00\x00\x00\xa7\xff\x00\x00\x00\x00\xa9\xff\x00\x00\xad\xff\xac\xff\x00\x00\x00\x00\x00\x00\xb4\xff\x00\x00\x00\x00\x00\x00\xb3\xff\x00\x00\xb8\xff\xb9\xff\x00\x00\x00\x00\xbc\xff\x00\x00\xbb\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x89\xff\x89\xff\x00\x00\x00\x00\x00\x00\xd0\xff\x00\x00\xd2\xff\xb4\xff\xd4\xff\x00\x00\xd8\xff\x00\x00\x00\x00\x00\x00\x00\x00\xd9\xff\xd6\xff\x00\x00\xd5\xff\x00\x00\xd1\xff\xcd\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbf\xff\x00\x00\xbd\xff\x00\x00\xc6\xff\x00\x00\xa1\xff\xcb\xff\x00\x00\x00\x00\x00\x00\xb5\xff\xb7\xff\x00\x00\xb2\xff\x00\x00\xad\xff\x00\x00\xaa\xff\xaa\xff\xa6\xff\xa4\xff\xa3\xff\xa0\xff\x93\xff\x00\x00\x00\x00\x00\x00\x92\xff\x9d\xff\x00\x00\xce\xff\x88\xff\x00\x00\x83\xff\x82\xff\x81\xff\x00\x00\x00\x00\x00\x00\x00\x00\x85\xff\x77\xff\x7e\xff\x7d\xff\x86\xff\x8c\xff\x8e\xff\x90\xff\x9f\xff\x95\xff\x96\xff\x00\x00\xa8\xff\xae\xff\xab\xff\xb1\xff\x00\x00\xb6\xff\xba\xff\x00\x00\xc2\xff\xca\xff\x00\x00\x00\x00\x00\x00\xbe\xff\x00\x00\xce\xff\x00\x00\x00\x00\xc8\xff\xcf\xff\x74\xff\xd3\xff\xd7\xff\xc4\xff\xc5\xff\xc1\xff\xc7\xff\x00\x00\xa5\xff\x00\x00\xce\xff\x00\x00\x00\x00\x00\x00\xb0\xff\xcc\xff\xc0\xff\x89\xff\xce\xff\xc9\xff\xc3\xff\xad\xff\x00\x00\x00\x00\xaf\xff"#--happyCheck :: HappyAddr-happyCheck = HappyA# "\xff\xff\x0b\x00\x01\x00\x01\x00\x01\x00\x01\x00\x08\x00\x01\x00\x01\x00\x27\x00\x01\x00\x0d\x00\x20\x00\x01\x00\x0d\x00\x0d\x00\x2e\x00\x10\x00\x01\x00\x17\x00\x0d\x00\x0f\x00\x15\x00\x06\x00\x17\x00\x16\x00\x03\x00\x1a\x00\x1b\x00\x0a\x00\x0d\x00\x03\x00\x2a\x00\x10\x00\x16\x00\x01\x00\x01\x00\x24\x00\x15\x00\x26\x00\x17\x00\x25\x00\x01\x00\x1a\x00\x1b\x00\x2c\x00\x25\x00\x2e\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x24\x00\x0d\x00\x26\x00\x21\x00\x10\x00\x23\x00\x0a\x00\x03\x00\x2c\x00\x15\x00\x23\x00\x17\x00\x03\x00\x04\x00\x1a\x00\x1b\x00\x01\x00\x01\x00\x25\x00\x25\x00\x03\x00\x0c\x00\x00\x00\x0a\x00\x24\x00\x00\x00\x26\x00\x1f\x00\x0d\x00\x0d\x00\x0f\x00\x0f\x00\x2c\x00\x11\x00\x12\x00\x13\x00\x14\x00\x21\x00\x16\x00\x23\x00\x18\x00\x19\x00\x01\x00\x1e\x00\x1f\x00\x1d\x00\x1e\x00\x1f\x00\x01\x00\x21\x00\x22\x00\x1d\x00\x23\x00\x25\x00\x0d\x00\x2e\x00\x0f\x00\x2a\x00\x2a\x00\x02\x00\x0d\x00\x01\x00\x0f\x00\x02\x00\x11\x00\x12\x00\x13\x00\x14\x00\x00\x00\x16\x00\x0d\x00\x18\x00\x19\x00\x0d\x00\x02\x00\x0f\x00\x1d\x00\x1e\x00\x1f\x00\x12\x00\x21\x00\x22\x00\x01\x00\x2a\x00\x0d\x00\x02\x00\x05\x00\x06\x00\x07\x00\x2a\x00\x12\x00\x05\x00\x0b\x00\x01\x00\x08\x00\x0e\x00\x0f\x00\x1d\x00\x06\x00\x07\x00\x03\x00\x12\x00\x2a\x00\x0b\x00\x03\x00\x0a\x00\x0e\x00\x0f\x00\x03\x00\x01\x00\x15\x00\x01\x00\x29\x00\x2a\x00\x06\x00\x07\x00\x06\x00\x2e\x00\x25\x00\x0b\x00\x03\x00\x0b\x00\x0e\x00\x0f\x00\x0e\x00\x0f\x00\x03\x00\x02\x00\x00\x00\x25\x00\x21\x00\x22\x00\x23\x00\x24\x00\x21\x00\x22\x00\x23\x00\x24\x00\x21\x00\x22\x00\x23\x00\x24\x00\x03\x00\x12\x00\x00\x00\x25\x00\x00\x00\x25\x00\x0d\x00\x0d\x00\x21\x00\x22\x00\x23\x00\x24\x00\x00\x00\x02\x00\x21\x00\x22\x00\x23\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x00\x00\x21\x00\x1d\x00\x23\x00\x1d\x00\x29\x00\x2a\x00\x2a\x00\x01\x00\x00\x00\x0c\x00\x0d\x00\x18\x00\x19\x00\x1a\x00\x01\x00\x1c\x00\x18\x00\x19\x00\x1a\x00\x0d\x00\x1c\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x01\x00\x01\x00\x01\x00\x10\x00\x18\x00\x19\x00\x1a\x00\x14\x00\x1c\x00\x03\x00\x04\x00\x1a\x00\x1b\x00\x0d\x00\x0f\x00\x10\x00\x1a\x00\x1b\x00\x0c\x00\x14\x00\x20\x00\x1a\x00\x1b\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x11\x00\x01\x00\x13\x00\x10\x00\x18\x00\x19\x00\x1a\x00\x14\x00\x20\x00\x18\x00\x19\x00\x1a\x00\x0a\x00\x0d\x00\x18\x00\x19\x00\x1a\x00\x0a\x00\x01\x00\x18\x00\x19\x00\x1a\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x1e\x00\x1f\x00\x01\x00\x10\x00\x01\x00\x1e\x00\x1f\x00\x14\x00\x00\x00\x20\x00\x01\x00\x08\x00\x09\x00\x01\x00\x0b\x00\x19\x00\x1a\x00\x0e\x00\x0f\x00\x01\x00\x0b\x00\x1a\x00\x00\x00\x0e\x00\x0f\x00\x0d\x00\x01\x00\x09\x00\x01\x00\x0b\x00\x01\x00\x01\x00\x0e\x00\x0f\x00\x09\x00\x01\x00\x0b\x00\x00\x00\x0b\x00\x0e\x00\x0f\x00\x0e\x00\x0f\x00\x0e\x00\x0f\x00\x00\x00\x01\x00\x01\x00\x0e\x00\x0f\x00\x01\x00\x20\x00\x15\x00\x00\x00\x23\x00\x03\x00\x04\x00\x0c\x00\x0d\x00\x0d\x00\x29\x00\x00\x00\x0d\x00\x2a\x00\x0c\x00\x17\x00\x10\x00\x2e\x00\x11\x00\x0a\x00\x13\x00\x11\x00\x1f\x00\x13\x00\x21\x00\x11\x00\x02\x00\x0e\x00\x2b\x00\x0d\x00\x05\x00\x02\x00\x09\x00\x1c\x00\x29\x00\x09\x00\x0e\x00\x02\x00\x28\x00\x02\x00\x2b\x00\x0e\x00\x0e\x00\x01\x00\x0e\x00\x0d\x00\x07\x00\x29\x00\x0e\x00\x2a\x00\x0e\x00\x0a\x00\x09\x00\x2b\x00\x2a\x00\x29\x00\x29\x00\x08\x00\x0a\x00\x07\x00\x2a\x00\x1c\x00\x08\x00\x2e\x00\x0e\x00\x2e\x00\x2e\x00\x2e\x00\x05\x00\x05\x00\x0d\x00\x01\x00\xff\xff\x2a\x00\x22\x00\x08\x00\x05\x00\x05\x00\xff\xff\x05\x00\x2a\x00\x01\x00\xff\xff\xff\xff\x01\x00\xff\xff\x2a\x00\x29\x00\xff\xff\x2a\x00\xff\xff\x2e\x00\x0d\x00\xff\xff\xff\xff\x0d\x00\x2b\x00\x2e\x00\xff\xff\x29\x00\x27\x00\x2e\x00\x2e\x00\xff\xff\x1c\x00\x2e\x00\x2e\x00\x29\x00\x2e\x00\xff\xff\x29\x00\x2e\x00\x27\x00\xff\xff\x2e\x00\xff\xff\xff\xff\x2a\x00\x29\x00\xff\xff\x2a\x00\xff\xff\xff\xff\xff\xff\x2b\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#--happyTable :: HappyAddr-happyTable = HappyA# "\x00\x00\xea\x00\x2c\x00\x6a\x00\x54\x00\x23\x00\xa7\x00\x63\x00\x4a\x00\xb9\x00\x23\x00\xab\x00\xf4\x00\x54\x00\x2d\x00\xe7\x00\xff\xff\x2e\x00\x2c\x00\xd6\x00\x4b\x00\x64\x00\x2f\x00\xc0\x00\x30\x00\xae\x00\x26\x00\x31\x00\x32\x00\xf3\x00\x2d\x00\x26\x00\x26\x00\x2e\x00\x55\x00\x23\x00\x23\x00\x33\x00\x2f\x00\x34\x00\x30\x00\xe0\x00\x2c\x00\x31\x00\x32\x00\x35\x00\x8c\x00\xff\xff\x23\x00\x26\x00\x4c\x00\x35\x00\x4d\x00\x33\x00\x2d\x00\x34\x00\xc0\x00\x2e\x00\x29\x00\x3a\x00\x26\x00\x35\x00\x2f\x00\xb7\x00\x30\x00\xba\x00\xbb\x00\x31\x00\x32\x00\x66\x00\x66\x00\x9b\x00\x24\x00\x26\x00\xbc\x00\x3e\x00\x3a\x00\x33\x00\xe3\x00\x34\x00\x3b\x00\x67\x00\x67\x00\x68\x00\x68\x00\x35\x00\x73\x00\x74\x00\x75\x00\x76\x00\xc4\x00\x77\x00\x29\x00\x78\x00\x79\x00\xa5\x00\xe5\x00\x3d\x00\x7a\x00\x7b\x00\x7c\x00\x66\x00\x7d\x00\x7e\x00\xc6\x00\x35\x00\x89\x00\x67\x00\xff\xff\x68\x00\x26\x00\x26\x00\xd0\x00\x67\x00\x66\x00\x68\x00\x5f\x00\x73\x00\x74\x00\x75\x00\x76\x00\x3e\x00\x77\x00\xd1\x00\x78\x00\x79\x00\x67\x00\x5f\x00\x68\x00\x7a\x00\x7b\x00\x7c\x00\xf6\x00\x7d\x00\x7e\x00\x83\x00\x26\x00\x6d\x00\x5f\x00\x8a\x00\x84\x00\x8b\x00\x26\x00\xce\x00\x90\x00\x86\x00\x83\x00\x75\xff\x71\x00\x69\x00\xd9\x00\x84\x00\xe1\x00\x26\x00\xa8\x00\x26\x00\x86\x00\x26\x00\xef\x00\x71\x00\x69\x00\x26\x00\x83\x00\xf1\x00\x83\x00\x23\x00\x26\x00\x84\x00\x85\x00\x89\x00\xff\xff\x87\x00\x86\x00\x26\x00\x86\x00\x71\x00\x69\x00\x71\x00\x69\x00\x26\x00\x5f\x00\xe4\x00\x87\x00\x27\x00\x28\x00\x29\x00\xe6\x00\x27\x00\x28\x00\x29\x00\xde\x00\x27\x00\x28\x00\x29\x00\xbe\x00\x26\x00\x60\x00\x3e\x00\x87\x00\x3e\x00\x87\x00\x6d\x00\x6d\x00\x27\x00\x28\x00\x29\x00\x2a\x00\xe8\x00\xd4\x00\x27\x00\x36\x00\x29\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x6d\x00\x6a\x00\xd5\x00\x37\x00\x97\x00\x29\x00\x3f\x00\x23\x00\x26\x00\x26\x00\x6a\x00\xd7\x00\x91\x00\x6f\x00\x45\x00\x46\x00\x47\x00\xda\x00\xc7\x00\x45\x00\x46\x00\x47\x00\xd3\x00\xb0\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x4d\x00\x42\x00\x43\x00\x44\x00\x40\x00\x4d\x00\x42\x00\x43\x00\x44\x00\x40\x00\x4d\x00\x42\x00\x43\x00\x44\x00\x63\x00\x6a\x00\x92\x00\x59\x00\x45\x00\x46\x00\x47\x00\xd1\x00\x48\x00\xba\x00\xbb\x00\x4e\x00\xaf\x00\xdc\x00\xa2\x00\x59\x00\x4e\x00\xb4\x00\xbc\x00\xa3\x00\x93\x00\x4e\x00\x4f\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x5c\x00\x6a\x00\xcb\x00\x59\x00\xf0\x00\x46\x00\x47\x00\xab\x00\x94\x00\xc8\x00\x46\x00\x47\x00\x3a\x00\xdd\x00\xb1\x00\x46\x00\x47\x00\x3a\x00\x95\x00\x52\x00\x46\x00\x47\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x40\x00\x4d\x00\x42\x00\x43\x00\x44\x00\xc5\x00\x3d\x00\x9d\x00\x59\x00\x63\x00\x3c\x00\x3d\x00\x5a\x00\x9e\x00\x38\x00\x63\x00\x81\x00\x82\x00\x6a\x00\x80\x00\x51\x00\x47\x00\x71\x00\x69\x00\x63\x00\xe2\x00\x50\x00\xac\x00\x71\x00\x69\x00\x9c\x00\x63\x00\xdf\x00\x63\x00\x80\x00\x63\x00\x9f\x00\x71\x00\x69\x00\x7f\x00\x63\x00\x80\x00\xad\x00\x70\x00\x71\x00\x69\x00\x71\x00\x69\x00\x9a\x00\x69\x00\x6d\x00\x6a\x00\x6a\x00\x68\x00\x69\x00\x6a\x00\x99\x00\x56\x00\xbc\x00\x9a\x00\xba\x00\xbb\x00\x6e\x00\x6f\x00\xa1\x00\x23\x00\xbd\x00\x6b\x00\x26\x00\xbc\x00\x53\x00\x62\x00\xff\xff\x5c\x00\x7e\x00\xcc\x00\x5c\x00\x58\x00\x5d\x00\x59\x00\x61\x00\xf9\x00\xf8\x00\x4c\x00\xf6\x00\xee\x00\xef\x00\xf3\x00\x3a\x00\x23\x00\xeb\x00\xec\x00\xc2\x00\xc4\x00\xca\x00\x4c\x00\xed\x00\xc3\x00\x5c\x00\xcb\x00\x5f\x00\xd9\x00\x23\x00\xce\x00\x26\x00\xd3\x00\x8f\x00\xdc\x00\x4c\x00\x26\x00\x23\x00\x23\x00\x8e\x00\x91\x00\xa1\x00\x26\x00\x3a\x00\xa7\x00\xff\xff\xa6\x00\xff\xff\xff\xff\xff\xff\xa8\x00\xaa\x00\xab\x00\x5c\x00\x00\x00\x26\x00\x97\x00\xb3\x00\xb4\x00\xb6\x00\x00\x00\x90\x00\x26\x00\x5c\x00\x00\x00\x00\x00\x5c\x00\x00\x00\x26\x00\x23\x00\x00\x00\x26\x00\x00\x00\xff\xff\x5f\x00\x00\x00\x00\x00\x5f\x00\x4c\x00\xff\xff\x00\x00\x23\x00\xb7\x00\xff\xff\xff\xff\x00\x00\x3a\x00\xff\xff\xff\xff\x23\x00\xff\xff\x00\x00\x23\x00\xff\xff\xb9\x00\x00\x00\xff\xff\x00\x00\x00\x00\x26\x00\x23\x00\x00\x00\x26\x00\x00\x00\x00\x00\x00\x00\x4c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#--happyReduceArr = Happy_Data_Array.array (33, 139) [-	(33 , happyReduce_33),-	(34 , happyReduce_34),-	(35 , happyReduce_35),-	(36 , happyReduce_36),-	(37 , happyReduce_37),-	(38 , happyReduce_38),-	(39 , happyReduce_39),-	(40 , happyReduce_40),-	(41 , happyReduce_41),-	(42 , happyReduce_42),-	(43 , happyReduce_43),-	(44 , happyReduce_44),-	(45 , happyReduce_45),-	(46 , happyReduce_46),-	(47 , happyReduce_47),-	(48 , happyReduce_48),-	(49 , happyReduce_49),-	(50 , happyReduce_50),-	(51 , happyReduce_51),-	(52 , happyReduce_52),-	(53 , happyReduce_53),-	(54 , happyReduce_54),-	(55 , happyReduce_55),-	(56 , happyReduce_56),-	(57 , happyReduce_57),-	(58 , happyReduce_58),-	(59 , happyReduce_59),-	(60 , happyReduce_60),-	(61 , happyReduce_61),-	(62 , happyReduce_62),-	(63 , happyReduce_63),-	(64 , happyReduce_64),-	(65 , happyReduce_65),-	(66 , happyReduce_66),-	(67 , happyReduce_67),-	(68 , happyReduce_68),-	(69 , happyReduce_69),-	(70 , happyReduce_70),-	(71 , happyReduce_71),-	(72 , happyReduce_72),-	(73 , happyReduce_73),-	(74 , happyReduce_74),-	(75 , happyReduce_75),-	(76 , happyReduce_76),-	(77 , happyReduce_77),-	(78 , happyReduce_78),-	(79 , happyReduce_79),-	(80 , happyReduce_80),-	(81 , happyReduce_81),-	(82 , happyReduce_82),-	(83 , happyReduce_83),-	(84 , happyReduce_84),-	(85 , happyReduce_85),-	(86 , happyReduce_86),-	(87 , happyReduce_87),-	(88 , happyReduce_88),-	(89 , happyReduce_89),-	(90 , happyReduce_90),-	(91 , happyReduce_91),-	(92 , happyReduce_92),-	(93 , happyReduce_93),-	(94 , happyReduce_94),-	(95 , happyReduce_95),-	(96 , happyReduce_96),-	(97 , happyReduce_97),-	(98 , happyReduce_98),-	(99 , happyReduce_99),-	(100 , happyReduce_100),-	(101 , happyReduce_101),-	(102 , happyReduce_102),-	(103 , happyReduce_103),-	(104 , happyReduce_104),-	(105 , happyReduce_105),-	(106 , happyReduce_106),-	(107 , happyReduce_107),-	(108 , happyReduce_108),-	(109 , happyReduce_109),-	(110 , happyReduce_110),-	(111 , happyReduce_111),-	(112 , happyReduce_112),-	(113 , happyReduce_113),-	(114 , happyReduce_114),-	(115 , happyReduce_115),-	(116 , happyReduce_116),-	(117 , happyReduce_117),-	(118 , happyReduce_118),-	(119 , happyReduce_119),-	(120 , happyReduce_120),-	(121 , happyReduce_121),-	(122 , happyReduce_122),-	(123 , happyReduce_123),-	(124 , happyReduce_124),-	(125 , happyReduce_125),-	(126 , happyReduce_126),-	(127 , happyReduce_127),-	(128 , happyReduce_128),-	(129 , happyReduce_129),-	(130 , happyReduce_130),-	(131 , happyReduce_131),-	(132 , happyReduce_132),-	(133 , happyReduce_133),-	(134 , happyReduce_134),-	(135 , happyReduce_135),-	(136 , happyReduce_136),-	(137 , happyReduce_137),-	(138 , happyReduce_138),-	(139 , happyReduce_139)-	]--happy_n_terms = 47 :: Int-happy_n_nonterms = 38 :: Int--happyReduce_33 = happySpecReduce_1  0# happyReduction_33-happyReduction_33 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TL happy_var_1)) -> -	happyIn36-		 (happy_var_1-	)}--happyReduce_34 = happySpecReduce_1  1# happyReduction_34-happyReduction_34 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TV happy_var_1)) -> -	happyIn37-		 (Ident happy_var_1-	)}--happyReduce_35 = happySpecReduce_1  2# happyReduction_35-happyReduction_35 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TI happy_var_1)) -> -	happyIn38-		 ((read ( happy_var_1)) :: Integer-	)}--happyReduce_36 = happySpecReduce_1  3# happyReduction_36-happyReduction_36 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TC happy_var_1)) -> -	happyIn39-		 ((read ( happy_var_1)) :: Char-	)}--happyReduce_37 = happySpecReduce_1  4# happyReduction_37-happyReduction_37 happy_x_1-	 =  case happyOutTok happy_x_1 of { (PT _ (TD happy_var_1)) -> -	happyIn40-		 ((read ( happy_var_1)) :: Double-	)}--happyReduce_38 = happySpecReduce_1  5# happyReduction_38-happyReduction_38 happy_x_1-	 =  case happyOut43 happy_x_1 of { happy_var_1 -> -	happyIn41-		 (LGr happy_var_1-	)}--happyReduce_39 = happySpecReduce_1  6# happyReduction_39-happyReduction_39 happy_x_1-	 =  case happyOut47 happy_x_1 of { happy_var_1 -> -	happyIn42-		 (DefAll happy_var_1-	)}--happyReduce_40 = happySpecReduce_3  6# happyReduction_40-happyReduction_40 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut73 happy_x_1 of { happy_var_1 -> -	case happyOut47 happy_x_3 of { happy_var_3 -> -	happyIn42-		 (DefSome happy_var_1 happy_var_3-	)}}--happyReduce_41 = happySpecReduce_2  6# happyReduction_41-happyReduction_41 happy_x_2-	happy_x_1-	 =  case happyOut73 happy_x_2 of { happy_var_2 -> -	happyIn42-		 (LDefView happy_var_2-	)}--happyReduce_42 = happySpecReduce_0  7# happyReduction_42-happyReduction_42  =  happyIn43-		 ([]-	)--happyReduce_43 = happySpecReduce_1  7# happyReduction_43-happyReduction_43 happy_x_1-	 =  case happyOut42 happy_x_1 of { happy_var_1 -> -	happyIn43-		 ((:[]) happy_var_1-	)}--happyReduce_44 = happySpecReduce_3  7# happyReduction_44-happyReduction_44 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut42 happy_x_1 of { happy_var_1 -> -	case happyOut43 happy_x_3 of { happy_var_3 -> -	happyIn43-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_45 = happySpecReduce_1  8# happyReduction_45-happyReduction_45 happy_x_1-	 =  case happyOut45 happy_x_1 of { happy_var_1 -> -	happyIn44-		 (Grammar happy_var_1-	)}--happyReduce_46 = happySpecReduce_0  9# happyReduction_46-happyReduction_46  =  happyIn45-		 ([]-	)--happyReduce_47 = happySpecReduce_1  9# happyReduction_47-happyReduction_47 happy_x_1-	 =  case happyOut47 happy_x_1 of { happy_var_1 -> -	happyIn45-		 ((:[]) happy_var_1-	)}--happyReduce_48 = happySpecReduce_3  9# happyReduction_48-happyReduction_48 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut47 happy_x_1 of { happy_var_1 -> -	case happyOut45 happy_x_3 of { happy_var_3 -> -	happyIn45-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_49 = happySpecReduce_0  10# happyReduction_49-happyReduction_49  =  happyIn46-		 ([]-	)--happyReduce_50 = happySpecReduce_2  10# happyReduction_50-happyReduction_50 happy_x_2-	happy_x_1-	 =  case happyOut46 happy_x_1 of { happy_var_1 -> -	case happyOut48 happy_x_2 of { happy_var_2 -> -	happyIn46-		 (flip (:) happy_var_1 happy_var_2-	)}}--happyReduce_51 = happyReduce 5# 11# happyReduction_51-happyReduction_51 (happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut50 happy_x_1 of { happy_var_1 -> -	case happyOut49 happy_x_3 of { happy_var_3 -> -	case happyOut46 happy_x_5 of { happy_var_5 -> -	happyIn47-		 (Rule happy_var_1 happy_var_3 (reverse happy_var_5)-	) `HappyStk` happyRest}}}--happyReduce_52 = happySpecReduce_2  11# happyReduction_52-happyReduction_52 happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn47-		 (Comment happy_var_2-	)}--happyReduce_53 = happySpecReduce_3  11# happyReduction_53-happyReduction_53 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	case happyOut36 happy_x_3 of { happy_var_3 -> -	happyIn47-		 (Comments happy_var_2 happy_var_3-	)}}--happyReduce_54 = happyReduce 6# 11# happyReduction_54-happyReduction_54 (happy_x_6 `HappyStk`-	happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut50 happy_x_2 of { happy_var_2 -> -	case happyOut49 happy_x_4 of { happy_var_4 -> -	case happyOut46 happy_x_6 of { happy_var_6 -> -	happyIn47-		 (Internal happy_var_2 happy_var_4 (reverse happy_var_6)-	) `HappyStk` happyRest}}}--happyReduce_55 = happySpecReduce_3  11# happyReduction_55-happyReduction_55 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut37 happy_x_2 of { happy_var_2 -> -	case happyOut72 happy_x_3 of { happy_var_3 -> -	happyIn47-		 (Token happy_var_2 happy_var_3-	)}}--happyReduce_56 = happyReduce 4# 11# happyReduction_56-happyReduction_56 (happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut37 happy_x_3 of { happy_var_3 -> -	case happyOut72 happy_x_4 of { happy_var_4 -> -	happyIn47-		 (PosToken happy_var_3 happy_var_4-	) `HappyStk` happyRest}}--happyReduce_57 = happySpecReduce_2  11# happyReduction_57-happyReduction_57 happy_x_2-	happy_x_1-	 =  case happyOut73 happy_x_2 of { happy_var_2 -> -	happyIn47-		 (Entryp happy_var_2-	)}--happyReduce_58 = happyReduce 4# 11# happyReduction_58-happyReduction_58 (happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut68 happy_x_2 of { happy_var_2 -> -	case happyOut49 happy_x_3 of { happy_var_3 -> -	case happyOut36 happy_x_4 of { happy_var_4 -> -	happyIn47-		 (Separator happy_var_2 happy_var_3 happy_var_4-	) `HappyStk` happyRest}}}--happyReduce_59 = happyReduce 4# 11# happyReduction_59-happyReduction_59 (happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut68 happy_x_2 of { happy_var_2 -> -	case happyOut49 happy_x_3 of { happy_var_3 -> -	case happyOut36 happy_x_4 of { happy_var_4 -> -	happyIn47-		 (Terminator happy_var_2 happy_var_3 happy_var_4-	) `HappyStk` happyRest}}}--happyReduce_60 = happyReduce 6# 11# happyReduction_60-happyReduction_60 (happy_x_6 `HappyStk`-	happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut49 happy_x_2 of { happy_var_2 -> -	case happyOut36 happy_x_3 of { happy_var_3 -> -	case happyOut36 happy_x_4 of { happy_var_4 -> -	case happyOut57 happy_x_5 of { happy_var_5 -> -	case happyOut68 happy_x_6 of { happy_var_6 -> -	happyIn47-		 (Delimiters happy_var_2 happy_var_3 happy_var_4 happy_var_5 happy_var_6-	) `HappyStk` happyRest}}}}}--happyReduce_61 = happySpecReduce_3  11# happyReduction_61-happyReduction_61 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut37 happy_x_2 of { happy_var_2 -> -	case happyOut38 happy_x_3 of { happy_var_3 -> -	happyIn47-		 (Coercions happy_var_2 happy_var_3-	)}}--happyReduce_62 = happyReduce 4# 11# happyReduction_62-happyReduction_62 (happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut37 happy_x_2 of { happy_var_2 -> -	case happyOut66 happy_x_4 of { happy_var_4 -> -	happyIn47-		 (Rules happy_var_2 happy_var_4-	) `HappyStk` happyRest}}--happyReduce_63 = happyReduce 5# 11# happyReduction_63-happyReduction_63 (happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut37 happy_x_2 of { happy_var_2 -> -	case happyOut59 happy_x_3 of { happy_var_3 -> -	case happyOut60 happy_x_5 of { happy_var_5 -> -	happyIn47-		 (Function happy_var_2 (reverse happy_var_3) happy_var_5-	) `HappyStk` happyRest}}}--happyReduce_64 = happySpecReduce_2  11# happyReduction_64-happyReduction_64 happy_x_2-	happy_x_1-	 =  case happyOut65 happy_x_2 of { happy_var_2 -> -	happyIn47-		 (Layout happy_var_2-	)}--happyReduce_65 = happySpecReduce_3  11# happyReduction_65-happyReduction_65 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut65 happy_x_3 of { happy_var_3 -> -	happyIn47-		 (LayoutStop happy_var_3-	)}--happyReduce_66 = happySpecReduce_2  11# happyReduction_66-happyReduction_66 happy_x_2-	happy_x_1-	 =  happyIn47-		 (LayoutTop-	)--happyReduce_67 = happySpecReduce_1  12# happyReduction_67-happyReduction_67 happy_x_1-	 =  case happyOut36 happy_x_1 of { happy_var_1 -> -	happyIn48-		 (Terminal happy_var_1-	)}--happyReduce_68 = happySpecReduce_1  12# happyReduction_68-happyReduction_68 happy_x_1-	 =  case happyOut49 happy_x_1 of { happy_var_1 -> -	happyIn48-		 (NTerminal happy_var_1-	)}--happyReduce_69 = happySpecReduce_3  13# happyReduction_69-happyReduction_69 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut49 happy_x_2 of { happy_var_2 -> -	happyIn49-		 (ListCat happy_var_2-	)}--happyReduce_70 = happySpecReduce_1  13# happyReduction_70-happyReduction_70 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn49-		 (IdCat happy_var_1-	)}--happyReduce_71 = happySpecReduce_1  14# happyReduction_71-happyReduction_71 happy_x_1-	 =  case happyOut51 happy_x_1 of { happy_var_1 -> -	happyIn50-		 (LabNoP happy_var_1-	)}--happyReduce_72 = happySpecReduce_2  14# happyReduction_72-happyReduction_72 happy_x_2-	happy_x_1-	 =  case happyOut51 happy_x_1 of { happy_var_1 -> -	case happyOut56 happy_x_2 of { happy_var_2 -> -	happyIn50-		 (LabP happy_var_1 happy_var_2-	)}}--happyReduce_73 = happySpecReduce_3  14# happyReduction_73-happyReduction_73 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut51 happy_x_1 of { happy_var_1 -> -	case happyOut51 happy_x_2 of { happy_var_2 -> -	case happyOut56 happy_x_3 of { happy_var_3 -> -	happyIn50-		 (LabPF happy_var_1 happy_var_2 happy_var_3-	)}}}--happyReduce_74 = happySpecReduce_2  14# happyReduction_74-happyReduction_74 happy_x_2-	happy_x_1-	 =  case happyOut51 happy_x_1 of { happy_var_1 -> -	case happyOut51 happy_x_2 of { happy_var_2 -> -	happyIn50-		 (LabF happy_var_1 happy_var_2-	)}}--happyReduce_75 = happySpecReduce_1  15# happyReduction_75-happyReduction_75 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn51-		 (Id happy_var_1-	)}--happyReduce_76 = happySpecReduce_1  15# happyReduction_76-happyReduction_76 happy_x_1-	 =  happyIn51-		 (Wild-	)--happyReduce_77 = happySpecReduce_2  15# happyReduction_77-happyReduction_77 happy_x_2-	happy_x_1-	 =  happyIn51-		 (ListE-	)--happyReduce_78 = happySpecReduce_3  15# happyReduction_78-happyReduction_78 happy_x_3-	happy_x_2-	happy_x_1-	 =  happyIn51-		 (ListCons-	)--happyReduce_79 = happyReduce 5# 15# happyReduction_79-happyReduction_79 (happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = happyIn51-		 (ListOne-	) `HappyStk` happyRest--happyReduce_80 = happyReduce 9# 16# happyReduction_80-happyReduction_80 (happy_x_9 `HappyStk`-	happy_x_8 `HappyStk`-	happy_x_7 `HappyStk`-	happy_x_6 `HappyStk`-	happy_x_5 `HappyStk`-	happy_x_4 `HappyStk`-	happy_x_3 `HappyStk`-	happy_x_2 `HappyStk`-	happy_x_1 `HappyStk`-	happyRest)-	 = case happyOut55 happy_x_3 of { happy_var_3 -> -	case happyOut54 happy_x_7 of { happy_var_7 -> -	happyIn52-		 (ProfIt happy_var_3 happy_var_7-	) `HappyStk` happyRest}}--happyReduce_81 = happySpecReduce_3  17# happyReduction_81-happyReduction_81 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut54 happy_x_2 of { happy_var_2 -> -	happyIn53-		 (Ints happy_var_2-	)}--happyReduce_82 = happySpecReduce_0  18# happyReduction_82-happyReduction_82  =  happyIn54-		 ([]-	)--happyReduce_83 = happySpecReduce_1  18# happyReduction_83-happyReduction_83 happy_x_1-	 =  case happyOut38 happy_x_1 of { happy_var_1 -> -	happyIn54-		 ((:[]) happy_var_1-	)}--happyReduce_84 = happySpecReduce_3  18# happyReduction_84-happyReduction_84 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut38 happy_x_1 of { happy_var_1 -> -	case happyOut54 happy_x_3 of { happy_var_3 -> -	happyIn54-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_85 = happySpecReduce_0  19# happyReduction_85-happyReduction_85  =  happyIn55-		 ([]-	)--happyReduce_86 = happySpecReduce_1  19# happyReduction_86-happyReduction_86 happy_x_1-	 =  case happyOut53 happy_x_1 of { happy_var_1 -> -	happyIn55-		 ((:[]) happy_var_1-	)}--happyReduce_87 = happySpecReduce_3  19# happyReduction_87-happyReduction_87 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut53 happy_x_1 of { happy_var_1 -> -	case happyOut55 happy_x_3 of { happy_var_3 -> -	happyIn55-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_88 = happySpecReduce_1  20# happyReduction_88-happyReduction_88 happy_x_1-	 =  case happyOut52 happy_x_1 of { happy_var_1 -> -	happyIn56-		 ((:[]) happy_var_1-	)}--happyReduce_89 = happySpecReduce_2  20# happyReduction_89-happyReduction_89 happy_x_2-	happy_x_1-	 =  case happyOut52 happy_x_1 of { happy_var_1 -> -	case happyOut56 happy_x_2 of { happy_var_2 -> -	happyIn56-		 ((:) happy_var_1 happy_var_2-	)}}--happyReduce_90 = happySpecReduce_0  21# happyReduction_90-happyReduction_90  =  happyIn57-		 (SepNone-	)--happyReduce_91 = happySpecReduce_2  21# happyReduction_91-happyReduction_91 happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn57-		 (SepTerm happy_var_2-	)}--happyReduce_92 = happySpecReduce_2  21# happyReduction_92-happyReduction_92 happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn57-		 (SepSepar happy_var_2-	)}--happyReduce_93 = happySpecReduce_1  22# happyReduction_93-happyReduction_93 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn58-		 (Arg happy_var_1-	)}--happyReduce_94 = happySpecReduce_0  23# happyReduction_94-happyReduction_94  =  happyIn59-		 ([]-	)--happyReduce_95 = happySpecReduce_2  23# happyReduction_95-happyReduction_95 happy_x_2-	happy_x_1-	 =  case happyOut59 happy_x_1 of { happy_var_1 -> -	case happyOut58 happy_x_2 of { happy_var_2 -> -	happyIn59-		 (flip (:) happy_var_1 happy_var_2-	)}}--happyReduce_96 = happySpecReduce_3  24# happyReduction_96-happyReduction_96 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut61 happy_x_1 of { happy_var_1 -> -	case happyOut60 happy_x_3 of { happy_var_3 -> -	happyIn60-		 (Cons happy_var_1 happy_var_3-	)}}--happyReduce_97 = happySpecReduce_1  24# happyReduction_97-happyReduction_97 happy_x_1-	 =  case happyOut61 happy_x_1 of { happy_var_1 -> -	happyIn60-		 (happy_var_1-	)}--happyReduce_98 = happySpecReduce_2  25# happyReduction_98-happyReduction_98 happy_x_2-	happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	case happyOut63 happy_x_2 of { happy_var_2 -> -	happyIn61-		 (App happy_var_1 happy_var_2-	)}}--happyReduce_99 = happySpecReduce_1  25# happyReduction_99-happyReduction_99 happy_x_1-	 =  case happyOut62 happy_x_1 of { happy_var_1 -> -	happyIn61-		 (happy_var_1-	)}--happyReduce_100 = happySpecReduce_1  26# happyReduction_100-happyReduction_100 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (Var happy_var_1-	)}--happyReduce_101 = happySpecReduce_1  26# happyReduction_101-happyReduction_101 happy_x_1-	 =  case happyOut38 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (LitInt happy_var_1-	)}--happyReduce_102 = happySpecReduce_1  26# happyReduction_102-happyReduction_102 happy_x_1-	 =  case happyOut39 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (LitChar happy_var_1-	)}--happyReduce_103 = happySpecReduce_1  26# happyReduction_103-happyReduction_103 happy_x_1-	 =  case happyOut36 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (LitString happy_var_1-	)}--happyReduce_104 = happySpecReduce_1  26# happyReduction_104-happyReduction_104 happy_x_1-	 =  case happyOut40 happy_x_1 of { happy_var_1 -> -	happyIn62-		 (LitDouble happy_var_1-	)}--happyReduce_105 = happySpecReduce_3  26# happyReduction_105-happyReduction_105 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut64 happy_x_2 of { happy_var_2 -> -	happyIn62-		 (List happy_var_2-	)}--happyReduce_106 = happySpecReduce_3  26# happyReduction_106-happyReduction_106 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut60 happy_x_2 of { happy_var_2 -> -	happyIn62-		 (happy_var_2-	)}--happyReduce_107 = happySpecReduce_1  27# happyReduction_107-happyReduction_107 happy_x_1-	 =  case happyOut62 happy_x_1 of { happy_var_1 -> -	happyIn63-		 ((:[]) happy_var_1-	)}--happyReduce_108 = happySpecReduce_2  27# happyReduction_108-happyReduction_108 happy_x_2-	happy_x_1-	 =  case happyOut62 happy_x_1 of { happy_var_1 -> -	case happyOut63 happy_x_2 of { happy_var_2 -> -	happyIn63-		 ((:) happy_var_1 happy_var_2-	)}}--happyReduce_109 = happySpecReduce_0  28# happyReduction_109-happyReduction_109  =  happyIn64-		 ([]-	)--happyReduce_110 = happySpecReduce_1  28# happyReduction_110-happyReduction_110 happy_x_1-	 =  case happyOut60 happy_x_1 of { happy_var_1 -> -	happyIn64-		 ((:[]) happy_var_1-	)}--happyReduce_111 = happySpecReduce_3  28# happyReduction_111-happyReduction_111 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut60 happy_x_1 of { happy_var_1 -> -	case happyOut64 happy_x_3 of { happy_var_3 -> -	happyIn64-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_112 = happySpecReduce_1  29# happyReduction_112-happyReduction_112 happy_x_1-	 =  case happyOut36 happy_x_1 of { happy_var_1 -> -	happyIn65-		 ((:[]) happy_var_1-	)}--happyReduce_113 = happySpecReduce_3  29# happyReduction_113-happyReduction_113 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_1 of { happy_var_1 -> -	case happyOut65 happy_x_3 of { happy_var_3 -> -	happyIn65-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_114 = happySpecReduce_1  30# happyReduction_114-happyReduction_114 happy_x_1-	 =  case happyOut67 happy_x_1 of { happy_var_1 -> -	happyIn66-		 ((:[]) happy_var_1-	)}--happyReduce_115 = happySpecReduce_3  30# happyReduction_115-happyReduction_115 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut67 happy_x_1 of { happy_var_1 -> -	case happyOut66 happy_x_3 of { happy_var_3 -> -	happyIn66-		 ((:) happy_var_1 happy_var_3-	)}}--happyReduce_116 = happySpecReduce_1  31# happyReduction_116-happyReduction_116 happy_x_1-	 =  case happyOut46 happy_x_1 of { happy_var_1 -> -	happyIn67-		 (RHS (reverse happy_var_1)-	)}--happyReduce_117 = happySpecReduce_1  32# happyReduction_117-happyReduction_117 happy_x_1-	 =  happyIn68-		 (MNonempty-	)--happyReduce_118 = happySpecReduce_0  32# happyReduction_118-happyReduction_118  =  happyIn68-		 (MEmpty-	)--happyReduce_119 = happySpecReduce_2  33# happyReduction_119-happyReduction_119 happy_x_2-	happy_x_1-	 =  case happyOut69 happy_x_1 of { happy_var_1 -> -	case happyOut71 happy_x_2 of { happy_var_2 -> -	happyIn69-		 (RSeq happy_var_1 happy_var_2-	)}}--happyReduce_120 = happySpecReduce_1  33# happyReduction_120-happyReduction_120 happy_x_1-	 =  case happyOut71 happy_x_1 of { happy_var_1 -> -	happyIn69-		 (happy_var_1-	)}--happyReduce_121 = happySpecReduce_3  34# happyReduction_121-happyReduction_121 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut70 happy_x_1 of { happy_var_1 -> -	case happyOut69 happy_x_3 of { happy_var_3 -> -	happyIn70-		 (RAlt happy_var_1 happy_var_3-	)}}--happyReduce_122 = happySpecReduce_3  34# happyReduction_122-happyReduction_122 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut69 happy_x_1 of { happy_var_1 -> -	case happyOut69 happy_x_3 of { happy_var_3 -> -	happyIn70-		 (RMinus happy_var_1 happy_var_3-	)}}--happyReduce_123 = happySpecReduce_1  34# happyReduction_123-happyReduction_123 happy_x_1-	 =  case happyOut69 happy_x_1 of { happy_var_1 -> -	happyIn70-		 (happy_var_1-	)}--happyReduce_124 = happySpecReduce_2  35# happyReduction_124-happyReduction_124 happy_x_2-	happy_x_1-	 =  case happyOut71 happy_x_1 of { happy_var_1 -> -	happyIn71-		 (RStar happy_var_1-	)}--happyReduce_125 = happySpecReduce_2  35# happyReduction_125-happyReduction_125 happy_x_2-	happy_x_1-	 =  case happyOut71 happy_x_1 of { happy_var_1 -> -	happyIn71-		 (RPlus happy_var_1-	)}--happyReduce_126 = happySpecReduce_2  35# happyReduction_126-happyReduction_126 happy_x_2-	happy_x_1-	 =  case happyOut71 happy_x_1 of { happy_var_1 -> -	happyIn71-		 (ROpt happy_var_1-	)}--happyReduce_127 = happySpecReduce_1  35# happyReduction_127-happyReduction_127 happy_x_1-	 =  happyIn71-		 (REps-	)--happyReduce_128 = happySpecReduce_1  35# happyReduction_128-happyReduction_128 happy_x_1-	 =  case happyOut39 happy_x_1 of { happy_var_1 -> -	happyIn71-		 (RChar happy_var_1-	)}--happyReduce_129 = happySpecReduce_3  35# happyReduction_129-happyReduction_129 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn71-		 (RAlts happy_var_2-	)}--happyReduce_130 = happySpecReduce_3  35# happyReduction_130-happyReduction_130 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut36 happy_x_2 of { happy_var_2 -> -	happyIn71-		 (RSeqs happy_var_2-	)}--happyReduce_131 = happySpecReduce_1  35# happyReduction_131-happyReduction_131 happy_x_1-	 =  happyIn71-		 (RDigit-	)--happyReduce_132 = happySpecReduce_1  35# happyReduction_132-happyReduction_132 happy_x_1-	 =  happyIn71-		 (RLetter-	)--happyReduce_133 = happySpecReduce_1  35# happyReduction_133-happyReduction_133 happy_x_1-	 =  happyIn71-		 (RUpper-	)--happyReduce_134 = happySpecReduce_1  35# happyReduction_134-happyReduction_134 happy_x_1-	 =  happyIn71-		 (RLower-	)--happyReduce_135 = happySpecReduce_1  35# happyReduction_135-happyReduction_135 happy_x_1-	 =  happyIn71-		 (RAny-	)--happyReduce_136 = happySpecReduce_3  35# happyReduction_136-happyReduction_136 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut72 happy_x_2 of { happy_var_2 -> -	happyIn71-		 (happy_var_2-	)}--happyReduce_137 = happySpecReduce_1  36# happyReduction_137-happyReduction_137 happy_x_1-	 =  case happyOut70 happy_x_1 of { happy_var_1 -> -	happyIn72-		 (happy_var_1-	)}--happyReduce_138 = happySpecReduce_1  37# happyReduction_138-happyReduction_138 happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	happyIn73-		 ((:[]) happy_var_1-	)}--happyReduce_139 = happySpecReduce_3  37# happyReduction_139-happyReduction_139 happy_x_3-	happy_x_2-	happy_x_1-	 =  case happyOut37 happy_x_1 of { happy_var_1 -> -	case happyOut73 happy_x_3 of { happy_var_3 -> -	happyIn73-		 ((:) happy_var_1 happy_var_3-	)}}--happyNewToken action sts stk [] =-	happyDoAction 46# notHappyAtAll action sts stk []--happyNewToken action sts stk (tk:tks) =-	let cont i = happyDoAction i tk action sts stk tks in-	case tk of {-	PT _ (TS _ 1) -> cont 1#;-	PT _ (TS _ 2) -> cont 2#;-	PT _ (TS _ 3) -> cont 3#;-	PT _ (TS _ 4) -> cont 4#;-	PT _ (TS _ 5) -> cont 5#;-	PT _ (TS _ 6) -> cont 6#;-	PT _ (TS _ 7) -> cont 7#;-	PT _ (TS _ 8) -> cont 8#;-	PT _ (TS _ 9) -> cont 9#;-	PT _ (TS _ 10) -> cont 10#;-	PT _ (TS _ 11) -> cont 11#;-	PT _ (TS _ 12) -> cont 12#;-	PT _ (TS _ 13) -> cont 13#;-	PT _ (TS _ 14) -> cont 14#;-	PT _ (TS _ 15) -> cont 15#;-	PT _ (TS _ 16) -> cont 16#;-	PT _ (TS _ 17) -> cont 17#;-	PT _ (TS _ 18) -> cont 18#;-	PT _ (TS _ 19) -> cont 19#;-	PT _ (TS _ 20) -> cont 20#;-	PT _ (TS _ 21) -> cont 21#;-	PT _ (TS _ 22) -> cont 22#;-	PT _ (TS _ 23) -> cont 23#;-	PT _ (TS _ 24) -> cont 24#;-	PT _ (TS _ 25) -> cont 25#;-	PT _ (TS _ 26) -> cont 26#;-	PT _ (TS _ 27) -> cont 27#;-	PT _ (TS _ 28) -> cont 28#;-	PT _ (TS _ 29) -> cont 29#;-	PT _ (TS _ 30) -> cont 30#;-	PT _ (TS _ 31) -> cont 31#;-	PT _ (TS _ 32) -> cont 32#;-	PT _ (TS _ 33) -> cont 33#;-	PT _ (TS _ 34) -> cont 34#;-	PT _ (TS _ 35) -> cont 35#;-	PT _ (TS _ 36) -> cont 36#;-	PT _ (TS _ 37) -> cont 37#;-	PT _ (TS _ 38) -> cont 38#;-	PT _ (TS _ 39) -> cont 39#;-	PT _ (TS _ 40) -> cont 40#;-	PT _ (TL happy_dollar_dollar) -> cont 41#;-	PT _ (TV happy_dollar_dollar) -> cont 42#;-	PT _ (TI happy_dollar_dollar) -> cont 43#;-	PT _ (TC happy_dollar_dollar) -> cont 44#;-	PT _ (TD happy_dollar_dollar) -> cont 45#;-	_ -> happyError' (tk:tks)-	}--happyError_ 46# tk tks = happyError' tks-happyError_ _ tk tks = happyError' (tk:tks)--happyThen :: () => Err a -> (a -> Err b) -> Err b-happyThen = (thenM)-happyReturn :: () => a -> Err a-happyReturn = (returnM)-happyThen1 m k tks = (thenM) m (\a -> k a tks)-happyReturn1 :: () => a -> b -> Err a-happyReturn1 = \a tks -> (returnM) a-happyError' :: () => [(Token)] -> Err a-happyError' = happyError--pLGrammar tks = happySomeParser where-  happySomeParser = happyThen (happyParse 0# tks) (\x -> happyReturn (happyOut41 x))--pLDef tks = happySomeParser where-  happySomeParser = happyThen (happyParse 1# tks) (\x -> happyReturn (happyOut42 x))--pListLDef tks = happySomeParser where-  happySomeParser = happyThen (happyParse 2# tks) (\x -> happyReturn (happyOut43 x))--pGrammar tks = happySomeParser where-  happySomeParser = happyThen (happyParse 3# tks) (\x -> happyReturn (happyOut44 x))--pListDef tks = happySomeParser where-  happySomeParser = happyThen (happyParse 4# tks) (\x -> happyReturn (happyOut45 x))--pListItem tks = happySomeParser where-  happySomeParser = happyThen (happyParse 5# tks) (\x -> happyReturn (happyOut46 x))--pDef tks = happySomeParser where-  happySomeParser = happyThen (happyParse 6# tks) (\x -> happyReturn (happyOut47 x))--pItem tks = happySomeParser where-  happySomeParser = happyThen (happyParse 7# tks) (\x -> happyReturn (happyOut48 x))--pCat tks = happySomeParser where-  happySomeParser = happyThen (happyParse 8# tks) (\x -> happyReturn (happyOut49 x))--pLabel tks = happySomeParser where-  happySomeParser = happyThen (happyParse 9# tks) (\x -> happyReturn (happyOut50 x))--pLabelId tks = happySomeParser where-  happySomeParser = happyThen (happyParse 10# tks) (\x -> happyReturn (happyOut51 x))--pProfItem tks = happySomeParser where-  happySomeParser = happyThen (happyParse 11# tks) (\x -> happyReturn (happyOut52 x))--pIntList tks = happySomeParser where-  happySomeParser = happyThen (happyParse 12# tks) (\x -> happyReturn (happyOut53 x))--pListInteger tks = happySomeParser where-  happySomeParser = happyThen (happyParse 13# tks) (\x -> happyReturn (happyOut54 x))--pListIntList tks = happySomeParser where-  happySomeParser = happyThen (happyParse 14# tks) (\x -> happyReturn (happyOut55 x))--pListProfItem tks = happySomeParser where-  happySomeParser = happyThen (happyParse 15# tks) (\x -> happyReturn (happyOut56 x))--pSeparation tks = happySomeParser where-  happySomeParser = happyThen (happyParse 16# tks) (\x -> happyReturn (happyOut57 x))--pArg tks = happySomeParser where-  happySomeParser = happyThen (happyParse 17# tks) (\x -> happyReturn (happyOut58 x))--pListArg tks = happySomeParser where-  happySomeParser = happyThen (happyParse 18# tks) (\x -> happyReturn (happyOut59 x))--pExp tks = happySomeParser where-  happySomeParser = happyThen (happyParse 19# tks) (\x -> happyReturn (happyOut60 x))--pExp1 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 20# tks) (\x -> happyReturn (happyOut61 x))--pExp2 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 21# tks) (\x -> happyReturn (happyOut62 x))--pListExp2 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 22# tks) (\x -> happyReturn (happyOut63 x))--pListExp tks = happySomeParser where-  happySomeParser = happyThen (happyParse 23# tks) (\x -> happyReturn (happyOut64 x))--pListString tks = happySomeParser where-  happySomeParser = happyThen (happyParse 24# tks) (\x -> happyReturn (happyOut65 x))--pListRHS tks = happySomeParser where-  happySomeParser = happyThen (happyParse 25# tks) (\x -> happyReturn (happyOut66 x))--pRHS tks = happySomeParser where-  happySomeParser = happyThen (happyParse 26# tks) (\x -> happyReturn (happyOut67 x))--pMinimumSize tks = happySomeParser where-  happySomeParser = happyThen (happyParse 27# tks) (\x -> happyReturn (happyOut68 x))--pReg2 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 28# tks) (\x -> happyReturn (happyOut69 x))--pReg1 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 29# tks) (\x -> happyReturn (happyOut70 x))--pReg3 tks = happySomeParser where-  happySomeParser = happyThen (happyParse 30# tks) (\x -> happyReturn (happyOut71 x))--pReg tks = happySomeParser where-  happySomeParser = happyThen (happyParse 31# tks) (\x -> happyReturn (happyOut72 x))--pListIdent tks = happySomeParser where-  happySomeParser = happyThen (happyParse 32# tks) (\x -> happyReturn (happyOut73 x))--happySeq = happyDontSeq---returnM :: a -> Err a-returnM = return--thenM :: Err a -> (a -> Err b) -> Err b-thenM = (>>=)--happyError :: [Token] -> Err a-happyError ts =-  Bad $ "syntax error at " ++ tokenPos ts ++ -  case ts of-    [] -> []-    [Err _] -> " due to lexer error"-    _ -> " before " ++ unwords (map (id . prToken) (take 4 ts))--myLexer = tokens-{-# LINE 1 "templates/GenericTemplate.hs" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}-{-# LINE 1 "<built-in>" #-}-{-# LINE 1 "<command-line>" #-}-{-# LINE 8 "<command-line>" #-}-# 1 "/usr/include/stdc-predef.h" 1 3 4--# 17 "/usr/include/stdc-predef.h" 3 4------------------------{-# LINE 8 "<command-line>" #-}-{-# LINE 1 "templates/GenericTemplate.hs" #-}--- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp --{-# LINE 13 "templates/GenericTemplate.hs" #-}-------- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.-#if __GLASGOW_HASKELL__ > 706-#define LT(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.<# m)) :: Bool)-#define GTE(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.>=# m)) :: Bool)-#define EQ(n,m) ((Happy_GHC_Exts.tagToEnum# (n Happy_GHC_Exts.==# m)) :: Bool)-#else-#define LT(n,m) (n Happy_GHC_Exts.<# m)-#define GTE(n,m) (n Happy_GHC_Exts.>=# m)-#define EQ(n,m) (n Happy_GHC_Exts.==# m)-#endif-{-# LINE 46 "templates/GenericTemplate.hs" #-}---data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList------{-# LINE 67 "templates/GenericTemplate.hs" #-}--{-# LINE 77 "templates/GenericTemplate.hs" #-}--{-# LINE 86 "templates/GenericTemplate.hs" #-}--infixr 9 `HappyStk`-data HappyStk a = HappyStk a (HappyStk a)---------------------------------------------------------------------------------- starting the parse--happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll---------------------------------------------------------------------------------- Accepting the parse---- If the current token is 0#, it means we've just accepted a partial--- parse (a %partial parser).  We must ignore the saved token on the top of--- the stack in this case.-happyAccept 0# tk st sts (_ `HappyStk` ans `HappyStk` _) =-        happyReturn1 ans-happyAccept j tk st sts (HappyStk ans _) = -        (happyTcHack j (happyTcHack st)) (happyReturn1 ans)---------------------------------------------------------------------------------- Arrays only: do the next action----happyDoAction i tk st-        = {- nothing -}---          case action of-                0#           -> {- nothing -}-                                     happyFail i tk st-                -1#          -> {- nothing -}-                                     happyAccept i tk st-                n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}--                                                   (happyReduceArr Happy_Data_Array.! rule) i tk st-                                                   where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))-                n                 -> {- nothing -}---                                     happyShift new_state i tk st-                                     where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))-   where off    = indexShortOffAddr happyActOffsets st-         off_i  = (off Happy_GHC_Exts.+# i)-         check  = if GTE(off_i,(0# :: Happy_GHC_Exts.Int#))-                  then EQ(indexShortOffAddr happyCheck off_i, i)-                  else False-         action-          | check     = indexShortOffAddr happyTable off_i-          | otherwise = indexShortOffAddr happyDefActions st---indexShortOffAddr (HappyA# arr) off =-        Happy_GHC_Exts.narrow16Int# i-  where-        i = Happy_GHC_Exts.word2Int# (Happy_GHC_Exts.or# (Happy_GHC_Exts.uncheckedShiftL# high 8#) low)-        high = Happy_GHC_Exts.int2Word# (Happy_GHC_Exts.ord# (Happy_GHC_Exts.indexCharOffAddr# arr (off' Happy_GHC_Exts.+# 1#)))-        low  = Happy_GHC_Exts.int2Word# (Happy_GHC_Exts.ord# (Happy_GHC_Exts.indexCharOffAddr# arr off'))-        off' = off Happy_GHC_Exts.*# 2#------data HappyAddr = HappyA# Happy_GHC_Exts.Addr#------------------------------------------------------------------------------------- HappyState data type (not arrays)--{-# LINE 170 "templates/GenericTemplate.hs" #-}---------------------------------------------------------------------------------- Shifting a token--happyShift new_state 0# tk st sts stk@(x `HappyStk` _) =-     let i = (case Happy_GHC_Exts.unsafeCoerce# x of { (Happy_GHC_Exts.I# (i)) -> i }) in---     trace "shifting the error token" $-     happyDoAction i tk new_state (HappyCons (st) (sts)) (stk)--happyShift new_state i tk st sts stk =-     happyNewToken new_state (HappyCons (st) (sts)) ((happyInTok (tk))`HappyStk`stk)---- happyReduce is specialised for the common cases.--happySpecReduce_0 i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happySpecReduce_0 nt fn j tk st@((action)) sts stk-     = happyGoto nt j tk st (HappyCons (st) (sts)) (fn `HappyStk` stk)--happySpecReduce_1 i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happySpecReduce_1 nt fn j tk _ sts@((HappyCons (st@(action)) (_))) (v1`HappyStk`stk')-     = let r = fn v1 in-       happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))--happySpecReduce_2 i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happySpecReduce_2 nt fn j tk _ (HappyCons (_) (sts@((HappyCons (st@(action)) (_))))) (v1`HappyStk`v2`HappyStk`stk')-     = let r = fn v1 v2 in-       happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))--happySpecReduce_3 i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happySpecReduce_3 nt fn j tk _ (HappyCons (_) ((HappyCons (_) (sts@((HappyCons (st@(action)) (_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk')-     = let r = fn v1 v2 v3 in-       happySeq r (happyGoto nt j tk st sts (r `HappyStk` stk'))--happyReduce k i fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happyReduce k nt fn j tk st sts stk-     = case happyDrop (k Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) sts of-         sts1@((HappyCons (st1@(action)) (_))) ->-                let r = fn stk in  -- it doesn't hurt to always seq here...-                happyDoSeq r (happyGoto nt j tk st1 sts1 r)--happyMonadReduce k nt fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happyMonadReduce k nt fn j tk st sts stk =-      case happyDrop k (HappyCons (st) (sts)) of-        sts1@((HappyCons (st1@(action)) (_))) ->-          let drop_stk = happyDropStk k stk in-          happyThen1 (fn stk tk) (\r -> happyGoto nt j tk st1 sts1 (r `HappyStk` drop_stk))--happyMonad2Reduce k nt fn 0# tk st sts stk-     = happyFail 0# tk st sts stk-happyMonad2Reduce k nt fn j tk st sts stk =-      case happyDrop k (HappyCons (st) (sts)) of-        sts1@((HappyCons (st1@(action)) (_))) ->-         let drop_stk = happyDropStk k stk--             off = indexShortOffAddr happyGotoOffsets st1-             off_i = (off Happy_GHC_Exts.+# nt)-             new_state = indexShortOffAddr happyTable off_i----          in-          happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk))--happyDrop 0# l = l-happyDrop n (HappyCons (_) (t)) = happyDrop (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) t--happyDropStk 0# l = l-happyDropStk n (x `HappyStk` xs) = happyDropStk (n Happy_GHC_Exts.-# (1#::Happy_GHC_Exts.Int#)) xs---------------------------------------------------------------------------------- Moving to a new state after a reduction---happyGoto nt j tk st = -   {- nothing -}-   happyDoAction j tk new_state-   where off = indexShortOffAddr happyGotoOffsets st-         off_i = (off Happy_GHC_Exts.+# nt)-         new_state = indexShortOffAddr happyTable off_i------------------------------------------------------------------------------------- Error recovery (0# is the error token)---- parse error if we are in recovery and we fail again-happyFail 0# tk old_st _ stk@(x `HappyStk` _) =-     let i = (case Happy_GHC_Exts.unsafeCoerce# x of { (Happy_GHC_Exts.I# (i)) -> i }) in---      trace "failing" $ -        happyError_ i tk--{-  We don't need state discarding for our restricted implementation of-    "error".  In fact, it can cause some bogus parses, so I've disabled it-    for now --SDM---- discard a state-happyFail  0# tk old_st (HappyCons ((action)) (sts)) -                                                (saved_tok `HappyStk` _ `HappyStk` stk) =---      trace ("discarding state, depth " ++ show (length stk))  $-        happyDoAction 0# tk action sts ((saved_tok`HappyStk`stk))--}---- Enter error recovery: generate an error token,---                       save the old token and carry on.-happyFail  i tk (action) sts stk =---      trace "entering error recovery" $-        happyDoAction 0# tk action sts ( (Happy_GHC_Exts.unsafeCoerce# (Happy_GHC_Exts.I# (i))) `HappyStk` stk)---- Internal happy errors:--notHappyAtAll :: a-notHappyAtAll = error "Internal Happy error\n"---------------------------------------------------------------------------------- Hack to get the typechecker to accept our action functions---happyTcHack :: Happy_GHC_Exts.Int# -> a -> a-happyTcHack x y = y-{-# INLINE happyTcHack #-}----------------------------------------------------------------------------------- Seq-ing.  If the --strict flag is given, then Happy emits ---      happySeq = happyDoSeq--- otherwise it emits---      happySeq = happyDontSeq--happyDoSeq, happyDontSeq :: a -> b -> b-happyDoSeq   a b = a `seq` b-happyDontSeq a b = b---------------------------------------------------------------------------------- Don't inline any functions from the template.  GHC has a nasty habit--- of deciding to inline happyGoto everywhere, which increases the size of--- the generated parser quite a bit.---{-# NOINLINE happyDoAction #-}-{-# NOINLINE happyTable #-}-{-# NOINLINE happyCheck #-}-{-# NOINLINE happyActOffsets #-}-{-# NOINLINE happyGotoOffsets #-}-{-# NOINLINE happyDefActions #-}--{-# NOINLINE happyShift #-}-{-# NOINLINE happySpecReduce_0 #-}-{-# NOINLINE happySpecReduce_1 #-}-{-# NOINLINE happySpecReduce_2 #-}-{-# NOINLINE happySpecReduce_3 #-}-{-# NOINLINE happyReduce #-}-{-# NOINLINE happyMonadReduce #-}-{-# NOINLINE happyGoto #-}-{-# NOINLINE happyFail #-}---- end of Happy Template.
src/BNFC/Backend/Base.hs view
@@ -11,34 +11,19 @@  import BNFC.Utils (writeFileRep) import Control.Monad.Writer-import System.Directory (doesDirectoryExist, createDirectoryIfMissing)-import System.FilePath (dropFileName)-+import System.Directory (createDirectoryIfMissing)+import System.FilePath (dropFileName, (</>)) --- import Control.Monad (liftM, when,unless)--- import Control.Monad.State--- import Control.Monad.Trans (lift)--- import Data.Char--- import Data.List (elemIndex, foldl', sort, intercalate)--- import Data.Maybe (catMaybes, listToMaybe)--- import Data.Version ( showVersion )--- import ErrM--- import Paths_BNFC ( version )--- import System.Console.GetOpt--- import System.FilePath (takeBaseName, takeFileName)--- import System.IO (stderr, hPutStrLn,hPutStr)--- import Text.Printf (printf)------ | Define the type of the backend functions--- For more purity, instead of having each backend writing the generated files to--- disk, they return a list of pairs containing the (relative) file path and--- the file content. This allow for 1) easier testing, 2) implement common options--- like changing the output dir or providing a diff instead of overwritting the--- files on a highter level and 3) more purity.+-- | Define the type of the backend functions For more purity, instead of+-- having each backend writing the generated files to disk, they return a list+-- of pairs containing the (relative) file path and the file content. This+-- allow for 1) easier testing, 2) implement common options like changing the+-- output dir or providing a diff instead of overwritting the files on a+-- highter level and 3) more purity. ----- The writer monad provide a more conveignent api to generate the list. Note that we--- still use the IO monad for now because some backend insist on printing stuff--- to the screen while generating the files.+-- The writer monad provide a more conveignent api to generate the list. Note+-- that we still use the IO monad for now because some backend insist on+-- printing stuff to the screen while generating the files. type MkFiles a = WriterT [(FilePath, String)] IO a type Backend = MkFiles () @@ -53,18 +38,18 @@ mkfile :: FilePath -> String -> MkFiles () mkfile path content = tell [(path,content)] --- | Write a set of files to disk. the first argument is the root directory inside--- which all the generated files will be written. This root directory--- should already exits. Sub-directory will be created as needed (ex: if the--- files contains a a/b/file.txt, `writeFiles` will create--- the directories `$ROOT/a` and `$ROOT/a/b`)+-- | Write a set of files to disk. the first argument is the root directory+-- inside which all the generated files will be written. This root directory+-- and sub-directories will be created as needed (ex: if the files contains a+-- a/b/file.txt, `writeFiles` will create the directories `$ROOT/a` and+-- `$ROOT/a/b`) writeFiles :: FilePath -> MkFiles () -> IO () writeFiles root fw = do   -- First we check that the directory exists   fb <- execBackend fw-  doesDirectoryExist root >>= flip unless (fail $ root ++ " does not exists")+  createDirectoryIfMissing True root   mapM_ (uncurry writeFile') fb   where writeFile' :: FilePath -> String -> IO ()         writeFile' path content =-          createDirectoryIfMissing True (dropFileName path)-          >> writeFileRep path content+          createDirectoryIfMissing True (root </> dropFileName path)+          >> writeFileRep (root </> path) content
src/BNFC/Backend/C.hs view
@@ -61,28 +61,29 @@  makefile :: String -> String -> String makefile name prefix =-  (++) (unlines [ "CC = gcc",-                  "CCFLAGS = -g -W -Wall", "",-                  "FLEX = flex",-                  "FLEX_OPTS = -P" ++ prefix, "",-                  "BISON = bison",-                  "BISON_OPTS = -t -p" ++ prefix, ""])+  (unlines [ "CC = gcc",+             "CCFLAGS = -g -W -Wall", "",+             "FLEX = flex",+             "FLEX_OPTS = -P" ++ prefix, "",+             "BISON = bison",+             "BISON_OPTS = -t -p" ++ prefix, "",+             "OBJS = Absyn.o Lexer.o Parser.o Printer.o", ""] ++)   $ Makefile.mkRule ".PHONY" ["clean", "distclean"]     []   $ Makefile.mkRule "all" [testName]     []   $ Makefile.mkRule "clean" []     -- peteg: don't nuke what we generated - move that to the "vclean" target.-    [ "rm -f *.o " ++ unwords [ name ++ e | e <- [".aux",".log",".pdf",""]] ]-  $ Makefile.mkRule "distclean" ["clean"] -- FIXME+    [ "rm -f *.o " ++ testName ++ " " ++ unwords+      [ name ++ e | e <- [".aux", ".log", ".pdf",".dvi", ".ps", ""]] ]+  $ Makefile.mkRule "distclean" ["clean"]     [ "rm -f " ++ unwords-      [ "Absyn.c", "Absyn.h", "Test.c", "Parser.c", "Parser.h", "Lexer.c"-      , "Skeleton.c", "Skeleton.h", "Printer.c" ,"Printer.h"-      , name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex "-      , testName, "Makefile" ]]-  $ Makefile.mkRule testName ["Absyn.o", "Lexer.o", "Parser.o", "Printer.o", "Test.o"]-    [ "@echo \"Linking test" ++ name ++ "...\""-    , "${CC} ${CCFLAGS} *.o -o Test" ++ name ]+      [ "Absyn.h", "Absyn.c", "Test.c", "Parser.c", "Parser.h", "Lexer.c",+        "Skeleton.c", "Skeleton.h", "Printer.c", "Printer.h", "Makefile " ]+      ++ name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex "]+  $ Makefile.mkRule testName ["${OBJS}", "Test.o"]+    [ "@echo \"Linking " ++ testName ++ "...\""+    , "${CC} ${CCFLAGS} ${OBJS} Test.o -o " ++ testName ]   $ Makefile.mkRule "Absyn.o" [ "Absyn.c", "Absyn.h"]     [ "${CC} ${CCFLAGS} -c Absyn.c" ]   $ Makefile.mkRule "Lexer.c" [ name ++ ".l" ]@@ -100,6 +101,8 @@   ""   where testName = "Test" ++ name +-- | Generate a test program that parses stdin and prints the AST and it's+-- linearization ctest :: CF -> String ctest cf =   unlines
src/BNFC/Backend/C/CFtoBisonC.hs view
@@ -39,10 +39,11 @@ -}  -module BNFC.Backend.C.CFtoBisonC (cf2Bison) where+module BNFC.Backend.C.CFtoBisonC (cf2Bison, startSymbol) where  import BNFC.CF-import Data.List (intersperse)+import Data.List (intercalate)+import Data.Maybe (fromMaybe) import BNFC.Backend.Common.NamedVariables hiding (varName) import Data.Char (toLower) import BNFC.Utils ((+++))@@ -60,11 +61,12 @@ cf2Bison name cf env  = unlines     [header name cf,-     union (allCats cf),+     union (allCatsNorm cf),      "%token _ERROR_",      tokens user env,      declarations cf,      specialToks cf,+     startSymbol cf,      "%%",      prRules (rulesForBison cf env)     ]@@ -74,25 +76,28 @@ header :: String -> CF -> String header name cf = unlines          ["/* This Bison file was machine-generated by BNFC */",-	  "%{",-	  "#include <stdlib.h>",-	  "#include <stdio.h>",-	  "#include <string.h>",-	  "#include \"Absyn.h\"",-	  "#define initialize_lexer " ++ name ++ "_initialize_lexer",-	  "extern int yyparse(void);",-	  "extern int yylex(void);",-	  "extern int initialize_lexer(FILE * inp);",+          "%{",+          "#include <stdlib.h>",+          "#include <stdio.h>",+          "#include <string.h>",+          "#include \"Absyn.h\"",+          "#define initialize_lexer " ++ name ++ "_initialize_lexer",+          "extern int yyparse(void);",+          "extern int yylex(void);",+          "int yy_mylinenumber;", +          "extern int initialize_lexer(FILE * inp);",           "void yyerror(const char *str)",           "{",-          "  fprintf(stderr,\"error: %s\\n\",str);",+          "  extern char *" ++ name ++ "text;", +          "  fprintf(stderr,\"error: line %d: %s at %s\\n\",",+          "    yy_mylinenumber + 1, str, " ++ name ++ "text);",           "}",-	  "",+          "",           -- M.F. 2004-09-17 changed allEntryPoints to allCatsIdNorm. Seems to fix the [Ty2] bug.-	  unlines $ map parseMethod (allCatsNorm cf), -- (allEntryPoints cf),-	  concatMap reverseList (filter isList (allCats cf)),-	  "%}"-	  ]+          unlines $ map parseMethod (allCatsNorm cf), -- (allEntryPoints cf),+          concatMap reverseList (filter isList (allCatsNorm cf)),+          "%}"+          ]  --This generates a parser method for each entry point. parseMethod :: Cat -> String@@ -102,7 +107,7 @@ --  else   unlines   [-   cat' +++ (resultName cat') +++ "= 0;",+   cat' +++ resultName cat' +++ "= 0;",    cat' ++ " p" ++ cat' ++ "(FILE *inp)",    "{",    "  initialize_lexer(inp);",@@ -112,7 +117,7 @@    "  }",    "  else",    "  { /* Success */",-   "    return" +++ (resultName cat') ++ ";",+   "    return" +++ resultName cat' ++ ";",    "  }",    "}"   ]@@ -139,7 +144,7 @@  ]  where   c' = identCat (normCat c)-  v = (map toLower c') ++ "_"+  v = map toLower c' ++ "_"  --The union declaration is special to Bison/Yacc and gives the type of yylval. --For efficiency, we may want to only include used categories here.@@ -157,23 +162,23 @@  ]  where --This is a little weird because people can make [Exp2] etc.  mkPointer s | identCat s /= show s = --list. add it even if it refers to a coercion.-   "  " ++ (identCat (normCat s)) +++ (varName (normCat s)) ++ ";\n"+   "  " ++ identCat (normCat s) +++ varName (normCat s) ++ ";\n"  mkPointer s | normCat s == s = --normal cat-   "  " ++ (identCat (normCat s)) +++ (varName (normCat s)) ++ ";\n"+   "  " ++ identCat (normCat s) +++ varName (normCat s) ++ ";\n"  mkPointer _ = ""  --declares non-terminal types. declarations :: CF -> String declarations cf = concatMap (typeNT cf) (allCats cf)  where --don't define internal rules-   typeNT cf nt | rulesForCat cf nt /= [] = "%type <" ++ (varName (normCat nt)) ++ "> " ++ (identCat nt) ++ "\n"+   typeNT cf nt | rulesForCat cf nt /= [] = "%type <" ++ varName (normCat nt) ++ "> " ++ identCat nt ++ "\n"    typeNT _ _ = ""  --declares terminal types. tokens :: [UserDef] -> SymEnv -> String-tokens user ts = concatMap (declTok user) ts+tokens user = concatMap (declTok user)  where-  declTok u (s,r) = if elem s (map show u)+  declTok u (s,r) = if s `elem` map show u     then "%token<string_> " ++ r ++ "    /*   " ++ s ++ "   */\n"     else "%token " ++ r ++ "    /*   " ++ s ++ "   */\n" @@ -188,6 +193,9 @@    where     ifC cat s = if isUsedCat cf cat then s else "" +startSymbol :: CF -> String+startSymbol cf = "%start" +++ identCat (firstEntry cf)+ --The following functions are a (relatively) straightforward translation --of the ones in CFtoHappy.hs rulesForBison :: CF -> SymEnv -> Rules@@ -196,31 +204,38 @@  -- For every non-terminal, we construct a set of rules. constructRule :: CF -> SymEnv -> [Rule] -> NonTerminal -> (NonTerminal,[(Pattern,Action)])-constructRule cf env rules nt = (nt,[(p,(generateAction (identCat (normCat nt)) (ruleName r) b m) +++ result) |+constructRule cf env rules nt = (nt,[(p, generateAction (identCat (normCat nt)) (funRule r) b m +++ result) |      r0 <- rules,      let (b,r) = if isConsFun (funRule r0) && elem (valCat r0) revs                    then (True,revSepListRule r0)                  else (False,r0),      let (p,m) = generatePatterns cf env r])  where-   ruleName r = case funRule r of-     "(:)" -> identCat nt-     z -> z    revs = reversibleCats cf    eps = allEntryPoints cf-   isEntry nt = if elem nt eps then True else False-   result = if isEntry nt then (resultName (identCat (normCat nt))) ++ "= $$;" else ""+   isEntry nt = nt `elem` eps+   result = if isEntry nt then resultName (identCat (normCat nt)) ++ "= $$;" else "" --- Generates a string containing the semantic action.+-- | Generates a string containing the semantic action.+-- >>> generateAction "Foo" "Bar" False ["$1"]+-- "make_Bar($1);"+-- >>> generateAction "Foo" "_" False ["$1"]+-- "$1;"+-- >>> generateAction "ListFoo" "[]" False []+-- "0;"+-- >>> generateAction "ListFoo" "(:[])" False ["$1"]+-- "make_ListFoo($1, 0);"+-- >>> generateAction "ListFoo" "(:)" False ["$1","$2"]+-- "make_ListFoo($1, $2);"+-- >>> generateAction "ListFoo" "(:)" True ["$1","$2"]+-- "make_ListFoo($2, $1);" generateAction :: String -> Fun -> Bool -> [MetaVar] -> Action-generateAction nt f b ms =-  if isCoercion f-  then (unwords ms) ++ ";"-  else if isNilFun f-  then "0;"-  else if isOneFun f-  then concat ["make_", nt, "(", (concat (intersperse ", " ms')), ", 0);"]-  else concat ["make_", normFun f, "(", (concat (intersperse ", " ms')), ");"]+generateAction nt f b ms +  | isCoercion f = unwords ms ++ ";"+  | isNilFun f   = "0;"+  | isOneFun f   = concat ["make_", nt, "(", intercalate ", " ms', ", 0);"]+  | isConsFun f  = concat ["make_", nt, "(", intercalate ", " ms', ");"]+  | otherwise    = concat ["make_", f, "(", intercalate ", " ms', ");"]  where   ms' = if b then reverse ms else ms @@ -232,15 +247,11 @@   its -> (unwords (map mkIt its), metas its)  where    mkIt i = case i of-     Left c -> case lookup (show c) env of-       Just x -> x-       Nothing -> typeName (identCat c)-     Right s -> case lookup s env of-       Just x -> x-       Nothing -> s+     Left c -> fromMaybe (typeName (identCat c)) (lookup (show c) env)+     Right s -> fromMaybe s (lookup s env)    metas its = [revIf c ('$': show i) | (i,Left c) <- zip [1 :: Int ..] its]-   revIf c m = if (not (isConsFun (funRule r)) && elem c revs)-                 then ("reverse" ++ (identCat (normCat c)) ++ "(" ++ m ++ ")")+   revIf c m = if not (isConsFun (funRule r)) && elem c revs+                 then "reverse" ++ identCat (normCat c) ++ "(" ++ m ++ ")"                else m  -- no reversal in the left-recursive Cons rule itself    revs = reversibleCats cf @@ -250,12 +261,12 @@ prRules :: Rules -> String prRules [] = [] prRules ((_, []):rs) = prRules rs --internal rule-prRules ((nt,((p,a):ls)):rs) =-  (unwords [nt', ":" , p, "{ $$ =", a, "}", "\n" ++ pr ls]) ++ ";\n" ++ prRules rs+prRules ((nt, (p,a) : ls):rs) =+  unwords [nt', ":" , p, "{ $$ =", a, "}", '\n' : pr ls] ++ ";\n" ++ prRules rs  where   nt' = identCat nt   pr []           = []-  pr ((p,a):ls)   = (unlines [(concat $ intersperse " " ["  |", p, "{ $$ =", a , "}"])]) ++ pr ls+  pr ((p,a):ls)   = unlines [unwords ["  |", p, "{ $$ =", a , "}"]] ++ pr ls  --Some helper functions. resultName :: String -> String
src/BNFC/Backend/C/CFtoCAbs.hs view
@@ -40,10 +40,10 @@  module BNFC.Backend.C.CFtoCAbs (cf2CAbs) where -import Text.PrettyPrint  import BNFC.CF-import BNFC.Utils((+++), vsep)+import BNFC.PrettyPrint+import BNFC.Utils((+++)) import BNFC.Backend.Common.NamedVariables import Data.Function (on) import Data.List@@ -70,7 +70,7 @@   concatMap prForward classes,   "",   "/********************   Abstract Syntax Classes    ********************/\n",-  concatMap prDataH (cf2dataLists cf),+  concatMap prDataH (getAbstractSyntax cf),   "",   "#endif"  ]@@ -94,7 +94,7 @@      else "_" --ignore this    else "_" ---Prints struct definitions for all categories.+-- | Prints struct definitions for all categories. prDataH :: Data -> String prDataH (cat, rules) =    if isList cat@@ -124,7 +124,7 @@  where   c' = identCat (normCat cat)   mem = identCat (normCatOfList cat)-  prKind (fun, _) = "is_" ++ normFun fun+  prKind (fun, _) = "is_" ++ fun   prUnion (_, []) = ""   prUnion (fun, cats) = "    struct { " ++ (render $ prInstVars (getVars cats)) ++ " } " ++ (memName fun) ++ ";\n" @@ -135,9 +135,8 @@     if isNilFun fun || isOneFun fun || isConsFun fun     then ""  --these are not represented in the AbSyn     else --a standard rule-      show c ++ " make_" ++ fun' ++ "(" ++ (prParamsH 0 (getVars cats)) ++ ");\n"+      show c ++ " make_" ++ fun ++ "(" ++ (prParamsH 0 (getVars cats)) ++ ");\n"    where-     fun' = normFun fun      prParamsH :: Int -> [(String, a)] -> String      prParamsH _ [] = ""      prParamsH n ((t,_):[]) = t ++ " p" ++ (show n)@@ -179,7 +178,7 @@ mkCFile cf = unlines  [   header,-  concatMap (render . prDataC) (cf2dataLists cf)+  concatMap (render . prDataC) (getAbstractSyntax cf)  ]  where   header = unlines@@ -264,11 +263,10 @@     m = identCat (normCat c')     m' = map toLower m ++ "_" prRuleC c (fun, cats) = vsep-    [ text $ "/********************   " ++ fun' ++ "    ********************/"-    , prConstructorC c fun' vs cats ]+    [ text $ "/********************   " ++ fun ++ "    ********************/"+    , prConstructorC c fun vs cats ]    where      vs = getVars cats-     fun' = normFun fun  -- | The constructor just assigns the parameters to the corresponding instance -- variables.
src/BNFC/Backend/C/CFtoCPrinter.hs view
@@ -43,10 +43,14 @@  import BNFC.CF import BNFC.Utils ((+++))+import BNFC.Backend.Common (renderListSepByPrecedence) import BNFC.Backend.Common.NamedVariables import BNFC.Backend.Common.StrUtils (renderCharOrString)+import BNFC.Backend.Utils (isTokenType) import Data.List import Data.Char(toLower)+import Data.Either (lefts)+import BNFC.PrettyPrint  --Produces (.h file, .c file) cf2CPrinter :: CF -> (String, String)@@ -164,6 +168,8 @@       "#include <string.h>",       "#include <stdlib.h>",       "",+      "#define INDENT_WIDTH 2",+      "",       "int _n_;",       "char* buf_;",       "int cur_;",@@ -333,9 +339,9 @@  --Generates methods for the Pretty Printer prPrintData :: [UserDef] -> (Cat, [Rule]) -> String-prPrintData user (cat, rules) =+prPrintData user (cat, rules) = unlines $  if isList cat- then unlines+ then  [   "void pp" ++ cl ++ "("++ cl +++ vname ++ ", int i)",   "{",@@ -350,14 +356,15 @@   "    else",   "    {",   visitMember,-  "      render" ++ [sc] ++ "(" ++ sep ++ ");",+  render (nest 6 (renderListSepByPrecedence "i" renderX+      (getSeparatorByPrecedence rules))),   "      " ++ vname +++ "=" +++ vname ++ "->" ++ vname ++ "_;",   "    }",   "  }",   "}",   ""  ] --Not a list:- else unlines+ else  [    "void pp" ++ cl ++ "(" ++ cl ++ " _p_, int _i_)",    "{",@@ -375,11 +382,23 @@    ecl = identCat (normCatOfList cat)    vname = map toLower cl    member = map toLower ecl-   visitMember = "      pp" ++ ecl ++ "(" ++ vname ++ "->" ++ member ++ "_, 0);"-   (sc, sep) = renderCharOrString sep'+   visitMember = "      pp" ++ ecl ++ "(" ++ vname ++ "->" ++ member ++ "_, i);"    sep' = getCons rules-   optsep = if hasOneFunc rules then "" else "      render" ++ [sc] ++ "(" ++ sep ++ ");"+   optsep = if hasOneFunc rules then "" else "      " ++ render (renderX sep') ++ ";" +-- | Helper function that call the right c function (renderC or renderS) to+-- render a literal string.+--+-- >>> renderX ","+-- renderC(',')+--+-- >>> renderX "---"+-- renderS("---")+renderX :: String -> Doc+renderX sep' = "render" <> char sc <> parens (text sep)+  where (sc, sep) = renderCharOrString sep'++ --Pretty Printer methods for a rule. prPrintRule :: [UserDef] -> Rule -> String prPrintRule user r@(Rule fun _ cats) | not (isCoercion fun) = unlines@@ -393,29 +412,20 @@    where     p = precRule r     (lparen, rparen) =-      ("    if (_i_ > " ++ (show p) ++ ") renderC(_L_PAREN);",-       "    if (_i_ > " ++ (show p) ++ ") renderC(_R_PAREN);")-    cats' = (concatMap (prPrintCat user fun) (zip3 (fixOnes (numVars [] cats)) cats (map getPrec cats)))-    getPrec (Right _) = 0 :: Integer-    getPrec (Left c) = precCat c+      ("    if (_i_ > " ++ show p ++ ") renderC(_L_PAREN);",+       "    if (_i_ > " ++ show p ++ ") renderC(_R_PAREN);")+    cats' = concatMap (prPrintCat user fun) (numVars cats) prPrintRule _ _ = ""  --This goes on to recurse to the instance variables.-prPrintCat :: [UserDef] -> String -> (Either String String, Either Cat String, Integer) -> String-prPrintCat user fnm (c,o,p) = case c of-  (Right t) -> "    render" ++ [sc] ++ "(" ++ t' ++ ");\n"-    where-     (sc,t') = renderCharOrString t-  (Left nt) -> if isBasic user nt-       then "    pp" ++ (basicFunName nt) ++ "(_p_->u." ++ v ++ "_." ++ nt ++ ", " ++ (show p) ++ ");\n"-       else if nt == "#_" --Internal category-         then "    /* Internal Category */\n"-         else "    pp" ++ o' ++ "(_p_->u." ++ v ++ "_." ++ nt ++ ", " ++ (show p) ++ ");\n"+prPrintCat :: [UserDef] -> String -> Either (Cat, Doc) String -> String+prPrintCat user fnm (c) = case c of+  Right t -> "    " ++ render (renderX t) ++ ";\n"+  Left (cat, nt) | isTokenType user cat -> "    pp" ++ basicFunName (render nt) ++ "(_p_->u." ++ v ++ "_." ++ render nt ++ ", " ++ show (precCat cat) ++ ");\n"+  Left (InternalCat, _) -> "    /* Internal Category */\n"+  Left (cat, nt) -> "    pp" ++ identCat (normCat cat) ++ "(_p_->u." ++ v ++ "_." ++ render nt ++ ", " ++ show (precCat cat) ++ ");\n"  where   v = map toLower (normFun fnm)-  o' = case o of-    Right x -> x-    Left x -> identCat (normCat x)  {- **** Abstract Syntax Tree Printer **** -} @@ -437,9 +447,9 @@  --This prints the functions for Abstract Syntax tree printing. prShowData :: [UserDef] -> (Cat, [Rule]) -> String-prShowData user (cat, rules) =+prShowData user (cat, rules) = unlines $  if isList cat- then unlines+ then  [   "void sh" ++ cl ++ "("++ cl +++ vname ++ ")",   "{",@@ -460,7 +470,7 @@   "}",   ""  ] --Not a list:- else unlines+ else  [    "void sh" ++ cl ++ "(" ++ cl ++ " _p_)",    "{",@@ -498,66 +508,43 @@       else ("  bufAppendC(' ');\n", "  bufAppendC('(');\n","  bufAppendC(')');\n")     cats' = if allTerms cats         then ""-    	else concat (insertSpaces (map (prShowCat user fun) (zip (fixOnes (numVars [] cats)) cats)))+        else concat (insertSpaces (map (prShowCat user fun) (lefts $ numVars cats)))     insertSpaces [] = []     insertSpaces (x:[]) = [x]     insertSpaces (x:xs) = if x == ""       then insertSpaces xs-      else (x : ["  bufAppendC(' ');\n"]) ++ (insertSpaces xs)+      else x : "  bufAppendC(' ');\n" : insertSpaces xs     allTerms [] = True     allTerms (Left _:_) = False     allTerms (_:zs) = allTerms zs prShowRule _ _ = ""  --This goes on to recurse to the instance variables.-prShowCat :: [UserDef] -> Fun -> (Either String String, Either Cat String) -> String-prShowCat user fnm (c,o) = case c of-  (Right _) -> ""-  (Left nt) -> if isBasic user nt-       then "    sh" ++ (basicFunName nt) ++ "(_p_->u." ++ v ++ "_." ++ nt ++ ");\n"-       else if nt == "#_" --Internal category-         then "    /* Internal Category */\n"-         else if ((show $ normCat $ strToCat nt) /= nt)-          then "    sh" ++ o' ++ "(_p_->u." ++ v ++ "_." ++ nt ++ ");\n"-          else concat+prShowCat :: [UserDef] -> Fun -> (Cat, Doc) -> String+prShowCat user fnm c = case c of+    (cat,nt) | isTokenType user cat ->+        "    sh" ++ basicFunName (render nt) ++ "(_p_->u." ++ v ++ "_." ++ render nt ++ ");\n"+    (InternalCat, _) -> "    /* Internal Category */\n"+    (cat,nt) | show (normCat $ strToCat$ render nt) /= render nt ->+        "    sh" ++ identCat (normCat cat) ++ "(_p_->u." ++ v ++ "_." ++ render nt ++ ");\n"+    (cat,nt) -> concat           [-	   "    bufAppendC('[');\n",-           "    sh" ++ o' ++ "(_p_->u." ++ v ++ "_." ++ nt ++ ");\n",-	   "    bufAppendC(']');\n"+           "    bufAppendC('[');\n",+           "    sh" ++ identCat (normCat cat) ++ "(_p_->u." ++ v ++ "_." ++ render nt ++ ");\n",+           "    bufAppendC(']');\n"           ]- where-  v = map toLower (normFun fnm)-  o' = case o of-    Right x -> x-    Left x -> identCat (normCat x)+  where v = map toLower (normFun fnm)  {- **** Helper Functions Section **** -}-----Just checks if something is a basic or user-defined type.---This is because you don't -> a basic non-pointer type.-isBasic :: [UserDef] -> String -> Bool-isBasic user v =-  if elem (init v) user'-    then True-    else if "integer_" `isPrefixOf` v then True-    else if "char_" `isPrefixOf` v then True-    else if "string_" `isPrefixOf` v then True-    else if "double_" `isPrefixOf` v then True-    else if "ident_" `isPrefixOf` v then True-    else False-  where-   user' = map (map toLower . show) user- --The visit-function name of a basic type basicFunName :: String -> String-basicFunName v =-    if "integer_" `isPrefixOf` v then "Integer"-    else if "char_" `isPrefixOf` v then "Char"-    else if "string_" `isPrefixOf` v then "String"-    else if "double_" `isPrefixOf` v then "Double"-    else if "ident_" `isPrefixOf` v then "Ident"-    else "Ident" --User-defined type+basicFunName v+  | "integer_" `isPrefixOf` v = "Integer"+  | "char_" `isPrefixOf` v    = "Char"+  | "string_" `isPrefixOf` v  = "String"+  | "double_" `isPrefixOf` v  = "Double"+  | "ident_" `isPrefixOf` v   = "Ident"+  | otherwise = "Ident" --User-defined type  --An extremely simple renderCer for terminals. prRender :: String@@ -571,7 +558,7 @@       "     bufAppendC('\\n');",       "     indent();",       "     bufAppendC(c);",-      "     _n_ = _n_ + 2;",+      "     _n_ = _n_ + INDENT_WIDTH;",       "     bufAppendC('\\n');",       "     indent();",       "  }",@@ -581,13 +568,14 @@       "  {",       "     backup();",       "     bufAppendC(c);",-      "     bufAppendC(' ');",       "  }",       "  else if (c == '}')",       "  {",-      "     _n_ = _n_ - 2;",-      "     backup();",-      "     backup();",+      "     int t;",+      "     _n_ = _n_ - INDENT_WIDTH;",+      "     for(t=0; t<INDENT_WIDTH; t++) {",+      "       backup();",+      "     }",       "     bufAppendC(c);",       "     bufAppendC('\\n\');",       "     indent();",@@ -608,6 +596,7 @@       "  else if (c == 0) return;",       "  else",       "  {",+      "     bufAppendC(' ');",       "     bufAppendC(c);",       "     bufAppendC(' ');",       "  }",
src/BNFC/Backend/C/CFtoCSkel.hs view
@@ -40,16 +40,19 @@ module BNFC.Backend.C.CFtoCSkel (cf2CSkel) where  import BNFC.CF-import BNFC.Utils			( (+++) )+import BNFC.Utils                       ( (+++) ) import BNFC.Backend.Common.NamedVariables-import Data.List		( isPrefixOf )-import Data.Char		( toLower, toUpper )+import BNFC.Backend.Utils (isTokenType)+import Data.Char                ( toLower, toUpper )+import Data.Either (lefts) +import Text.PrettyPrint+ --Produces (.H file, .C file) cf2CSkel :: CF -> (String, String) cf2CSkel cf = (mkHFile cf groups, mkCFile cf groups)  where-    groups = (fixCoercions (ruleGroups cf))+    groups = fixCoercions (ruleGroups cf)   {- **** Header (.H) File Functions **** -}@@ -76,7 +79,7 @@    ]   prUserH user = "void visit" ++ u' ++ "(" ++ show user ++ " p);"     where-     u' = let u = show user in ((toUpper (head u)) : (map toLower (tail u))) --this is a hack to fix a potential capitalization problem.+     u' = let u = show user in toUpper (head u) : map toLower (tail u) --this is a hack to fix a potential capitalization problem.   footer = unlines    [     "void visitIdent(Ident i);",@@ -98,7 +101,7 @@  {- **** Implementation (.C) File Functions **** -} ---Makes the .C File+-- | Makes the skeleton's .c File mkCFile :: CF -> [(Cat,[Rule])] -> String mkCFile cf groups = concat    [@@ -115,6 +118,9 @@       "   To use, copy Skeleton.h and Skeleton.c to",       "   new files. */",       "",+      "#include <stdlib.h>",+      "#include <stdio.h>",+      "",       "#include \"Skeleton.h\"",       ""       ]@@ -126,7 +132,7 @@       "}"      ]      where-      u' = ((toUpper (head u)) : (map toLower (tail u))) --this is a hack to fix a potential capitalization problem.+      u' = toUpper (head u) : map toLower (tail u) --this is a hack to fix a potential capitalization problem.     footer = unlines      [       "void visitIdent(Ident i)",@@ -154,87 +160,79 @@  --Visit functions for a category. prData :: [UserDef] -> (Cat, [Rule]) -> String-prData user (cat, rules) =-    if isList cat-      then unlines-	       [-		"void visit" ++ cl ++ "("++ cl +++ vname ++ ")",-		"{",-		"  while(" ++ vname ++ " != 0)",-		"  {",-		"    /* Code For " ++ cl ++ " Goes Here */",-		"    visit" ++ ecl ++ "(" ++ vname ++ "->" ++ member ++ "_);",-		"    " ++ vname +++ "=" +++ vname ++ "->" ++ vname ++ "_;",-		"  }",-		"}",-		""-	       ]+prData user (cat, rules)+  | isList cat = unlines+               [+                "void visit" ++ cl ++ "("++ cl +++ vname ++ ")",+                "{",+                "  while(" ++ vname ++ " != 0)",+                "  {",+                "    /* Code For " ++ cl ++ " Goes Here */",+                "    visit" ++ ecl ++ "(" ++ vname ++ "->" ++ member ++ "_);",+                "    " ++ vname +++ "=" +++ vname ++ "->" ++ vname ++ "_;",+                "  }",+                "}",+                ""+               ]       -- Not a list:-      else unlines-	       [-		"void visit" ++ cl ++ "(" ++ cl ++ " _p_)",-		"{",-		"  switch(_p_->kind)",-		"  {",-		concatMap (prPrintRule user) rules,-		"  default:",-		"    fprintf(stderr, \"Error: bad kind field when printing " ++ cl ++ "!\\n\");",-		"    exit(1);",-		"  }",-		"}\n"-	       ]+  | otherwise = unlines+               [+                "void visit" ++ cl ++ "(" ++ cl ++ " _p_)",+                "{",+                "  switch(_p_->kind)",+                "  {",+                concatMap (render . prPrintRule user) rules,+                "  default:",+                "    fprintf(stderr, \"Error: bad kind field when printing " ++ cl ++ "!\\n\");",+                "    exit(1);",+                "  }",+                "}\n"+               ]     where cl = identCat $ normCat cat-	  ecl = identCat $ normCatOfList cat-	  vname = map toLower cl-	  member = map toLower ecl+          ecl = identCat $ normCatOfList cat+          vname = map toLower cl+          member = map toLower ecl --- Visits all the instance variables of a category.-prPrintRule :: [UserDef] -> Rule -> String-prPrintRule user (Rule fun _c cats) | not (isCoercion fun) = unlines-  [-   "  case is_" ++ fun ++ ":",-   "    /* Code for " ++ fun ++ " Goes Here */",-   cats' ++ "    break;"-  ]-   where-    cats' = concatMap (prCat user fun) (zip (fixOnes (numVars [] cats)) cats)+-- | Visits all the instance variables of a category.+-- >>> let ab = Cat "ab"+-- >>> prPrintRule [] (Rule "abc" undefined [Left ab, Left ab])+--   case is_abc:+--     /* Code for abc Goes Here */+--     visitab(_p_->u.abc_.ab_1);+--     visitab(_p_->u.abc_.ab_2);+--     break;+-- >>> prPrintRule [ab] (Rule "abc" undefined [Left ab])+--   case is_abc:+--     /* Code for abc Goes Here */+--     visitAb(_p_->u.abc_.ab_);+--     break;+-- >>> prPrintRule [ab] (Rule "abc" undefined [Left ab, Left ab])+--   case is_abc:+--     /* Code for abc Goes Here */+--     visitAb(_p_->u.abc_.ab_1);+--     visitAb(_p_->u.abc_.ab_2);+--     break;+prPrintRule :: [UserDef] -> Rule -> Doc+prPrintRule user (Rule fun _c cats) | not (isCoercion fun) = nest 2 $ vcat+    [ text $ "case is_" ++ fun ++ ":"+    , nest 2 (vcat+        [ "/* Code for " <> text fun <> " Goes Here */"+        , cats'+        , "break;" ])+    ]+  where+    cats' = vcat $ map (prCat user fun) (lefts (numVars cats)) prPrintRule _user (Rule _fun _ _) = ""  -- Prints the actual instance-variable visiting.-prCat :: [UserDef] -> Fun -> (Either String String, Either Cat String) -> String-prCat user fnm (c, o) =-    case c of-      Right {} -> ""-      Left nt  ->-        if isBasic user nt-	  then "    visit" ++ basicFunName nt ++ "(_p_->u." ++ v ++ "_." ++ nt ++ ");\n"-	  else "    visit" ++ o' ++ "(_p_->u." ++ v ++ "_." ++ nt ++ ");\n"+prCat :: [UserDef] -> Fun -> (Cat, Doc) -> Doc+prCat user fnm (cat, vname) =+      let visitf = "visit" <> if isTokenType user cat+                       then basicFunName cat+                       else text (identCat (normCat cat))+      in visitf <> parens ("_p_->u." <> text v <> "_." <> vname ) <> ";"     where v = map toLower $ normFun fnm-	  o' = case o of-	         Right x -> x-		 Left x  -> identCat $ normCat x ---Just checks if something is a basic or user-defined type.---This is because you don't -> a basic non-pointer type.-isBasic :: [UserDef] -> String -> Bool-isBasic user v =-  if elem (init v) user'-    then True-    else if "integer_" `isPrefixOf` v then True-    else if "char_" `isPrefixOf` v then True-    else if "string_" `isPrefixOf` v then True-    else if "double_" `isPrefixOf` v then True-    else if "ident_" `isPrefixOf` v then True-    else False-  where-   user' = map (map toLower . show) user- --The visit-function name of a basic type-basicFunName :: String -> String-basicFunName v =-    if "integer_" `isPrefixOf` v then "Integer"-    else if "char_" `isPrefixOf` v then "Char"-    else if "string_" `isPrefixOf` v then "String"-    else if "double_" `isPrefixOf` v then "Double"-    else if "ident_" `isPrefixOf` v then "Ident"-    else (toUpper (head v)) : (init (tail v)) --User-defined type+basicFunName :: Cat -> Doc+basicFunName c = text (toUpper (head (show c)): tail (show c))
src/BNFC/Backend/C/CFtoFlexC.hs view
@@ -69,6 +69,7 @@    "#include <string.h>",    "#include \"Parser.h\"",    "#define YY_BUFFER_LENGTH 4096",+   "extern int yy_mylinenumber ;",    "char YY_PARSED_STRING[YY_BUFFER_LENGTH];",    "void YY_BUFFER_APPEND(char *s)",    "{",@@ -115,8 +116,9 @@    ifC catChar    chStates,    ifC catDouble  "<YYINITIAL>{DIGIT}+\".\"{DIGIT}+(\"e\"(\\-)?{DIGIT}+)?      \t yylval.double_ = atof(yytext); return _DOUBLE_;\n",    ifC catInteger "<YYINITIAL>{DIGIT}+      \t yylval.int_ = atoi(yytext); return _INTEGER_;\n",-   ifC catIdent   "<YYINITIAL>{LETTER}{IDENT}*      \t yylval.string_ = strdup(yytext); return _IDENT_;\n"-   , "<YYINITIAL>[ \\t\\r\\n\\f]      \t /* ignore white space. */;\n",+   ifC catIdent   "<YYINITIAL>{LETTER}{IDENT}*      \t yylval.string_ = strdup(yytext); return _IDENT_;\n",+   "\\n ++yy_mylinenumber ;\n",+   "<YYINITIAL>[ \\t\\r\\n\\f]      \t /* ignore white space. */;\n",    "<YYINITIAL>.      \t return _ERROR_;\n",    "%%\n",    footer@@ -162,7 +164,7 @@  lexSingleComment :: String -> String lexSingleComment c =-  "<YYINITIAL>\"" ++ c ++ "\"[^\\n]*\\n      \t /* BNFC single-line comment */;"+  "<YYINITIAL>\"" ++ c ++ "\"[^\\n]*\\n     ++yy_mylinenumber; \t /* BNFC single-line comment */;"  --There might be a possible bug here if a language includes 2 multi-line comments. --They could possibly start a comment with one character and end it with another.@@ -172,7 +174,7 @@   "<YYINITIAL>\"" ++ b ++ "\"      \t BEGIN COMMENT;",   "<COMMENT>\"" ++ e ++ "\"      \t BEGIN YYINITIAL;",   "<COMMENT>.      \t /* BNFC multi-line comment */;",-  "<COMMENT>[\\n]      \t /* BNFC multi-line comment */;"+  "<COMMENT>[\\n]    ++yy_mylinenumber ; \t /* BNFC multi-line comment */;"   ]  --Helper function that escapes characters in strings
src/BNFC/Backend/CPP/NoSTL.hs view
@@ -20,14 +20,14 @@ module BNFC.Backend.CPP.NoSTL (makeCppNoStl) where  import BNFC.Utils-import BNFC.Options import BNFC.CF+import BNFC.Options import BNFC.Backend.Base import BNFC.Backend.CPP.NoSTL.CFtoCPPAbs import BNFC.Backend.CPP.NoSTL.CFtoFlex import BNFC.Backend.CPP.NoSTL.CFtoBison import BNFC.Backend.CPP.NoSTL.CFtoCVisitSkel-import BNFC.Backend.CPP.NoSTL.CFtoCPPPrinter+import BNFC.Backend.CPP.PrettyPrinter import Data.Char import qualified BNFC.Backend.Common.Makefile as Makefile @@ -45,7 +45,7 @@     let (skelH, skelC) = cf2CVisitSkel cf     mkfile "Skeleton.H" skelH     mkfile "Skeleton.C" skelC-    let (prinH, prinC) = cf2CPPPrinter cf+    let (prinH, prinC) = cf2CPPPrinter False Nothing cf     mkfile "Printer.H" prinH     mkfile "Printer.C" prinC     mkfile "Test.C" (cpptest cf)@@ -54,19 +54,29 @@  makefile :: String -> String makefile name =-  (++) (unlines [ "CC = g++", "CCFLAGS = -g", "FLEX = flex", "BISON = bison", "" ])-  $ Makefile.mkRule "all" [ "Test" ++ name ]+  (unlines [ "CC = g++",+             "CCFLAGS = -g -W -Wall", "",+             "FLEX = flex",+             "FLEX_OPTS = -P" ++ name, "",+             "BISON = bison",+             "BISON_OPTS = -t -p" ++ name, "",+             "OBJS = Absyn.o Lexer.o Parser.o Printer.o", "" ] ++)+  $ Makefile.mkRule ".PHONY" ["clean", "distclean"]     []+  $ Makefile.mkRule "all" [testName]+    []   $ Makefile.mkRule "clean" []     -- peteg: don't nuke what we generated - move that to the "vclean" target.-    [ "rm -f *.o " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps Test" ++ name ]-  $ Makefile.mkRule "distclean" []-    [ "rm -f *.o Absyn.C Absyn.H Test.C Parser.C Parser.H Lexer.C Skeleton.C Skeleton.H Printer.C Printer.H"-    , "rm -f " ++ name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex " ++ name ++ ".dvi " ++ name ++ ".aux "-    , "rm -f " ++ name ++ ".log " ++ name ++ ".ps Test" ++ name ++ " Makefile" ]-  $ Makefile.mkRule ("Test" ++ name) [ "Absyn.o", "Lexer.o", "Parser.o", "Printer.o", "Test.o" ]-    [ "@echo \"Linking Test" ++ name ++ "...\""-    , "${CC} ${CCFLAGS} *.o -o Test" ++ name ]+    [ "rm -f *.o " ++ testName ++ " " ++ unwords+      [ name ++ e | e <- [".aux", ".log", ".pdf",".dvi", ".ps", ""]] ]+  $ Makefile.mkRule "distclean" ["clean"]+    [ "rm -f " ++ unwords+      [ "Absyn.C", "Absyn.H", "Test.C", "Parser.C", "Parser.H", "Lexer.C",+        "Skeleton.C", "Skeleton.H", "Printer.C", "Printer.H", "Makefile " ]+      ++ name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex "]+  $ Makefile.mkRule (testName) [ "${OBJS}", "Test.o" ]+    [ "@echo \"Linking " ++ testName ++ "...\""+    , "${CC} ${CCFLAGS} ${OBJS} Test.o -o " ++ testName ]   $ Makefile.mkRule "Absyn.o" [ "Absyn.C", "Absyn.H" ]     [ "${CC} ${CCFLAGS} -c Absyn.C" ]   $ Makefile.mkRule "Lexer.C" [ name ++ ".l" ]@@ -82,7 +92,7 @@   $ Makefile.mkRule "Test.o" [ "Test.C", "Parser.H", "Printer.H", "Absyn.H" ]     [ "${CC} ${CCFLAGS} -c Test.C" ]   ""-+  where testName = "Test" ++ name  cpptest :: CF -> String cpptest cf =
src/BNFC/Backend/CPP/NoSTL/CFtoBison.hs view
@@ -63,10 +63,13 @@ import BNFC.CF import Data.List (intersperse) import BNFC.Backend.Common.NamedVariables hiding (varName)+import BNFC.Backend.CPP.STL.CFtoBisonSTL (union) import Data.Char (toLower,isUpper) import BNFC.Utils ((+++)) import BNFC.TypeChecker import ErrM+import BNFC.Backend.C.CFtoBisonC (startSymbol)+import BNFC.PrettyPrint  --This follows the basic structure of CFtoHappy. @@ -81,10 +84,11 @@ cf2Bison name cf env  = unlines     [header name cf,-     union (allCats cf),+     render $ union Nothing (allCats cf),      "%token _ERROR_",      tokens user env,      declarations cf,+     startSymbol cf,      specialToks cf,      "%%",      prRules (rulesForBison name cf env)@@ -111,13 +115,14 @@ 	  "}",           "void yyerror(const char *str)",           "{",-          "  std::cout << \"line \" << yy_mylinenumber + 1 << std::endl ;",-          "  fprintf(stderr,\"error: %s\\n\",str);",+          "  extern char *yytext;",+          "  fprintf(stderr,\"error: line %d: %s at %s\\n\", ",+          "    yy_mylinenumber + 1, str, yytext);",           "}", 	  "", 	  definedRules cf, 	  unlines $ map (parseMethod name) (allCatsNorm cf),  -- (allEntryPoints cf), M.F. 2004-09-14 fix of [Ty2] bug.-	  concatMap reverseList (filter isList (allCats cf)),+	  concatMap reverseList (filter isList (allCatsNorm cf)), 	  "%}" 	  ] @@ -217,27 +222,6 @@   c' = identCat (normCat c)   v = (map toLower c') ++ "_" ---The union declaration is special to Bison/Yacc and gives the type of yylval.---For efficiency, we may want to only include used categories here.-union :: [Cat] -> String-union cats = unlines- [-  "%union",-  "{",-  "  int int_;",-  "  char char_;",-  "  double double_;",-  "  char* string_;",-  concatMap mkPointer cats,-  "}"- ]- where --This is a little weird because people can make [Exp2] etc.- mkPointer s | identCat s /= show s = --list. add it even if it refers to a coercion.-   "  " ++ identCat (normCat s) ++ "*" +++ varName s ++ ";\n"- mkPointer s | normCat s == s = --normal cat-   "  " ++ identCat (normCat s) ++ "*" +++ varName s ++ ";\n"- mkPointer _ = ""- --declares non-terminal types. declarations :: CF -> String declarations cf = concatMap (typeNT cf) (allCats cf)@@ -280,8 +264,8 @@      let (p,m) = generatePatterns cf env r])  where    ruleName r = case funRule r of-     "(:)" -> identCat nt-     "(:[])" -> identCat nt+     "(:)" -> identCat (normCat nt)+     "(:[])" -> identCat (normCat nt)      z -> z    revs = reversibleCats cf    eps = allEntryPoints cf@@ -297,7 +281,7 @@   then "0;"   else if isDefinedRule f   then concat [ f, "_", "(", concat $ intersperse ", " ms', ");" ]-  else concat ["new ", normFun f, "(", (concat (intersperse ", " ms')), ");"]+  else concat ["new ", f, "(", (concat (intersperse ", " ms')), ");"]  where   ms' = if b then reverse ms else ms 
src/BNFC/Backend/CPP/NoSTL/CFtoCPPAbs.hs view
@@ -44,6 +44,7 @@ import BNFC.CF import BNFC.Utils((+++),(++++)) import BNFC.Backend.Common.NamedVariables+import BNFC.Backend.Common.OOAbstract import Data.List import Data.Char(toLower) import Text.PrettyPrint@@ -72,33 +73,17 @@   prVisitable,   "",   "/********************   Abstract Syntax Classes    ********************/\n",-  concatMap (prDataH user) (cf2dataLists cf),+  concatMap (prDataH user) (getAbstractSyntax cf),   "",   "#endif"  ]  where   user = fst (unzip (tokenPragmas cf))-  header = "//C++ Abstract Syntax Interface generated by the BNF Converter.\n"-  rules = getRules cf-  classes = rules ++ (getClasses (map show $ allCats cf))-  prForward s | isProperLabel s = "class " ++ (show$normCat$strToCat s) ++ ";\n"+  header = "/* ~~~ C++ Abstract Syntax Interface generated by the BNF Converter.\n ~~~ */"+  classes = allClasses (cf2cabs cf)+  prForward s | isProperLabel s = "class " ++ s ++ ";\n"   prForward _ = ""-  getRules cf = (map testRule (rulesOfCF cf))-  getClasses [] = []-  getClasses (c:cs) =-   if identCat (normCat$strToCat c) /= c-   then getClasses cs-   else if elem c rules-     then getClasses cs-     else c : (getClasses cs) -  testRule (Rule f c _) =-   if isList c-   then if isConsFun f-     then identCat c-     else "_" --ignore this-   else f- --Prints interface classes for all categories. prDataH :: [UserDef] -> Data -> String prDataH  user (cat, rules) =@@ -143,22 +128,21 @@     else --a standard rule     unlines     [-     "class" +++ fun' +++ ": public" +++ super,+     "class" +++ fun +++ ": public" +++ super,      "{",      " public:",      render $ nest 2 $ prInstVars user vs,-     "  " ++ fun' ++ "(const" +++ fun' +++ "&);",-     "  " ++ fun' ++ " &operator=(const" +++ fun' +++ "&);",-     "  " ++ fun' ++ "(" ++ (prConstructorH 1 vs) ++ ");",-     prDestructorH fun',+     "  " ++ fun ++ "(const" +++ fun +++ "&);",+     "  " ++ fun ++ " &operator=(const" +++ fun +++ "&);",+     "  " ++ fun ++ "(" ++ (prConstructorH 1 vs) ++ ");",+     prDestructorH fun,      "  virtual void accept(Visitor *v);",-     "  virtual " +++ fun' +++ " *clone() const;",-     "  void swap(" ++ fun' +++ "&);",+     "  virtual " +++ fun +++ " *clone() const;",+     "  void swap(" ++ fun +++ "&);",      "};\n"     ]    where      vs = getVars cats-     fun' = normFun fun      c' = identCat (normCat c);      mem = drop 4 c'      memstar = if isBasic user mem then "" else "*"@@ -206,9 +190,7 @@      "};"     ]    prVisitFun f | isProperLabel f =-     "  virtual void visit" ++ f' ++ "(" ++ f' ++ " *p) = 0;\n"-    where-       f' = normFun f+     "  virtual void visit" ++ f ++ "(" ++ f ++ " *p) = 0;\n"    prVisitFun _ = ""  --typedefs in the Header make generation much nicer.@@ -257,7 +239,7 @@ mkCFile cf = unlines  [   header,-  concatMap (prDataC user) (cf2dataLists cf)+  concatMap (prDataC user) (getAbstractSyntax cf)  ]  where   user = fst (unzip (tokenPragmas cf))@@ -292,17 +274,16 @@     else --a standard rule     unlines     [-     "/********************   " ++ fun' ++ "    ********************/",-     render $ prConstructorC user fun' vs cats,-     prCopyC user fun' vs,-     prDestructorC user fun' vs,+     "/********************   " ++ fun ++ "    ********************/",+     render $ prConstructorC user fun vs cats,+     prCopyC user fun vs,+     prDestructorC user fun vs,      prAcceptC fun,-     prCloneC user fun' vs,+     prCloneC user fun vs,      ""     ]    where      vs = getVars cats-     fun' = normFun fun      c' = identCat (normCat c)  --These are all built-in list functions.
− src/BNFC/Backend/CPP/NoSTL/CFtoCPPPrinter.hs
@@ -1,597 +0,0 @@-{--   **************************************************************-    BNF Converter Module--    Description   : This module generates the C++ Pretty Printer.-                    It also generates the "show" method for-                    printing an abstract syntax tree.--                    The generated files use the Visitor design pattern.--    Author        : Michael Pellauer (pellauer@cs.chalmers.se)--    License       : GPL (GNU General Public License)--    Created       : 10 August, 2003--    Modified      : 3 September, 2003-                    * Added resizable buffers--   **************************************************************--}--module BNFC.Backend.CPP.NoSTL.CFtoCPPPrinter (cf2CPPPrinter) where--import BNFC.CF-import BNFC.Utils ((+++))-import BNFC.Backend.Common.NamedVariables-import BNFC.Backend.Common.StrUtils (renderCharOrString)-import Data.List-import Data.Char(toLower)----Produces (.H file, .C file)-cf2CPPPrinter :: CF -> (String, String)-cf2CPPPrinter cf = (mkHFile cf groups, mkCFile cf groups)- where-    groups = fixCoercions (ruleGroupsInternals cf)--{- **** Header (.H) File Methods **** -}----An extremely large function to make the Header File-mkHFile :: CF -> [(Cat,[Rule])] -> String-mkHFile _ groups = unlines- [-  printHeader,-  concatMap prDataH groups,-  classFooter,-  showHeader,-  concatMap prDataH groups,-  classFooter,-  footer- ]- where-  printHeader = unlines-   [-    "#ifndef PRINTER_HEADER",-    "#define PRINTER_HEADER",-    "",-    "#include \"Absyn.H\"",-    "#include <stdio.h>",-    "#include <string.h>",-    "#include <stdlib.h>",-    "",-    "/* Certain applications may improve performance by changing the buffer size */",-    "#define BUFFER_INITIAL 2000",-    "/* You may wish to change _L_PAREN or _R_PAREN */",-    "#define _L_PAREN '('",-    "#define _R_PAREN ')'",-    "",-    "class PrintAbsyn : public Visitor",-    "{",-    " protected:",-    "  int _n_, _i_;",-    "  /* The following are simple heuristics for rendering terminals */",-    "  /* You may wish to change them */",-    "  void render(Char c);",-    "  void render(String s);",-    "  void indent(void);",-    "  void backup(void);",-    " public:",-    "  PrintAbsyn(void);",-    "  ~PrintAbsyn(void);",-    "  char* print(Visitable* v);"-   ]-  classFooter = unlines-   [-    "  void visitInteger(Integer i);",-    "  void visitDouble(Double d);",-    "  void visitChar(Char c);",-    "  void visitString(String s);",-    "  void visitIdent(String s);",-    " protected:",-    "  void inline bufAppend(const char* s)",-    "  {",-    "    int len = strlen(s);",-    "    while (cur_ + len > buf_size)",-    "    {",-    "      buf_size *= 2; /* Double the buffer size */",-    "      resizeBuffer();",-    "    }",-    "    for(int n = 0; n < len; n++)",-    "    {",-    "      buf_[cur_ + n] = s[n];",-    "    }",-    "    cur_ += len;",-    "    buf_[cur_] = 0;",-    "  }",-    "  void inline bufAppend(const char c)",-    "  {",-    "    if (cur_ == buf_size)",-    "    {",-    "      buf_size *= 2; /* Double the buffer size */",-    "      resizeBuffer();",-    "    }",-    "    buf_[cur_] = c;",-    "    cur_++;",-    "    buf_[cur_] = 0;",-    "  }",-    "  void inline bufReset(void)",-    "  {",-    "    cur_ = 0;",-    "    buf_size = BUFFER_INITIAL;",-    "    resizeBuffer();",-    "    memset(buf_, 0, buf_size);",-    "  }",-    "  void inline resizeBuffer(void)",-    "  {",-    "    char* temp = (char*) malloc(buf_size);",-    "    if (!temp)",-    "    {",-    "      fprintf(stderr, \"Error: Out of memory while attempting to grow buffer!\\n\");",-    "      exit(1);",-    "    }",-    "    if (buf_)",-    "    {",-    "      strcpy(temp, buf_);",-    "      free(buf_);",-    "    }",-    "    buf_ = temp;",-    "  }",-    "  char *buf_;",-    "  int cur_, buf_size;",-    "};",-    ""-   ]-  showHeader = unlines-   [-    "",-    "class ShowAbsyn : public Visitor",-    "{",-    " public:",-    "  ShowAbsyn(void);",-    "  ~ShowAbsyn(void);",-    "  char* show(Visitable* v);"-   ]-  footer = unlines-   [-    "",-    "#endif"-   ]----Prints all the required method names and their parameters.-prDataH :: (Cat, [Rule]) -> String-prDataH (cat, rules) =- if isList cat- then concat ["  void visit", cl, "(", cl, "* p);\n"]- else abstract ++ (concatMap prRuleH rules)- where-   cl = identCat (normCat cat)-   abstract = case lookupRule (show cat) rules of-    Just _ -> ""-    Nothing ->  "  void visit" ++ cl ++ "(" ++ cl ++ " *p); /* abstract class */\n"----Prints all the methods to visit a rule.-prRuleH :: Rule -> String-prRuleH (Rule fun _ _) | isProperLabel fun = concat-  ["  void visit", fun, "(", fun, " *p);\n"]-prRuleH _ = ""--{- **** Implementation (.C) File Methods **** -}----This makes the .C file by a similar method.-mkCFile :: CF -> [(Cat,[Rule])] -> String-mkCFile cf groups = concat-   [-    header,-    prRender,-    printEntries,-    concatMap (prPrintData user) groups,-    printBasics,-    showEntries,-    concatMap (prShowData user) groups,-    showBasics-   ]-  where-    user = fst (unzip (tokenPragmas cf))-    header = unlines-     [-      "/*** BNFC-Generated Pretty Printer and Abstract Syntax Viewer ***/",-      "",-      "#include \"Printer.H\"",-      ""-     ]-    printEntries = unlines-     [-      "PrintAbsyn::PrintAbsyn(void)",-      "{",-      "  _i_ = 0; _n_ = 0;",-      "  buf_ = 0;",-      "  bufReset();",-      "}",-      "",-      "PrintAbsyn::~PrintAbsyn(void)",-      "{",-      "}",-      "",-      "char* PrintAbsyn::print(Visitable *v)",-      "{",-      "  _i_ = 0; _n_ = 0;",-      "  bufReset();",-      "  v->accept(this);",-      "  return buf_;",-      "}"-     ]-    showEntries = unlines-     [-      "ShowAbsyn::ShowAbsyn(void)",-      "{",-      "  buf_ = 0;",-      "  bufReset();",-      "}",-      "",-      "ShowAbsyn::~ShowAbsyn(void)",-      "{",-      "}",-      "",-      "char* ShowAbsyn::show(Visitable *v)",-      "{",-      "  bufReset();",-      "  v->accept(this);",-      "  return buf_;",-      "}"-     ]-    printBasics = unlines-     [-      "void PrintAbsyn::visitInteger(Integer i)",-      "{",-      "  char tmp[16];",-      "  sprintf(tmp, \"%d\", i);",-      "  bufAppend(tmp);",-      "}",-      "void PrintAbsyn::visitDouble(Double d)",-      "{",-      "  char tmp[16];",-      "  sprintf(tmp, \"%g\", d);",-      "  bufAppend(tmp);",-      "}",-      "void PrintAbsyn::visitChar(Char c)",-      "{",-      "  bufAppend('\\'');",-      "  bufAppend(c);",-      "  bufAppend('\\'');",-      "}",-      "void PrintAbsyn::visitString(String s)",-      "{",-      "  bufAppend('\\\"');",-      "  bufAppend(s);",-      "  bufAppend('\\\"');",-      "}",-      "void PrintAbsyn::visitIdent(String s)",-      "{",-      "  render(s);",-      "}",-      ""-     ]-    showBasics = unlines-     [-      "void ShowAbsyn::visitInteger(Integer i)",-      "{",-      "  char tmp[16];",-      "  sprintf(tmp, \"%d\", i);",-      "  bufAppend(tmp);",-      "}",-      "void ShowAbsyn::visitDouble(Double d)",-      "{",-      "  char tmp[16];",-      "  sprintf(tmp, \"%g\", d);",-      "  bufAppend(tmp);",-      "}",-      "void ShowAbsyn::visitChar(Char c)",-      "{",-      "  bufAppend('\\'');",-      "  bufAppend(c);",-      "  bufAppend('\\'');",-      "}",-      "void ShowAbsyn::visitString(String s)",-      "{",-      "  bufAppend('\\\"');",-      "  bufAppend(s);",-      "  bufAppend('\\\"');",-      "}",-      "void ShowAbsyn::visitIdent(String s)",-      "{",-      "  bufAppend('\\\"');",-      "  bufAppend(s);",-      "  bufAppend('\\\"');",-      "}",-      ""-     ]--{- **** Pretty Printer Methods **** -}----Generates methods for the Pretty Printer-prPrintData :: [UserDef] -> (Cat, [Rule]) -> String-prPrintData user (cat, rules) =- if isList cat- then unlines- [-  "void PrintAbsyn::visit" ++ cl ++ "("++ cl ++ " *" ++ vname ++ ")",-  "{",-  "  while(" ++ vname ++ "!= 0)",-  "  {",-  "    if (" ++ vname ++ "->" ++ vname ++ "_ == 0)",-  "    {",-  visitMember,-  optsep,-  "      " ++ vname +++ "= 0;",-  "    }",-  "    else",-  "    {",-  visitMember,-  "      render(" ++ sep ++ ");",-  "      " ++ vname +++ "=" +++ vname ++ "->" ++ vname ++ "_;",-  "    }",-  "  }",-  "}",-  ""- ] --Not a list:- else abstract ++ (concatMap (prPrintRule user) rules)- where-   cl = identCat (normCat cat)-   ecl = identCat (normCatOfList cat)-   vname = map toLower cl-   member = map toLower ecl ++ "_"-   visitMember = if isBasic user member-     then "      visit" ++ (funName member) ++ "(" ++ vname ++ "->" ++ member ++ ");"-     else "      " ++ vname ++ "->" ++ member ++ "->accept(this);"-   sep = snd (renderCharOrString sep')-   sep' = getCons rules-   optsep = if hasOneFunc rules then "" else ("      render(" ++ sep ++ ");")-   abstract = case lookupRule (show cat) rules of-    Just _ -> ""-    Nothing ->  "void PrintAbsyn::visit" ++ cl ++ "(" ++ cl ++ "*p) {} //abstract class\n\n"----Pretty Printer methods for a rule.-prPrintRule :: [UserDef] -> Rule -> String-prPrintRule user r@(Rule fun _ cats) | isProperLabel fun = unlines-  [-   "void PrintAbsyn::visit" ++ fun ++ "(" ++ fun ++ "*" +++ fnm ++ ")",-   "{",-   "  int oldi = _i_;",-   lparen,-   cats',-   rparen,-   "  _i_ = oldi;",-   "}\n"-  ]-   where-    p = precRule r-    (lparen, rparen) =-      ("  if (oldi > " ++ (show p) ++ ") render(_L_PAREN);\n",-       "  if (oldi > " ++ (show p) ++ ") render(_R_PAREN);\n")-    cats' = (concatMap (prPrintCat user fnm) (zip (fixOnes (numVars [] cats)) (map getPrec cats)))-    fnm = "p" --old names could cause conflicts-    getPrec (Right _) = 0-    getPrec (Left c) = precCat c-prPrintRule _ _ = ""----This goes on to recurse to the instance variables.-prPrintCat :: [UserDef] -> String -> (Either String String, Integer) -> String-prPrintCat user fnm (c,p) = case c of-  (Right t) -> "  render(" ++ t' ++ ");\n"-    where-     t' = snd (renderCharOrString t)-  (Left nt) -> if isBasic user nt-       then "  visit" ++ (funName nt) ++ "(" ++ fnm ++ "->" ++ nt ++ ");\n"-       else if "list" `isPrefixOf` nt-         then "  if(" ++ fnm ++ "->" ++ nt ++ ") {" ++ accept ++ "}"-	 else "  " ++ accept ++ "\n"-     where-       accept = if nt == "#_" --Internal category-         then "/* Internal Category */\n"-         else (setI p) ++ fnm ++ "->" ++ nt ++ "->accept(this);"---{- **** Abstract Syntax Tree Printer **** -}----This prints the functions for Abstract Syntax tree printing.-prShowData :: [UserDef] -> (Cat, [Rule]) -> String-prShowData user (cat, rules) =- if isList cat- then unlines- [-  "void ShowAbsyn::visit" ++ cl ++ "("++ cl ++ " *" ++ vname ++ ")",-  "{",-  "  while(" ++ vname ++ "!= 0)",-  "  {",-  "    if (" ++ vname ++ "->" ++ vname ++ "_)",-  "    {",-  visitMember,-  "      bufAppend(\", \");",-  "      " ++ vname +++ "=" +++ vname ++ "->" ++ vname ++ "_;",-  "    }",-  "    else",-  "    {",-  visitMember,-  "      " ++ vname ++ " = 0;",-  "    }",-  "  }",-  "}",-  ""- ] --Not a list:- else abstract ++ (concatMap (prShowRule user) rules)- where-   cl = identCat (normCat cat)-   ecl = identCat (normCatOfList cat)-   vname = map toLower cl-   member = map toLower ecl ++ "_"-   visitMember = if isBasic user member-     then "      visit" ++ (funName member) ++ "(" ++ vname ++ "->" ++ member ++ ");"-     else "      " ++ vname ++ "->" ++ member ++ "->accept(this);"-   abstract = case lookupRule (show cat) rules of-    Just _ -> ""-    Nothing ->  "void ShowAbsyn::visit" ++ cl ++ "(" ++ cl ++ "* p) {} //abstract class\n\n"----This prints all the methods for Abstract Syntax tree rules.-prShowRule :: [UserDef] -> Rule -> String-prShowRule user (Rule fun _ cats) | isProperLabel fun = concat-  [-   "void ShowAbsyn::visit" ++ fun ++ "(" ++ fun ++ "*" +++ fnm ++ ")\n",-   "{\n",-   lparen,-   "  bufAppend(\"" ++ fun ++ "\");\n",-   optspace,-   cats',-   rparen,-   "}\n"-  ]-   where-    (optspace, lparen, rparen) = if allTerms cats-      then ("","","")-      else ("  bufAppend(' ');\n", "  bufAppend('(');\n","  bufAppend(')');\n")-    cats' = if allTerms cats-        then ""-    	else concat (insertSpaces (map (prShowCat user fnm) (fixOnes (numVars [] cats))))-    insertSpaces [] = []-    insertSpaces (x:[]) = [x]-    insertSpaces (x:xs) = if x == ""-      then insertSpaces xs-      else (x : ["  bufAppend(' ');\n"]) ++ insertSpaces xs-    allTerms [] = True-    allTerms (Left _:_) = False-    allTerms (_:zs) = allTerms zs-    fnm = "p" --other names could cause conflicts-prShowRule _ _ = ""----This recurses to the instance variables of a class.-prShowCat :: [UserDef] -> String -> Either String String -> String-prShowCat user fnm c =-  case c of-    (Right _) -> ""-    (Left nt) ->-      if isBasic user nt-       then "  visit" ++ (funName nt) ++ "(" ++ fnm ++ "->" ++ nt ++ ");\n"-       else if nt == "#_" --internal category-       then "/* Internal Category */\n"-       else if ((show$normCat$strToCat nt) /= nt)-          then accept- 	  else concat-	  [-	   "  bufAppend('[');\n",-	   "  if (" ++ fnm ++ "->" ++ nt ++ ")" ++ accept,-	   "  bufAppend(']');\n"-	  ]-       where-         accept = "  " ++ fnm ++ "->" ++ nt ++ "->accept(this);\n"--{- **** Helper Functions Section **** -}-----Just checks if something is a basic or user-defined type.---This is because you don't -> a basic non-pointer type.-isBasic :: [UserDef] -> String -> Bool-isBasic user v =-  if elem (init v) user'-    then True-    else if "integer_" `isPrefixOf` v then True-    else if "char_" `isPrefixOf` v then True-    else if "string_" `isPrefixOf` v then True-    else if "double_" `isPrefixOf` v then True-    else if "ident_" `isPrefixOf` v then True-    else False-  where-   user' = map (map toLower.show) user----The visit-function name of a basic type-funName :: String -> String-funName v =-    if "integer_" `isPrefixOf` v then "Integer"-    else if "char_" `isPrefixOf` v then "Char"-    else if "string_" `isPrefixOf` v then "String"-    else if "double_" `isPrefixOf` v then "Double"-    else if "ident_" `isPrefixOf` v then "Ident"-    else "Ident" --User-defined type----Just sets the coercion level for parentheses in the Pretty Printer.-setI :: Integer -> String-setI n = "_i_ = " ++ (show n) ++ "; "----An extremely simple renderer for terminals.-prRender :: String-prRender = unlines-  [-      "//You may wish to change render",-      "void PrintAbsyn::render(Char c)",-      "{",-      "  if (c == '{')",-      "  {",-      "     bufAppend('\\n');",-      "     indent();",-      "     bufAppend(c);",-      "     _n_ = _n_ + 2;",-      "     bufAppend('\\n');",-      "     indent();",-      "  }",-      "  else if (c == '(' || c == '[')",-      "     bufAppend(c);",-      "  else if (c == ')' || c == ']')",-      "  {",-      "     backup();",-      "     bufAppend(c);",-      "     bufAppend(' ');",-      "  }",-      "  else if (c == '}')",-      "  {",-      "     _n_ = _n_ - 2;",-      "     backup();",-      "     backup();",-      "     bufAppend(c);",-      "     bufAppend('\\n\');",-      "     indent();",-      "  }",-      "  else if (c == ',')",-      "  {",-      "     backup();",-      "     bufAppend(c);",-      "     bufAppend(' ');",-      "  }",-      "  else if (c == ';')",-      "  {",-      "     backup();",-      "     bufAppend(c);",-      "     bufAppend('\\n');",-      "     indent();",-      "  }",-      "  else if (c == 0) return;",-      "  else",-      "  {",-      "     bufAppend(c);",-      "     bufAppend(' ');",-      "  }",-      "}",-      "void PrintAbsyn::render(String s)",-      "{",-      "  if(strlen(s) > 0)",-      "  {",-      "    bufAppend(s);",-      "    bufAppend(' ');",-      "  }",-      "}",-      "void PrintAbsyn::indent()",-      "{",-      "  int n = _n_;",-      "  while (n > 0)",-      "  {",-      "    bufAppend(' ');",-      "    n--;",-      "  }",-      "}",-      "void PrintAbsyn::backup()",-      "{",-      "  if (buf_[cur_ - 1] == ' ')",-      "  {",-      "    buf_[cur_ - 1] = 0;",-      "    cur_--;",-      "  }",-      "}"-  ]
src/BNFC/Backend/CPP/NoSTL/CFtoCVisitSkel.hs view
@@ -42,8 +42,11 @@ import BNFC.CF import BNFC.Utils ((+++)) import BNFC.Backend.Common.NamedVariables+import BNFC.Backend.Utils (isTokenType) import Data.List import Data.Char(toLower, toUpper)+import Data.Either (lefts)+import BNFC.PrettyPrint  --Produces (.H file, .C file) cf2CVisitSkel :: CF -> (String, String)@@ -188,7 +191,7 @@   "}",   ""  ] --Not a list:- else abstract ++ (concatMap (prRule user) rules)+ else abstract ++ (concatMap (render . prRule user) rules)  where    cl = identCat (normCat cat)    vname = map toLower cl@@ -201,37 +204,43 @@     Just _ -> ""     Nothing ->  "void Skeleton::visit" ++ cl ++ "(" ++ cl ++ "*" +++ vname ++ ") {} //abstract class\n\n" ---Visits all the instance variables of a category.-prRule :: [UserDef] -> Rule -> String-prRule user (Rule fun _ cats) | not (isCoercion fun) = unlines-  [-   "void Skeleton::visit" ++ fun ++ "(" ++ fun ++ "*" +++ fnm ++ ")",-   "{",-   "  /* Code For " ++ fun ++ " Goes Here */",-   "",-   cats' ++ "}\n"+-- | Visits all the instance variables of a category.+-- >>> prRule [Cat "A"] (Rule "F" (Cat "S") [Right "X", Left (Cat "A"), Left (Cat "B")])+-- void Skeleton::visitF(F* f)+-- {+--   /* Code For F Goes Here */+-- <BLANKLINE>+--   visitA(f->a_);+--   f->b_->accept(this);+-- }+prRule :: [UserDef] -> Rule -> Doc+prRule user (Rule fun _ cats) | not (isCoercion fun) = vcat+  [ text ("void Skeleton::visit" ++ fun ++ "(" ++ fun ++ "*" +++ fnm ++ ")")+  , codeblock 2+      [ text ("/* Code For " ++ fun ++ " Goes Here */")+      , ""+      , cats'+      ]   ]    where-    cats' = if allTerms cats-        then ""-    	else (concatMap (prCat user fnm) (fixOnes (numVars [] cats)))-    allTerms [] = True-    allTerms (Left _:_) = False-    allTerms (_:zs) = allTerms zs+    cats' = vcat (map (prCat user fnm) (lefts (numVars cats)))     fnm = map toLower fun prRule _ _ = "" ---Prints the actual instance-variable visiting.-prCat user fnm c =-  case c of-    (Right _) -> ""-    (Left nt) -> if isBasic user nt-       then "  visit" ++ (funName nt) ++ "(" ++ fnm ++ "->" ++ nt ++ ");\n"-       else if "list" `isPrefixOf` nt-         then "  if (" ++ fnm ++ "->" ++ nt ++ ") {" ++ accept ++ "}\n"-	 else "  " ++ accept ++ "\n"-      where-       accept = fnm ++ "->" ++ nt ++ "->accept(this);"+-- | Prints the actual instance-variable visiting.+-- >>> prCat [] "Myfun" (Cat "Integer", "integer_")+-- visitInteger(Myfun->integer_);+-- >>> prCat [] "Myfun" (ListCat (Cat "A"), "lista_")+-- if (Myfun->lista_) {Myfun->lista_->accept(this);}+-- >>> prCat [] "Myfun" (Cat "A", "a_")+-- Myfun->a_->accept(this);+prCat :: [Cat] -> String -> (Cat, Doc) -> Doc+prCat user fnm (cat, nt)+  | isTokenType user cat = "visit" <> text (funName (render nt)) <> parens (fname <> "->" <> nt) <> ";"+  | isList cat = "if" <+> parens (fname <> "->" <> nt) <+> braces accept+  | otherwise = accept+  where accept = fname <> "->" <> nt <> "->accept(this);"+        fname = text fnm  --Just checks if something is a basic or user-defined type. --This is because you don't -> a basic non-pointer type.
src/BNFC/Backend/CPP/NoSTL/RegToFlex.hs view
@@ -66,6 +66,7 @@ -- Handle special characters in regular expressions. mkEsc :: String -> String mkEsc = concatMap escChar-    where escChar c-	      | c `elem` "$+-*=<>[](){}!?.,;:^~|&%#/\\$_@\"" = '\\':[c]-	      | otherwise = [c]+  where+    escChar c+      | c `elem` ("$+-*=<>[](){}!?.,;:^~|&%#/\\$_@\"" :: String) = '\\':[c]+      | otherwise = [c]
+ src/BNFC/Backend/CPP/PrettyPrinter.hs view
@@ -0,0 +1,727 @@+{-+   **************************************************************+    BNF Converter Module++    Description   : This module generates the C++ Pretty Printer.+                    It also generates the "show" method for+                    printing an abstract syntax tree.++                    The generated files use the Visitor design pattern.++    Author        : Michael Pellauer (pellauer@cs.chalmers.se)++    License       : GPL (GNU General Public License)++    Created       : 10 August, 2003++    Modified      : 3 September, 2003+                    * Added resizable buffers++   **************************************************************+-}++module BNFC.Backend.CPP.PrettyPrinter (cf2CPPPrinter, prRender) where++import BNFC.CF+import BNFC.Utils ((+++))+import BNFC.Backend.Common+import BNFC.Backend.Common.NamedVariables+import BNFC.Backend.Common.StrUtils (renderCharOrString)+import Data.Char(toLower)+import BNFC.Backend.CPP.STL.STLUtils+import BNFC.PrettyPrint++--Produces (.H file, .C file)+cf2CPPPrinter :: Bool -> Maybe String -> CF -> (String, String)+cf2CPPPrinter useStl inPackage cf =+    (mkHFile useStl inPackage cf groups, mkCFile useStl inPackage cf groups)+ where+    groups = positionRules cf ++ fixCoercions (ruleGroupsInternals cf)++positionRules :: CF -> [(Cat,[Rule])]+positionRules cf =+      [(cat,[Rule (show cat) cat [Left catString, Left catInteger]]) |+        cat <- filter (isPositionCat cf) $ fst (unzip (tokenPragmas cf))]++{- **** Header (.H) File Methods **** -}++--An extremely large function to make the Header File+mkHFile :: Bool -> Maybe String -> CF -> [(Cat,[Rule])] -> String+mkHFile useStl inPackage cf groups = unlines+ [+  printHeader,+  concatMap prDataH groups,+  classFooter,+  showHeader,+  concatMap prDataH groups,+  classFooter,+  footer+ ]+ where+  printHeader = unlines+   [+    "#ifndef " ++ hdef,+    "#define " ++ hdef,+    "",+    "#include \"Absyn.H\"",+    "#include <stdio.h>",+    "#include <string.h>",+    "#include <stdlib.h>",+    "",+    nsStart inPackage,+    "/* Certain applications may improve performance by changing the buffer size */",+    "#define " ++ nsDefine inPackage "BUFFER_INITIAL" ++ " 2000",+    "/* You may wish to change _L_PAREN or _R_PAREN */",+    "#define " ++ nsDefine inPackage "_L_PAREN" ++ " '('",+    "#define " ++ nsDefine inPackage "_R_PAREN" ++ " ')'",+    "",+    "class PrintAbsyn : public Visitor",+    "{",+    " protected:",+    "  int _n_, _i_;",+    "  /* The following are simple heuristics for rendering terminals */",+    "  /* You may wish to change them */",+    "  void render(Char c);",+    "  void render(String s);",+    if useStl then "void render(char* s);" else "",+    "  void indent(void);",+    "  void backup(void);",+    " public:",+    "  PrintAbsyn(void);",+    "  ~PrintAbsyn(void);",+    "  char* print(Visitable* v);"+   ]+  hdef = nsDefine inPackage "PRINTER_HEADER"+  classFooter = unlines $+   [+    "  void visitInteger(Integer i);",+    "  void visitDouble(Double d);",+    "  void visitChar(Char c);",+    "  void visitString(String s);",+    "  void visitIdent(String s);"+   ] ++ ["  void visit" ++ t ++ "(String s);" | t <- tokenNames cf] +++   [+    " protected:",+    "  void inline bufAppend(const char* s)",+    "  {",+    "    int len = strlen(s);",+    "    while (cur_ + len > buf_size)",+    "    {",+    "      buf_size *= 2; /* Double the buffer size */",+    "      resizeBuffer();",+    "    }",+    "    for(int n = 0; n < len; n++)",+    "    {",+    "      buf_[cur_ + n] = s[n];",+    "    }",+    "    cur_ += len;",+    "    buf_[cur_] = 0;",+    "  }",+    "  void inline bufAppend(const char c)",+    "  {",+    "    if (cur_ == buf_size)",+    "    {",+    "      buf_size *= 2; /* Double the buffer size */",+    "      resizeBuffer();",+    "    }",+    "    buf_[cur_] = c;",+    "    cur_++;",+    "    buf_[cur_] = 0;",+    "  }",+    if useStl then render (nest 2 bufAppendString) else "",+    "  void inline bufReset(void)",+    "  {",+    "    cur_ = 0;",+    "    buf_size = " ++ nsDefine inPackage "BUFFER_INITIAL" ++ ";",+    "    resizeBuffer();",+    "    memset(buf_, 0, buf_size);",+    "  }",+    "  void inline resizeBuffer(void)",+    "  {",+    "    char* temp = (char*) malloc(buf_size);",+    "    if (!temp)",+    "    {",+    "      fprintf(stderr, \"Error: Out of memory while attempting to grow buffer!\\n\");",+    "      exit(1);",+    "    }",+    "    if (buf_)",+    "    {",+    "      strcpy(temp, buf_);",+    "      free(buf_);",+    "    }",+    "    buf_ = temp;",+    "  }",+    "  char *buf_;",+    "  int cur_, buf_size;",+    "};",+    ""+   ]+  bufAppendString :: Doc+  bufAppendString =+      "void inline bufAppend(String str)"+      $$ codeblock 2+          [ "const char* s = str.c_str();"+          , "bufAppend(s);"]+  showHeader = unlines+   [+    "",+    "class ShowAbsyn : public Visitor",+    "{",+    " public:",+    "  ShowAbsyn(void);",+    "  ~ShowAbsyn(void);",+    "  char* show(Visitable* v);"+   ]+  footer = unlines+   [+    nsEnd inPackage,+    "",+    "#endif"+   ]++--Prints all the required method names and their parameters.+prDataH :: (Cat, [Rule]) -> String+prDataH (cat, rules) =+ if isList cat+ then concat ["  void visit", cl, "(", cl, "* p);\n"]+ else abstract ++ concatMap prRuleH rules+ where+   cl = identCat (normCat cat)+   abstract = case lookupRule (show cat) rules of+    Just _ -> ""+    Nothing ->  "  void visit" ++ cl ++ "(" ++ cl ++ " *p); /* abstract class */\n"++--Prints all the methods to visit a rule.+prRuleH :: Rule -> String+prRuleH (Rule fun _ _) | isProperLabel fun = concat+  ["  void visit", fun, "(", fun, " *p);\n"]+prRuleH _ = ""++{- **** Implementation (.C) File Methods **** -}++--This makes the .C file by a similar method.+mkCFile :: Bool -> Maybe String -> CF -> [(Cat,[Rule])] -> String+mkCFile useStl inPackage cf groups = concat+   [+    header,+    nsStart inPackage ++ "\n",+    prRender useStl,+    printEntries,+    concatMap (prPrintData useStl inPackage cf) groups,+    printBasics,+    printTokens,+    showEntries,+    concatMap (prShowData useStl) groups,+    showBasics,+    showTokens,+    nsEnd inPackage ++ "\n"+   ]+  where+    header = unlines+     [+      "/*** BNFC-Generated Pretty Printer and Abstract Syntax Viewer ***/",+      "",+      "#include <string>",+      "#include \"Printer.H\"",+      "#define INDENT_WIDTH 2",+      ""+     ]+    printEntries = unlines+     [+      "PrintAbsyn::PrintAbsyn(void)",+      "{",+      "  _i_ = 0; _n_ = 0;",+      "  buf_ = 0;",+      "  bufReset();",+      "}",+      "",+      "PrintAbsyn::~PrintAbsyn(void)",+      "{",+      "}",+      "",+      "char* PrintAbsyn::print(Visitable *v)",+      "{",+      "  _i_ = 0; _n_ = 0;",+      "  bufReset();",+      "  v->accept(this);",+      "  return buf_;",+      "}"+     ]+    showEntries = unlines+     [+      "ShowAbsyn::ShowAbsyn(void)",+      "{",+      "  buf_ = 0;",+      "  bufReset();",+      "}",+      "",+      "ShowAbsyn::~ShowAbsyn(void)",+      "{",+      "}",+      "",+      "char* ShowAbsyn::show(Visitable *v)",+      "{",+      "  bufReset();",+      "  v->accept(this);",+      "  return buf_;",+      "}"+     ]+    printBasics = unlines+     [+      "void PrintAbsyn::visitInteger(Integer i)",+      "{",+      "  char tmp[16];",+      "  sprintf(tmp, \"%d\", i);",+      "  bufAppend(tmp);",+      "}",+      "void PrintAbsyn::visitDouble(Double d)",+      "{",+      "  char tmp[16];",+      "  sprintf(tmp, \"%g\", d);",+      "  bufAppend(tmp);",+      "}",+      "void PrintAbsyn::visitChar(Char c)",+      "{",+      "  bufAppend('\\'');",+      "  bufAppend(c);",+      "  bufAppend('\\'');",+      "}",+      "void PrintAbsyn::visitString(String s)",+      "{",+      "  bufAppend('\\\"');",+      "  bufAppend(s);",+      "  bufAppend('\\\"');",+      "}",+      "void PrintAbsyn::visitIdent(String s)",+      "{",+      "  render(s);",+      "}",+      ""+     ]++    printTokens = unlines+     [unlines [+      "void PrintAbsyn::visit" ++ t ++ "(String s)",+      "{",+      "  render(s);",+      "}",+      ""+      ] | t <- tokenNames cf+     ]++    showBasics = unlines+     [+      "void ShowAbsyn::visitInteger(Integer i)",+      "{",+      "  char tmp[16];",+      "  sprintf(tmp, \"%d\", i);",+      "  bufAppend(tmp);",+      "}",+      "void ShowAbsyn::visitDouble(Double d)",+      "{",+      "  char tmp[16];",+      "  sprintf(tmp, \"%g\", d);",+      "  bufAppend(tmp);",+      "}",+      "void ShowAbsyn::visitChar(Char c)",+      "{",+      "  bufAppend('\\'');",+      "  bufAppend(c);",+      "  bufAppend('\\'');",+      "}",+      "void ShowAbsyn::visitString(String s)",+      "{",+      "  bufAppend('\\\"');",+      "  bufAppend(s);",+      "  bufAppend('\\\"');",+      "}",+      "void ShowAbsyn::visitIdent(String s)",+      "{",+      "  bufAppend('\\\"');",+      "  bufAppend(s);",+      "  bufAppend('\\\"');",+      "}",+      ""+     ]++    showTokens = unlines+     [unlines [+      "void ShowAbsyn::visit" ++ t ++ "(String s)",+      "{",+      "  bufAppend('\\\"');",+      "  bufAppend(s);",+      "  bufAppend('\\\"');",+      "}",+      ""+      ] | t <- tokenNames cf+     ]+++{- **** Pretty Printer Methods **** -}++--Generates methods for the Pretty Printer+prPrintData :: Bool -> Maybe String -> CF -> (Cat, [Rule]) -> String+prPrintData True {- use STL -} _ _ (cat@(ListCat _), rules) =+    render $ genPrintVisitorList (cat, rules)+prPrintData False {- use STL -} _ _ (cat@(ListCat _), rules) =+    genPrintVisitorListNoStl (cat, rules)+prPrintData _ inPackage cf (cat, rules) = -- Not a list+ -- a position token+ if isPositionCat cf cat then unlines [+   "void PrintAbsyn::visit" ++ show cat ++ "(" ++ show cat ++ "* p)",+   "{",+   "  visitIdent(p->string_);",+   "}"+   ]+ else abstract ++ concatMap (prPrintRule inPackage) rules+ where+   cl = identCat (normCat cat)+   abstract = case lookupRule (show cat) rules of+    Just _ -> ""+    Nothing ->  "void PrintAbsyn::visit" ++ cl ++ "(" ++ cl ++ "*p) {} //abstract class\n\n"++-- | Generate pretty printer visitor for a list category:+--+-- >>> let c = Cat "C" ; lc = ListCat c+-- >>> let rules = [Rule "[]" lc [], Rule "(:)" lc [Left c, Right "-", Left lc]]+-- >>> genPrintVisitorList (lc, rules)+-- void PrintAbsyn::visitListC(ListC *listc)+-- {+--   for (ListC::const_iterator i = listc->begin() ; i != listc->end() ; ++i)+--   {+--     (*i)->accept(this);+--     render('-');+--   }+-- }+--+-- >>> let c2 = CoercCat "C" 2 ; lc2 = ListCat c2+-- >>> let rules2 = rules ++ [Rule "[]" lc2 [], Rule "(:)" lc2 [Left c2, Right "+", Left lc2]]+-- >>> genPrintVisitorList (lc, rules2)+-- void PrintAbsyn::visitListC(ListC *listc)+-- {+--   for (ListC::const_iterator i = listc->begin() ; i != listc->end() ; ++i)+--   {+--     (*i)->accept(this);+--     switch(_i_)+--     {+--       case 2: render('+'); break;+--       default: render('-');+--     }+--   }+-- }+genPrintVisitorList :: (Cat, [Rule]) -> Doc+genPrintVisitorList (cat@(ListCat c), rules) =+    "void PrintAbsyn::visit" <> text cl <> "("<> text cl <> " *" <> vname <> ")"+    $$ codeblock 2+      [ "for ("<> text cl <> "::const_iterator i = " <> vname <> "->begin() ; i != " <> vname <> "->end() ; ++i)"+      , codeblock 2+          [ if isTokenCat c+              then "visit" <> text (baseName cl) <> "(*i) ;"+              else "(*i)->accept(this);"+          , (if hasOneFunc rules+              then "if (i != " <> vname <> "->end() - 1)"+              else empty)+            <+> renderListSepByPrecedence "_i_" renderSep separators+          ]+      ]+ where+   separators = getSeparatorByPrecedence rules+   cl = identCat (normCat cat)+   vname = text $ map toLower cl+   renderSep s = "render(" <> text (snd (renderCharOrString s)) <> ")"+genPrintVisitorList _ = error "genPrintVisitorList expects a ListCat"++-- | This is the only part of the pretty printer that differs significantly+-- between the versions with and without STL.+genPrintVisitorListNoStl :: (Cat, [Rule]) -> String+genPrintVisitorListNoStl (cat@(ListCat c), rules) = unlines+    [ "void PrintAbsyn::visit" ++ cl ++ "("++ cl ++ " *" ++ vname ++ ")"+    , "{"+    , "  while(" ++ vname ++ "!= 0)"+    , "  {"+    , "    if (" ++ vname ++ "->" ++ vname ++ "_ == 0)"+    , "    {"+    , visitMember+    , optsep+    , "      " ++ vname +++ "= 0;"+    , "    }"+    , "    else"+    , "    {"+    , visitMember+    , render $ nest 6 $ renderListSepByPrecedence "_i_" renderSep separators+    , "      " ++ vname +++ "=" +++ vname ++ "->" ++ vname ++ "_;"+    , "    }"+    , "  }"+    , "}"+    , ""+    ]+  where+    visitMember = if isTokenCat c+        then "      visit" ++ funName c ++ "(" ++ vname ++ "->" ++ member ++ ");"+        else "      " ++ vname ++ "->" ++ member ++ "->accept(this);"+    cl = identCat (normCat cat)+    ecl = identCat (normCatOfList cat)+    vname = map toLower cl+    member = map toLower ecl ++ "_"+    optsep = if hasOneFunc rules then "" else "      render(" ++ sep ++ ");"+    sep = snd (renderCharOrString sep')+    sep' = getCons rules+    renderSep s = "render(" <> text (snd (renderCharOrString s)) <> ")"+    separators = getSeparatorByPrecedence rules+genPrintVisitorListNoStl _ = error "genPrintVisitorListNoStl expects a ListCat"++--Pretty Printer methods for a rule.+prPrintRule :: Maybe String -> Rule -> String+prPrintRule inPackage r@(Rule fun _ cats) | isProperLabel fun = unlines+  [+   "void PrintAbsyn::visit" ++ fun ++ "(" ++ fun ++ "*" +++ fnm ++ ")",+   "{",+   "  int oldi = _i_;",+   lparen,+   cats',+   rparen,+   "  _i_ = oldi;",+   "}\n"+  ]+   where+    p = precRule r+    (lparen, rparen) =+      ("  if (oldi > " ++ show p ++ ") render(" ++ nsDefine inPackage "_L_PAREN" ++ ");\n",+       "  if (oldi > " ++ show p ++ ") render(" ++ nsDefine inPackage "_R_PAREN" ++ ");\n")+    cats' = concatMap (prPrintCat fnm) (numVars cats)+    fnm = "p" --old names could cause conflicts+prPrintRule _ _ = ""++--This goes on to recurse to the instance variables.+prPrintCat :: String -> Either (Cat, Doc) String -> String+prPrintCat _ (Right t) = "  render(" ++ t' ++ ");\n"+  where t' = snd (renderCharOrString t)+prPrintCat fnm (Left (c, nt))+  | isTokenCat c  = "  visit" ++ funName c ++ "(" ++ fnm ++ "->" ++ render nt ++ ");\n"+  | isList c            = "  if(" ++ fnm ++ "->" ++ render nt ++ ") {" ++ accept ++ "}"+  | otherwise           = "  " ++ accept ++ "\n"+  where+    accept+      | c == InternalCat =  "/* Internal Category */\n"+      | otherwise        = setI (precCat c) ++ fnm ++ "->" ++ render nt ++ "->accept(this);"++{- **** Abstract Syntax Tree Printer **** -}++--This prints the functions for Abstract Syntax tree printing.+prShowData :: Bool -> (Cat, [Rule]) -> String+prShowData True (cat@(ListCat c), _) = unlines+ [+  "void ShowAbsyn::visit" ++ cl ++ "("++ cl ++ " *" ++ vname ++ ")",+  "{",+  "  for ("++ cl ++"::const_iterator i = " +++       vname++"->begin() ; i != " ++vname ++"->end() ; ++i)",+  "  {",+  if isTokenCat c+    then "    visit" ++ baseName cl ++ "(*i) ;"+    else "    (*i)->accept(this);",+  "    if (i != " ++ vname ++ "->end() - 1) bufAppend(\", \");",+  "  }",+  "}",+  ""+ ]+  where+    cl = identCat (normCat cat)+    vname = map toLower cl+prShowData False (cat@(ListCat c), _) =+ unlines+ [+  "void ShowAbsyn::visit" ++ cl ++ "("++ cl ++ " *" ++ vname ++ ")",+  "{",+  "  while(" ++ vname ++ "!= 0)",+  "  {",+  "    if (" ++ vname ++ "->" ++ vname ++ "_)",+  "    {",+  visitMember,+  "      bufAppend(\", \");",+  "      " ++ vname +++ "=" +++ vname ++ "->" ++ vname ++ "_;",+  "    }",+  "    else",+  "    {",+  visitMember,+  "      " ++ vname ++ " = 0;",+  "    }",+  "  }",+  "}",+  ""+ ]+  where+    cl = identCat (normCat cat)+    ecl = identCat (normCatOfList cat)+    vname = map toLower cl+    member = map toLower ecl ++ "_"+    visitMember = if isTokenCat c+      then "      visit" ++ funName c ++ "(" ++ vname ++ "->" ++ member ++ ");"+      else "      " ++ vname ++ "->" ++ member ++ "->accept(this);"+prShowData _ (cat, rules) =  --Not a list:+  abstract ++ concatMap prShowRule rules+  where+    cl = identCat (normCat cat)+    abstract = case lookupRule (show cat) rules of+      Just _ -> ""+      Nothing ->  "void ShowAbsyn::visit" ++ cl ++ "(" ++ cl ++ "* p) {} //abstract class\n\n"++--This prints all the methods for Abstract Syntax tree rules.+prShowRule :: Rule -> String+prShowRule (Rule fun _ cats) | isProperLabel fun = concat+  [+   "void ShowAbsyn::visit" ++ fun ++ "(" ++ fun ++ "*" +++ fnm ++ ")\n",+   "{\n",+   lparen,+   "  bufAppend(\"" ++ fun ++ "\");\n",+   optspace,+   cats',+   rparen,+   "}\n"+  ]+   where+    (optspace, lparen, rparen) = if allTerms cats+      then ("","","")+      else ("  bufAppend(' ');\n", "  bufAppend('(');\n","  bufAppend(')');\n")+    cats' = if allTerms cats+        then ""+        else concat (insertSpaces (map (prShowCat fnm) (numVars cats)))+    insertSpaces [] = []+    insertSpaces (x:[]) = [x]+    insertSpaces (x:xs) = if x == ""+      then insertSpaces xs+      else x : "  bufAppend(' ');\n" : insertSpaces xs+    allTerms [] = True+    allTerms (Left _:_) = False+    allTerms (_:zs) = allTerms zs+    fnm = "p" --other names could cause conflicts+prShowRule _ = ""++-- This recurses to the instance variables of a class.+prShowCat :: String -> Either (Cat, Doc) String -> String+prShowCat _ (Right _)               = ""+prShowCat fnm (Left (cat,nt))+  | isTokenCat cat              =+    "  visit" ++ funName cat ++ "(" ++ fnm ++ "->" ++ render nt ++ ");\n"+  | cat == InternalCat                = "/* Internal Category */\n"+  | show (normCat $ strToCat $ render nt) /= render nt = accept+  | otherwise                         =+    concat [+           "  bufAppend('[');\n",+           "  if (" ++ fnm ++ "->" ++ render nt ++ ")" ++ accept,+           "  bufAppend(']');\n"+          ]+  where accept = "  " ++ fnm ++ "->" ++ render nt ++ "->accept(this);\n"++{- **** Helper Functions Section **** -}++-- from ListIdent to Ident+baseName = drop 4+++--The visit-function name of a basic type+funName :: Cat -> String+funName (TokenCat c) | c `elem` builtin = c+  where builtin = ["Integer", "Char", "String", "Double", "Ident" ]+funName _ = "Ident" --User-defined type+--The visit-function name of a basic type+-- funName :: String -> String+-- funName v =+--     if "integer_" `isPrefixOf` v then "Integer"+--     else if "char_" `isPrefixOf` v then "Char"+--     else if "string_" `isPrefixOf` v then "String"+--     else if "double_" `isPrefixOf` v then "Double"+--     else if "ident_" `isPrefixOf` v then "Ident"+--     else "Ident" --User-defined type++--Just sets the coercion level for parentheses in the Pretty Printer.+setI :: Integer -> String+setI n = "_i_ = " ++ show n ++ "; "++--An extremely simple renderer for terminals.+prRender :: Bool -> String+prRender useStl = unlines+  [+      "//You may wish to change render",+      "void PrintAbsyn::render(Char c)",+      "{",+      "  if (c == '{')",+      "  {",+      "     bufAppend('\\n');",+      "     indent();",+      "     bufAppend(c);",+      "     _n_ = _n_ + INDENT_WIDTH;",+      "     bufAppend('\\n');",+      "     indent();",+      "  }",+      "  else if (c == '(' || c == '[')",+      "     bufAppend(c);",+      "  else if (c == ')' || c == ']')",+      "  {",+      "     backup();",+      "     bufAppend(c);",+      "  }",+      "  else if (c == '}')",+      "  {",+      "     int t;",+      "     _n_ = _n_ - INDENT_WIDTH;",+      "     for (t=0; t<INDENT_WIDTH; t++) {",+      "       backup();",+      "     }",+      "     bufAppend(c);",+      "     bufAppend('\\n\');",+      "     indent();",+      "  }",+      "  else if (c == ',')",+      "  {",+      "     backup();",+      "     bufAppend(c);",+      "     bufAppend(' ');",+      "  }",+      "  else if (c == ';')",+      "  {",+      "     backup();",+      "     bufAppend(c);",+      "     bufAppend('\\n');",+      "     indent();",+      "  }",+      "  else if (c == 0) return;",+      "  else",+      "  {",+      "     bufAppend(' ');",+      "     bufAppend(c);",+      "     bufAppend(' ');",+      "  }",+      "}",+      let renderString = "void PrintAbsyn::render(String s_)" $$ codeblock 2+                             [ "const char *s = s_.c_str() ;"+                             , "if(strlen(s) > 0)"+                             , codeblock 2+                                 [ "bufAppend(s);"+                                 , "bufAppend(' ');" ] ]+      in if useStl then render renderString else "",+      "void PrintAbsyn::render(char* s)",+      "{",+      "  if(strlen(s) > 0)",+      "  {",+      "    bufAppend(s);",+      "    bufAppend(' ');",+      "  }",+      "}",+      "void PrintAbsyn::indent()",+      "{",+      "  int n = _n_;",+      "  while (n > 0)",+      "  {",+      "    bufAppend(' ');",+      "    n--;",+      "  }",+      "}",+      "void PrintAbsyn::backup()",+      "{",+      "  if (buf_[cur_ - 1] == ' ')",+      "  {",+      "    buf_[cur_ - 1] = 0;",+      "    cur_--;",+      "  }",+      "}"+  ]
src/BNFC/Backend/CPP/STL.hs view
@@ -21,18 +21,18 @@  module BNFC.Backend.CPP.STL (makeCppStl,) where +import BNFC.Utils+import BNFC.CF import BNFC.Options-import qualified BNFC.Backend.Common.Makefile as Makefile import BNFC.Backend.Base+import BNFC.Backend.CPP.STL.CFtoSTLAbs import BNFC.Backend.CPP.NoSTL.CFtoFlex import BNFC.Backend.CPP.STL.CFtoBisonSTL import BNFC.Backend.CPP.STL.CFtoCVisitSkelSTL-import BNFC.Backend.CPP.STL.CFtoSTLAbs-import BNFC.Backend.CPP.STL.CFtoSTLPrinter+import BNFC.Backend.CPP.PrettyPrinter import BNFC.Backend.CPP.STL.STLUtils-import BNFC.CF-import BNFC.Utils import Data.Char+import qualified BNFC.Backend.Common.Makefile as Makefile  makeCppStl :: SharedOptions -> CF -> MkFiles () makeCppStl opts cf = do@@ -48,7 +48,7 @@     let (skelH, skelC) = cf2CVisitSkel (inPackage opts) cf     mkfile "Skeleton.H" skelH     mkfile "Skeleton.C" skelC-    let (prinH, prinC) = cf2CPPPrinter (inPackage opts) cf+    let (prinH, prinC) = cf2CPPPrinter True (inPackage opts) cf     mkfile "Printer.H" prinH     mkfile "Printer.C" prinC     mkfile "Test.C" (cpptest (inPackage opts) cf)@@ -57,19 +57,29 @@  makefile :: String -> String makefile name =-  (unlines [ "CC = g++", "CCFLAGS = -g", "FLEX = flex", "BISON = bison" ] ++)-  $ Makefile.mkRule "all" [ "Test" ++ name ]+  (unlines [ "CC = g++",+             "CCFLAGS = -g -W -Wall", "",+             "FLEX = flex",+             "FLEX_OPTS = -P" ++ name, "",+             "BISON = bison",+             "BISON_OPTS = -t -p" ++ name, "",+             "OBJS = Absyn.o Lexer.o Parser.o Printer.o", "" ] ++)+  $ Makefile.mkRule ".PHONY" ["clean", "distclean"]     []+  $ Makefile.mkRule "all" [testName]+    []   $ Makefile.mkRule "clean" []    -- peteg: don't nuke what we generated - move that to the "vclean" target.-   [ "rm -f *.o " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log "-   , "rm -f " ++ name ++ ".pdf Test" ++ name ]-  $ Makefile.mkRule "distclean" []-   [ " rm -f *.o Absyn.C Absyn.H Test.C Parser.C Parser.H Lexer.C Skeleton.C Skeleton.H Printer.C Printer.H " ++ name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex " ++ name ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps Test" ++ name ++ " Makefile" ]-  $ Makefile.mkRule ("Test" ++ name) [ "Absyn.o", "Lexer.o",-                                       "Parser.o", "Printer.o", "Test.o" ]-   [ "@echo \"Linking Test" ++ name ++ "...\""-   , "${CC} ${CCFLAGS} *.o -o Test" ++ name ]+    [ "rm -f *.o " ++ testName ++ " " ++ unwords+      [ name ++ e | e <- [".aux", ".log", ".pdf",".dvi", ".ps", ""]] ]+  $ Makefile.mkRule "distclean" ["clean"]+    [ "rm -f " ++ unwords+      [ "Absyn.C", "Absyn.H", "Test.C", "Parser.C", "Parser.H", "Lexer.C",+        "Skeleton.C", "Skeleton.H", "Printer.C", "Printer.H", "Makefile " ]+      ++ name ++ ".l " ++ name ++ ".y " ++ name ++ ".tex "]+  $ Makefile.mkRule (testName) [ "${OBJS}", "Test.o" ]+   [ "@echo \"Linking " ++ testName ++ "...\""+   , "${CC} ${CCFLAGS} ${OBJS} Test.o -o " ++ testName ]   $ Makefile.mkRule "Absyn.o" [ "Absyn.C", "Absyn.H" ]    [ "${CC} ${CCFLAGS} -c Absyn.C" ]   $ Makefile.mkRule "Lexer.C" [ name ++ ".l" ]@@ -87,6 +97,7 @@   $ Makefile.mkRule "Test.o" [ "Test.C", "Parser.H", "Printer.H", "Absyn.H" ]    [ "${CC} ${CCFLAGS} -c Test.C" ]   ""+  where testName = "Test" ++ name  cpptest :: Maybe String -> CF -> String cpptest inPackage cf =
src/BNFC/Backend/CPP/STL/CFtoBisonSTL.hs view
@@ -42,16 +42,18 @@ -}  -module BNFC.Backend.CPP.STL.CFtoBisonSTL (cf2Bison) where+module BNFC.Backend.CPP.STL.CFtoBisonSTL (cf2Bison, union) where  import BNFC.CF-import Data.List (intersperse)+import Data.List (intersperse, nub) import BNFC.Backend.Common.NamedVariables hiding (varName) import Data.Char (toLower,isUpper) import BNFC.Utils ((+++)) import BNFC.TypeChecker import ErrM import BNFC.Backend.CPP.STL.STLUtils+import BNFC.Backend.C.CFtoBisonC (startSymbol)+import BNFC.PrettyPrint  --This follows the basic structure of CFtoHappy. @@ -66,11 +68,12 @@ cf2Bison ln inPackage name cf env  = unlines     [header inPackage name cf,-     union inPackage (positionCats cf ++ allCats cf),+     render $ union inPackage (positionCats cf ++ allCats cf),      maybe "" (\ns -> "%name-prefix=\"" ++ ns ++ "yy\"") inPackage,      "%token _ERROR_",      tokens user env,      declarations cf,+     startSymbol cf,      specialToks cf,      "%%",      prRules (rulesForBison ln inPackage name cf env)@@ -104,8 +107,9 @@ 	  "}",           "void " ++ ns ++ "yyerror(const char *str)",           "{",-          "  std::cout << \"line \" << " ++ ns ++ "yy_mylinenumber << std::endl ;",-          "  fprintf(stderr,\"error: %s\\n\",str);",+          "  extern char *yytext;",+          "  fprintf(stderr,\"error: line %d: %s at %s\\n\", ",+          "    yy_mylinenumber, str, yytext);",           "}", 	  "", 	  definedRules cf,@@ -212,27 +216,49 @@   ns = nsString inPackage  ---The union declaration is special to Bison/Yacc and gives the type of yylval.---For efficiency, we may want to only include used categories here.-union :: Maybe String -> [Cat] -> String-union inPackage cats = unlines- [-  "%union",-  "{",-  "  int int_;",-  "  char char_;",-  "  double double_;",-  "  char* string_;",-  concatMap mkPointer cats,-  "}"- ]- where --This is a little weird because people can make [Exp2] etc.- mkPointer s | identCat s /= show s = --list. add it even if it refers to a coercion.-   "  " ++ scope ++ (identCat (normCat s)) ++ "*" +++ (varName s) ++ ";\n"- mkPointer s | normCat s == s = --normal cat-   "  " ++ scope ++ (identCat (normCat s)) ++ "*" +++ (varName s) ++ ";\n"- mkPointer _ = ""- scope = nsScope inPackage+-- | The union declaration is special to Bison/Yacc and gives the type of+-- yylval.  For efficiency, we may want to only include used categories here.+--+-- >>> let foo = Cat "Foo"+-- >>> union Nothing [foo, ListCat foo]+-- %union+-- {+--   int int_;+--   char char_;+--   double double_;+--   char* string_;+--   Foo* foo_;+--   ListFoo* listfoo_;+-- }+--+-- If the given list of categories is contains coerced categories, those should+-- be normalized and duplicate removed+-- E.g. if there is both [Foo] and [Foo2] we should only print one pointer:+--    ListFoo* listfoo_;+--+-- >>> let foo2 = CoercCat "Foo" 2+-- >>> union Nothing [foo, ListCat foo, foo2, ListCat foo2]+-- %union+-- {+--   int int_;+--   char char_;+--   double double_;+--   char* string_;+--   Foo* foo_;+--   ListFoo* listfoo_;+-- }+union :: Maybe String -> [Cat] -> Doc+union inPackage cats =+    "%union" $$ codeblock 2 (+        [ "int int_;"+        , "char char_;"+        , "double double_;"+        , "char* string_;" ]+        ++ map mkPointer normCats )+  where+    normCats = nub (map normCat cats)+    mkPointer s = scope <> text (identCat s) <> "*" <+> text (varName s) <> ";"+    scope = text (nsScope inPackage)  --declares non-terminal types. declarations :: CF -> String
− src/BNFC/Backend/CPP/STL/CFtoSTLPrinter.hs
@@ -1,638 +0,0 @@-{--   **************************************************************-    BNF Converter Module--    Description   : This module generates the C++ Pretty Printer.-                    It also generates the "show" method for-                    printing an abstract syntax tree.--                    The generated files use the Visitor design pattern.--    Author        : Michael Pellauer (pellauer@cs.chalmers.se)--    License       : GPL (GNU General Public License)--    Created       : 10 August, 2003--    Modified      : 3 September, 2003-                    * Added resizable buffers--   **************************************************************--}--module BNFC.Backend.CPP.STL.CFtoSTLPrinter (cf2CPPPrinter) where--import BNFC.CF-import BNFC.Utils ((+++))-import BNFC.Backend.Common.NamedVariables-import BNFC.Backend.Common.StrUtils (renderCharOrString)-import Data.List-import Data.Char(toLower)-import BNFC.Backend.CPP.STL.STLUtils----Produces (.H file, .C file)-cf2CPPPrinter :: Maybe String -> CF -> (String, String)-cf2CPPPrinter inPackage cf = (mkHFile inPackage cf groups, mkCFile inPackage cf groups)- where-    groups = positionRules cf ++ (fixCoercions (ruleGroupsInternals cf))--positionRules :: CF -> [(Cat,[Rule])]-positionRules cf =-      [(cat,[Rule (show cat) cat [Left catString, Left catInteger]]) |-        cat <- filter (isPositionCat cf) $ fst (unzip (tokenPragmas cf))]--{- **** Header (.H) File Methods **** -}----An extremely large function to make the Header File-mkHFile :: Maybe String -> CF -> [(Cat,[Rule])] -> String-mkHFile inPackage cf groups = unlines- [-  printHeader,-  concatMap prDataH groups,-  classFooter,-  showHeader,-  concatMap prDataH groups,-  classFooter,-  footer- ]- where-  printHeader = unlines-   [-    "#ifndef " ++ hdef,-    "#define " ++ hdef,-    "",-    "#include \"Absyn.H\"",-    "#include <stdio.h>",-    "#include <string.h>",-    "#include <stdlib.h>",-    "",-    nsStart inPackage,-    "/* Certain applications may improve performance by changing the buffer size */",-    "#define " ++ nsDefine inPackage "BUFFER_INITIAL" ++ " 2000",-    "/* You may wish to change _L_PAREN or _R_PAREN */",-    "#define " ++ nsDefine inPackage "_L_PAREN" ++ " '('",-    "#define " ++ nsDefine inPackage "_R_PAREN" ++ " ')'",-    "",-    "class PrintAbsyn : public Visitor",-    "{",-    " protected:",-    "  int _n_, _i_;",-    "  /* The following are simple heuristics for rendering terminals */",-    "  /* You may wish to change them */",-    "  void render(Char c);",-    "  void render(String s);",-    "  void indent(void);",-    "  void backup(void);",-    " public:",-    "  PrintAbsyn(void);",-    "  ~PrintAbsyn(void);",-    "  char* print(Visitable* v);"-   ]-  hdef = nsDefine inPackage "PRINTER_HEADER"-  classFooter = unlines $-   [-    "  void visitInteger(Integer i);",-    "  void visitDouble(Double d);",-    "  void visitChar(Char c);",-    "  void visitString(String s);",-    "  void visitIdent(String s);"-   ] ++ ["  void visit" ++ t ++ "(String s);" | t <- tokenNames cf] ++-   [-    " protected:",-    "  void inline bufAppend(const char* s)",-    "  {",-    "    int len = strlen(s);",-    "    while (cur_ + len > buf_size)",-    "    {",-    "      buf_size *= 2; /* Double the buffer size */",-    "      resizeBuffer();",-    "    }",-    "    for(int n = 0; n < len; n++)",-    "    {",-    "      buf_[cur_ + n] = s[n];",-    "    }",-    "    cur_ += len;",-    "    buf_[cur_] = 0;",-    "  }",-    "  void inline bufAppend(const char c)",-    "  {",-    "    if (cur_ == buf_size)",-    "    {",-    "      buf_size *= 2; /* Double the buffer size */",-    "      resizeBuffer();",-    "    }",-    "    buf_[cur_] = c;",-    "    cur_++;",-    "    buf_[cur_] = 0;",-    "  }",-    "  void inline bufReset(void)",-    "  {",-    "    cur_ = 0;",-    "    buf_size = " ++ nsDefine inPackage "BUFFER_INITIAL" ++ ";",-    "    resizeBuffer();",-    "    memset(buf_, 0, buf_size);",-    "  }",-    "  void inline resizeBuffer(void)",-    "  {",-    "    char* temp = (char*) malloc(buf_size);",-    "    if (!temp)",-    "    {",-    "      fprintf(stderr, \"Error: Out of memory while attempting to grow buffer!\\n\");",-    "      exit(1);",-    "    }",-    "    if (buf_)",-    "    {",-    "      strcpy(temp, buf_);",-    "      free(buf_);",-    "    }",-    "    buf_ = temp;",-    "  }",-    "  char *buf_;",-    "  int cur_, buf_size;",-    "};",-    ""-   ]-  showHeader = unlines-   [-    "",-    "class ShowAbsyn : public Visitor",-    "{",-    " public:",-    "  ShowAbsyn(void);",-    "  ~ShowAbsyn(void);",-    "  char* show(Visitable* v);"-   ]-  footer = unlines-   [-    nsEnd inPackage,-    "",-    "#endif"-   ]----Prints all the required method names and their parameters.-prDataH :: (Cat, [Rule]) -> String-prDataH (cat, rules) =- if isList cat- then concat ["  void visit", cl, "(", cl, "* p);\n"]- else abstract ++ (concatMap prRuleH rules)- where-   cl = identCat (normCat cat)-   abstract = case lookupRule (show cat) rules of-    Just _ -> ""-    Nothing ->  "  void visit" ++ cl ++ "(" ++ cl ++ " *p); /* abstract class */\n"----Prints all the methods to visit a rule.-prRuleH :: Rule -> String-prRuleH (Rule fun _ _) | isProperLabel fun = concat-  ["  void visit", fun, "(", fun, " *p);\n"]-prRuleH _ = ""--{- **** Implementation (.C) File Methods **** -}----This makes the .C file by a similar method.-mkCFile :: Maybe String -> CF -> [(Cat,[Rule])] -> String-mkCFile inPackage cf groups = concat-   [-    header,-    nsStart inPackage ++ "\n",-    prRender,-    printEntries,-    concatMap (prPrintData inPackage cf user) groups,-    printBasics,-    printTokens,-    showEntries,-    concatMap (prShowData user) groups,-    showBasics,-    showTokens,-    nsEnd inPackage ++ "\n"-   ]-  where-    user0 = fst (unzip (tokenPragmas cf))-    (_,user) = partition (isPositionCat cf) user0-    header = unlines-     [-      "/*** BNFC-Generated Pretty Printer and Abstract Syntax Viewer ***/",-      "",-      "#include <string>",-      "#include \"Printer.H\"",-      ""-     ]-    printEntries = unlines-     [-      "PrintAbsyn::PrintAbsyn(void)",-      "{",-      "  _i_ = 0; _n_ = 0;",-      "  buf_ = 0;",-      "  bufReset();",-      "}",-      "",-      "PrintAbsyn::~PrintAbsyn(void)",-      "{",-      "}",-      "",-      "char* PrintAbsyn::print(Visitable *v)",-      "{",-      "  _i_ = 0; _n_ = 0;",-      "  bufReset();",-      "  v->accept(this);",-      "  return buf_;",-      "}"-     ]-    showEntries = unlines-     [-      "ShowAbsyn::ShowAbsyn(void)",-      "{",-      "  buf_ = 0;",-      "  bufReset();",-      "}",-      "",-      "ShowAbsyn::~ShowAbsyn(void)",-      "{",-      "}",-      "",-      "char* ShowAbsyn::show(Visitable *v)",-      "{",-      "  bufReset();",-      "  v->accept(this);",-      "  return buf_;",-      "}"-     ]-    printBasics = unlines-     [-      "void PrintAbsyn::visitInteger(Integer i)",-      "{",-      "  char tmp[16];",-      "  sprintf(tmp, \"%d\", i);",-      "  bufAppend(tmp);",-      "}",-      "void PrintAbsyn::visitDouble(Double d)",-      "{",-      "  char tmp[16];",-      "  sprintf(tmp, \"%g\", d);",-      "  bufAppend(tmp);",-      "}",-      "void PrintAbsyn::visitChar(Char c)",-      "{",-      "  bufAppend('\\'');",-      "  bufAppend(c);",-      "  bufAppend('\\'');",-      "}",-      "void PrintAbsyn::visitString(String s_)",-      "{",-      "  const char *s = s_.c_str() ;",-      "  bufAppend('\\\"');",-      "  bufAppend(s);",-      "  bufAppend('\\\"');",-      "}",-      "void PrintAbsyn::visitIdent(String s_)",-      "{",-      "  const char *s = s_.c_str() ;",-      "  render(s);",-      "}",-      ""-     ]--    printTokens = unlines-     [unlines [-      "void PrintAbsyn::visit" ++ t ++ "(String s_)",-      "{",-      "  const char *s = s_.c_str() ;",-      "  render(s);",-      "}",-      ""-      ] | t <- tokenNames cf-     ]--    showBasics = unlines-     [-      "void ShowAbsyn::visitInteger(Integer i)",-      "{",-      "  char tmp[16];",-      "  sprintf(tmp, \"%d\", i);",-      "  bufAppend(tmp);",-      "}",-      "void ShowAbsyn::visitDouble(Double d)",-      "{",-      "  char tmp[16];",-      "  sprintf(tmp, \"%g\", d);",-      "  bufAppend(tmp);",-      "}",-      "void ShowAbsyn::visitChar(Char c)",-      "{",-      "  bufAppend('\\'');",-      "  bufAppend(c);",-      "  bufAppend('\\'');",-      "}",-      "void ShowAbsyn::visitString(String s_)",-      "{",-      "  const char *s = s_.c_str() ;",-      "  bufAppend('\\\"');",-      "  bufAppend(s);",-      "  bufAppend('\\\"');",-      "}",-      "void ShowAbsyn::visitIdent(String s_)",-      "{",-      "  const char *s = s_.c_str() ;",-      "  bufAppend('\\\"');",-      "  bufAppend(s);",-      "  bufAppend('\\\"');",-      "}",-      ""-     ]--    showTokens = unlines-     [unlines [-      "void ShowAbsyn::visit" ++ t ++ "(String s_)",-      "{",-      "  const char *s = s_.c_str() ;",-      "  bufAppend('\\\"');",-      "  bufAppend(s);",-      "  bufAppend('\\\"');",-      "}",-      ""-      ] | t <- tokenNames cf-     ]---{- **** Pretty Printer Methods **** -}----Generates methods for the Pretty Printer-prPrintData :: Maybe String -> CF -> [UserDef] -> (Cat, [Rule]) -> String-prPrintData inPackage cf user (cat, rules) =- if isList cat- then unlines- [-  "void PrintAbsyn::visit" ++ cl ++ "("++ cl ++ " *" ++ vname ++ ")",-  "{",-  "  for ("++ cl ++"::const_iterator i = " ++-       vname++"->begin() ; i != " ++vname ++"->end() ; ++i)",-  "  {",-  if isBase user vname-    then "    visit" ++ baseName cl ++ "(*i) ;"-    else "    (*i)->accept(this);",-  optsep,-  "  }",-  "}",-  ""- ] --Not a list:- -- a position token- else if isPositionCat cf cat then unlines [-   "void PrintAbsyn::visit" ++ show cat ++ "(" ++ show cat ++ "* p)",-   "{",-   "  visitIdent(p->string_);",-   "}"-   ]- else abstract ++ (concatMap (prPrintRule inPackage user) rules)- where-   cl = identCat (normCat cat)-   vname = map toLower cl-   sep = snd (renderCharOrString sep')-   sep' = getCons rules-   optsep =-     (if hasOneFunc rules-       then "    if (i != " ++ vname ++ "->end() - 1) "-       else "    "-     )   ++ "render(" ++ sep ++ ");"-   abstract = case lookupRule (show cat) rules of-    Just _ -> ""-    Nothing ->  "void PrintAbsyn::visit" ++ cl ++ "(" ++ cl ++ "*p) {} //abstract class\n\n"----Pretty Printer methods for a rule.-prPrintRule :: Maybe String -> [UserDef] -> Rule -> String-prPrintRule inPackage user r@(Rule fun _ cats) | isProperLabel fun = unlines-  [-   "void PrintAbsyn::visit" ++ fun ++ "(" ++ fun ++ "*" +++ fnm ++ ")",-   "{",-   "  int oldi = _i_;",-   lparen,-   cats',-   rparen,-   "  _i_ = oldi;",-   "}\n"-  ]-   where-    p = precRule r-    (lparen, rparen) =-      ("  if (oldi > " ++ (show p) ++ ") render(" ++ nsDefine inPackage "_L_PAREN" ++ ");\n",-       "  if (oldi > " ++ (show p) ++ ") render(" ++ nsDefine inPackage "_R_PAREN" ++ ");\n")-    cats' = (concatMap (prPrintCat user fnm) (zip (fixOnes (numVars [] cats)) (map getPrec cats)))-    fnm = "p" --old names could cause conflicts-    getPrec (Right _) = 0-    getPrec (Left c) = precCat c-prPrintRule _ _ _ = ""----This goes on to recurse to the instance variables.-prPrintCat :: [UserDef] -> String -> (Either String String, Integer) -> String-prPrintCat user fnm (c,p) = case c of-  (Right t) -> "  render(" ++ t' ++ ");\n"-    where-     t' = snd (renderCharOrString t)-  (Left nt) -> if isBasic user nt-       then "  visit" ++ (funName nt) ++ "(" ++ fnm ++ "->" ++ nt ++ ");\n"-       else if "list" `isPrefixOf` nt-         then "  if(" ++ fnm ++ "->" ++ nt ++ ") {" ++ accept ++ "}"-	 else "  " ++ accept ++ "\n"-     where-       accept = if nt == "#_" --Internal category-         then "/* Internal Category */\n"-         else (setI p) ++ fnm ++ "->" ++ nt ++ "->accept(this);"--{- **** Abstract Syntax Tree Printer **** -}----This prints the functions for Abstract Syntax tree printing.-prShowData :: [UserDef] -> (Cat, [Rule]) -> String-prShowData user (cat, rules) =- if isList cat- then unlines- [-  "void ShowAbsyn::visit" ++ cl ++ "("++ cl ++ " *" ++ vname ++ ")",-  "{",-  "  for ("++ cl ++"::const_iterator i = " ++-       vname++"->begin() ; i != " ++vname ++"->end() ; ++i)",-  "  {",-  if isBase user vname-    then "    visit" ++ baseName cl ++ "(*i) ;"-    else "    (*i)->accept(this);",-  "    if (i != " ++ vname ++ "->end() - 1) bufAppend(\", \");",-  "  }",-  "}",-  ""- ] --Not a list:- else abstract ++ (concatMap (prShowRule user) rules)- where-   cl = identCat (normCat cat)-   vname = map toLower cl-   abstract = case lookupRule (show cat) rules of-    Just _ -> ""-    Nothing ->  "void ShowAbsyn::visit" ++ cl ++ "(" ++ cl ++ "* p) {} //abstract class\n\n"----This prints all the methods for Abstract Syntax tree rules.-prShowRule :: [UserDef] -> Rule -> String-prShowRule user (Rule fun _ cats) | isProperLabel fun = concat-  [-   "void ShowAbsyn::visit" ++ fun ++ "(" ++ fun ++ "*" +++ fnm ++ ")\n",-   "{\n",-   lparen,-   "  bufAppend(\"" ++ fun ++ "\");\n",-   optspace,-   cats',-   rparen,-   "}\n"-  ]-   where-    (optspace, lparen, rparen) = if allTerms cats-      then ("","","")-      else ("  bufAppend(' ');\n", "  bufAppend('(');\n","  bufAppend(')');\n")-    cats' = if allTerms cats-        then ""-    	else concat (insertSpaces (map (prShowCat user fnm) (fixOnes (numVars [] cats))))-    insertSpaces [] = []-    insertSpaces (x:[]) = [x]-    insertSpaces (x:xs) = if x == ""-      then insertSpaces xs-      else (x : ["  bufAppend(' ');\n"]) ++ (insertSpaces xs)-    allTerms [] = True-    allTerms (Left _:_) = False-    allTerms (_:zs) = allTerms zs-    fnm = "p" --other names could cause conflicts-prShowRule _ _ = ""----This recurses to the instance variables of a class.-prShowCat :: [UserDef] -> String -> Either String String -> String-prShowCat user fnm c =-  case c of-    (Right _) -> ""-    (Left nt) ->-      if isBasic user nt-       then "  visit" ++ (funName nt) ++ "(" ++ fnm ++ "->" ++ nt ++ ");\n"-       else if nt == "#_" --internal category-       then "/* Internal Category */\n"-       else if ((show $normCat$strToCat nt) /= nt)-          then accept- 	  else concat-	  [-	   "  bufAppend('[');\n",-	   "  if (" ++ fnm ++ "->" ++ nt ++ ")" ++ accept,-	   "  bufAppend(']');\n"-	  ]-       where-         accept = "  " ++ fnm ++ "->" ++ nt ++ "->accept(this);\n"--{- **** Helper Functions Section **** -}-----Just checks if something is a basic or user-defined type.---This is because you don't -> a basic non-pointer type.-isBasic :: [UserDef] -> String -> Bool-isBasic user v =-  if elem (init v) user'-    then True-    else if "integer_" `isPrefixOf` v then True-    else if "char_" `isPrefixOf` v then True-    else if "string_" `isPrefixOf` v then True-    else if "double_" `isPrefixOf` v then True-    else if "ident_" `isPrefixOf` v then True-    else False-  where-   user' = map (map toLower.show) user---- from listident to ident_-isBase user vn = isBasic user (baseName vn ++ "_")--- from ListIdent to Ident-baseName cl = drop 4 cl-----The visit-function name of a basic type-funName :: String -> String-funName v =-    if "integer_" `isPrefixOf` v then "Integer"-    else if "char_" `isPrefixOf` v then "Char"-    else if "string_" `isPrefixOf` v then "String"-    else if "double_" `isPrefixOf` v then "Double"-    else if "ident_" `isPrefixOf` v then "Ident"-    else "Ident" --User-defined type----Just sets the coercion level for parentheses in the Pretty Printer.-setI :: Integer -> String-setI n = "_i_ = " ++ (show n) ++ "; "----An extremely simple renderer for terminals.-prRender :: String-prRender = unlines-  [-      "//You may wish to change render",-      "void PrintAbsyn::render(Char c)",-      "{",-      "  if (c == '{')",-      "  {",-      "     bufAppend('\\n');",-      "     indent();",-      "     bufAppend(c);",-      "     _n_ = _n_ + 2;",-      "     bufAppend('\\n');",-      "     indent();",-      "  }",-      "  else if (c == '(' || c == '[')",-      "     bufAppend(c);",-      "  else if (c == ')' || c == ']')",-      "  {",-      "     backup();",-      "     bufAppend(c);",-      "     bufAppend(' ');",-      "  }",-      "  else if (c == '}')",-      "  {",-      "     _n_ = _n_ - 2;",-      "     backup();",-      "     backup();",-      "     bufAppend(c);",-      "     bufAppend('\\n\');",-      "     indent();",-      "  }",-      "  else if (c == ',')",-      "  {",-      "     backup();",-      "     bufAppend(c);",-      "     bufAppend(' ');",-      "  }",-      "  else if (c == ';')",-      "  {",-      "     backup();",-      "     bufAppend(c);",-      "     bufAppend('\\n');",-      "     indent();",-      "  }",-      "  else if (c == 0) return;",-      "  else",-      "  {",-      "     bufAppend(c);",-      "     bufAppend(' ');",-      "  }",-      "}",-      "void PrintAbsyn::render(String s_)",-      "{",-      "  const char *s = s_.c_str() ;",-      "  if(strlen(s) > 0)",-      "  {",-      "    bufAppend(s);",-      "    bufAppend(' ');",-      "  }",-      "}",-      "void PrintAbsyn::indent()",-      "{",-      "  int n = _n_;",-      "  while (n > 0)",-      "  {",-      "    bufAppend(' ');",-      "    n--;",-      "  }",-      "}",-      "void PrintAbsyn::backup()",-      "{",-      "  if (buf_[cur_ - 1] == ' ')",-      "  {",-      "    buf_[cur_ - 1] = 0;",-      "    cur_--;",-      "  }",-      "}"-  ]
src/BNFC/Backend/CSharp/CFtoCSharpPrinter.hs view
@@ -87,6 +87,7 @@   "    #region Misc rendering functions",   "    // You may wish to change these:",   "    private const int BUFFER_INITIAL_CAPACITY = 2000;",+  "    private const int INDENT_WIDTH = 2;",   "    private const string LEFT_PARENTHESIS = \"(\";",   "    private const string RIGHT_PARENTHESIS = \")\";",   "    private static System.Globalization.NumberFormatInfo InvariantFormatInfo = System.Globalization.NumberFormatInfo.InvariantInfo;",@@ -102,7 +103,7 @@   "        buffer.Append(\"\\n\");",   "        Indent();",   "        buffer.Append(s);",-  "        _n_ = _n_ + 2;",+  "        _n_ = _n_ + INDENT_WIDTH;",   "        buffer.Append(\"\\n\");",   "        Indent();",   "      }",@@ -116,9 +117,11 @@   "      }",   "      else if(s == \"}\")",   "      {",-  "        _n_ = _n_ - 2;",-  "        Backup();",-  "        Backup();",+  "        int t;",+  "        _n_ = _n_ - INDENT_WIDTH;",+  "        for(t=0; t<INDENT_WIDTH; t++) {",+  "          Backup();",+  "        }",   "        buffer.Append(s);",   "        buffer.Append(\"\\n\");",   "        Indent();",
src/BNFC/Backend/CSharp/CFtoGPPG.hs view
@@ -101,7 +101,7 @@      rule f xs e =       case checkDefinition' list ctx f xs e of-        Bad err	-> error $ "Panic! This should have been caught already:\n" ++ err+        Bad err -> error $ "Panic! This should have been caught already:\n" ++ err         Ok (_,(_,_)) -> unlinesInline [           "Defined Rule goes here"           ]@@ -204,7 +204,7 @@ -- Generates a string containing the semantic action. -- This was copied from CFtoCup15, with only a few small modifications generateAction :: Namespace -> NonTerminal -> Fun -> Bool -> [(MetaVar, Bool)]-	       -> Action+               -> Action generateAction namespace nt f rev mbs   | isNilFun f             = "$$ = new " ++ identifier namespace c ++ "();"   | isOneFun f             = "$$ = new " ++ identifier namespace c ++ "(); $$.Add(" ++ p_1 ++ ");"
src/BNFC/Backend/CSharp/RegToGPLEX.hs view
@@ -66,6 +66,7 @@ -- Handle special characters in regular expressions. mkEsc :: String -> String mkEsc = concatMap escChar-    where escChar c-	      | c `elem` "$+-*=<>[](){}!?.,;:^~|&%#/\\$_@\"" = '\\':[c]-	      | otherwise = [c]+  where+    escChar c+      | c `elem` ("$+-*=<>[](){}!?.,;:^~|&%#/\\$_@\"" :: String) = '\\':[c]+      | otherwise = [c]
+ src/BNFC/Backend/Common.hs view
@@ -0,0 +1,33 @@+module BNFC.Backend.Common (renderListSepByPrecedence) where+-- Functions common to different backends++import BNFC.PrettyPrint++-- | Helper function for c-like languages that generates the code printing+-- the list separator according to the given precedence level:+--+-- >>> let my_render c = "my_render(\"" <> text c <> "\")"+-- >>> renderListSepByPrecedence "x" my_render []+-- <BLANKLINE>+--+-- >>> renderListSepByPrecedence "x" my_render [(0,",")]+-- my_render(",");+--+-- >>> renderListSepByPrecedence "x" my_render [(3,";"), (1, "--")]+-- switch(x)+-- {+--   case 3: my_render(";"); break;+--   default: my_render("--");+-- }+renderListSepByPrecedence :: Doc                 -- ^ Name of the coercion level variable+                         -> (String -> Doc)     -- ^ render function+                         -> [(Integer, String)] -- ^ separators by precedence+                         -> Doc+renderListSepByPrecedence _ _ [] = empty+renderListSepByPrecedence _ render [(_,sep)] = render sep <> ";"+renderListSepByPrecedence var render ss = "switch(" <> var <> ")" $$ codeblock 2+    ( ["case" <+> integer i <:> render sep <>"; break;" | (i, sep) <- init ss]+    ++ ["default" <:> render sep <>";" | let (_,sep) = last ss])+  where+    a <:> b = a <> ":" <+> b+
src/BNFC/Backend/Common/Makefile.hs view
@@ -17,6 +17,10 @@   ++ map (printf "\t%s") recipe   ++ [""] +mkVar :: String -> String -> Makefile+mkVar n v = (++) (n ++ "=" ++ v  ++ "\n")++ -- | Create the Makefile file using the name specified in the option -- record. mkMakefile :: SharedOptions -> String -> Backend
src/BNFC/Backend/Common/NamedVariables.hs view
@@ -70,6 +70,9 @@ import BNFC.CF import Data.Char (toLower) import Data.List (nub)+import Text.PrettyPrint+import Control.Arrow (left, (&&&))+import Data.Either (lefts)  type IVar = (String, Int) --The type of an instance variable@@ -101,16 +104,32 @@ 	else i : (addVar' is (x+1) c)       else i : (addVar' is n c) ---Given a rule's definition, it goes through and nicely the variables by type.-numVars :: [(String, Int)] -> [Either Cat b] -> [Either String b]-numVars _env [] = []-numVars env ((Right f) : fs) = (Right f) : (numVars env fs)-numVars env ((Left f) : fs) =-   case lookup f' env of-     Nothing -> (Left f') : (numVars ((f',1):env) fs)-     Just n -> (Left $ f' ++ (show $ n + 1)) : (numVars ((f',n+1):env) fs)- where-   f' = varName (identCat (normCat f))+-- # Create variable names for rules rhs+-- This is about creating variable names for the right-hand side of rules.+-- In particular, if you have a rule like Foo. Bar ::= A B A, you need to+-- create unique variable names for the two instances of category A++-- | Anotate the right hand side of a rule with variable names+-- for the non-terminals.+-- >>> numVars [Left (Cat "A"), Right "+", Left (Cat "B")]+-- [Left (A,a_),Right "+",Left (B,b_)]+-- >>> numVars [Left (Cat "A"), Left (Cat "A"), Right ";"]+-- [Left (A,a_1),Left (A,a_2),Right ";"]+numVars :: [Either Cat a] -> [Either (Cat, Doc) a]+numVars cats =+  -- First, we anotate each Left _ with a variable name (not univque)+  let withNames = map (left (id &&& (varName . identCat . normCat))) cats+  -- next, the function f' adds numbers where needed...+  in f' [] withNames+  where f' _ [] = []+        f' env (Right t:xs) = Right t:f' env xs+        f' env (Left (c,n):xs) =+            -- we should use n_i as var name+            let i = maybe 1 (+1) (lookup n env)+            -- Is there more use of the name u_ ?+                thereIsMore = n `elem` map snd (lefts xs)+                vname = text n <> if i > 1 || thereIsMore then int i else empty+            in Left (c, vname) : f' ((n,i):env) xs  --This makes numbers a little nicer. --If there's only one variable of a type we drop the redundant _1 label.
src/BNFC/Backend/Common/OOAbstract.hs view
@@ -83,7 +83,7 @@   }  where   (pos,base) = partition (isPositionCat cf) $ fst (unzip (tokenPragmas cf))-  (lists,cats) = partition isList $ allCats cf+  (lists,cats) = partition isList $ allCatsNorm cf   toks = map (show.normCat) base   testRule (Rule f c _)    | isList c  = Nothing
src/BNFC/Backend/Haskell.hs view
@@ -39,11 +39,13 @@ import BNFC.Backend.Haskell.ToCNF as ToCNF import BNFC.Backend.Haskell.MkErrM import BNFC.Backend.Haskell.MkSharedString+import BNFC.Backend.Haskell.Utils (parserName) import qualified BNFC.Backend.Common.Makefile as Makefile  import System.FilePath (pathSeparator) import Control.Monad(when,unless) import Text.Printf (printf)+import Text.PrettyPrint  -- naming conventions @@ -60,7 +62,7 @@       errMod = errFileM opts       shareMod = shareFileM opts   do-    mkfile (absFile opts) $ cf2Abstract (byteStrings opts) (ghcExtensions opts) absMod cf+    mkfile (absFile opts) $ cf2Abstract (byteStrings opts) (ghcExtensions opts) (functor opts) absMod cf     case alexMode opts of       Alex1 -> do         mkfile (alexFile opts) $ cf2alex lexMod errMod cf@@ -73,12 +75,12 @@         liftIO $ printf "Use Alex 3.0 to compile %s.\n" (alexFile opts)     unless (cnf opts) $ do               mkfile (happyFile opts) $-        cf2HappyS parMod absMod lexMod errMod (glr opts) (byteStrings opts) cf+        cf2HappyS parMod absMod lexMod errMod (glr opts) (byteStrings opts) (functor opts) cf       liftIO $ printf "%s Tested with Happy 1.15\n" (happyFile opts)     mkfile (tFile opts)        $ testfile opts cf     mkfile (txtFile opts)      $ cfToTxt (lang opts) cf-    mkfile (templateFile opts) $ cf2Template (templateFileM opts) absMod errMod cf-    mkfile (printerFile opts)  $ cf2Printer (byteStrings opts) prMod absMod cf+    mkfile (templateFile opts) $ cf2Template (templateFileM opts) absMod errMod (functor opts) cf+    mkfile (printerFile opts)  $ cf2Printer (byteStrings opts) (functor opts) False prMod absMod cf     when (hasLayout cf) $ mkfile (layoutFile opts) $ cf2Layout (alex1 opts) (inDir opts) layMod lexMod cf     mkfile (errFile opts)      $ errM errMod cf     when (shareStrings opts) $ mkfile (shareFile opts)    $ sharedString shareMod (byteStrings opts) cf@@ -92,11 +94,6 @@       mkfile "TestCNF.hs" $ ToCNF.genTestFile opts cf       mkfile "BenchCNF.hs" $ ToCNF.genBenchmark opts -codeDir :: Options -> FilePath-codeDir opts = let pref = maybe "" pkgToDir (inPackage opts)-		   dir = if inDir opts then lang opts else ""-		   sep = if null pref || null dir then "" else [pathSeparator]-		 in pref ++ sep ++ dir  makefile :: Options -> String makefile opts = makeA where@@ -110,8 +107,7 @@               else "ghc --make " ++ tFile opts ++ " -o " ++ mkFile withLang "Test" "" opts])         $ Makefile.mkRule "clean" []             [ "-rm -f "  ++ unwords-                (map (dir++) [ "*.log", "*.aux", "*.hi", "*.o", "*.dvi" ])-            , "-rm -f " ++ psFile opts ]+                (map (dir++) [ "*.log", "*.aux", "*.hi", "*.o", "*.dvi" ]) ]         $  Makefile.mkRule "distclean" ["clean"]             [ "-rm -f " ++ unwords                 [ mkFile withLang "Doc" "*" opts@@ -135,36 +131,35 @@ testfile :: Options -> CF -> String testfile opts cf         = let lay = hasLayout cf-	      use_xml = xml opts > 0+              use_xml = xml opts > 0               xpr = if use_xml then "XPrint a, "     else ""-	      use_glr = glr opts == GLR+              use_glr = glr opts == GLR               if_glr s = if use_glr then s else ""-	      firstParser = if use_glr then "the_parser" else parserName-	      parserName = 'p' : topType-	      topType = show (firstEntry cf)+              firstParser = if use_glr then "the_parser" else render (parserName topType)+              topType = firstEntry cf           in unlines-	        ["-- automatically generated by BNF Converter",-		 "module Main where\n",-	         "",-	         "import System.IO ( stdin, hGetContents )",-	         "import System.Environment ( getArgs, getProgName )",-	         "import System.Exit ( exitFailure, exitSuccess )",-		 "",-		 "import " ++ alexFileM     opts,-		 "import " ++ happyFileM    opts,-		 "import " ++ templateFileM opts,-	         "import " ++ printerFileM  opts,-	         "import " ++ absFileM      opts,-	         if lay then "import " ++ layoutFileM opts else "",-	         if use_xml then "import " ++ xmlFileM opts else "",-	         if_glr "import qualified Data.Map(Map, lookup, toList)",-	         if_glr "import Data.Maybe(fromJust)",-	         "import " ++ errFileM      opts,-		 "",-		 if use_glr-		   then "type ParseFun a = [[Token]] -> (GLRResult, GLR_Output (Err a))"-		   else "type ParseFun a = [Token] -> Err a",-	         "",+                ["-- automatically generated by BNF Converter",+                 "module Main where\n",+                 "",+                 "import System.IO ( stdin, hGetContents )",+                 "import System.Environment ( getArgs, getProgName )",+                 "import System.Exit ( exitFailure, exitSuccess )",+                 "",+                 "import " ++ alexFileM     opts,+                 "import " ++ happyFileM    opts,+                 "import " ++ templateFileM opts,+                 "import " ++ printerFileM  opts,+                 "import " ++ absFileM      opts,+                 if lay then "import " ++ layoutFileM opts else "",+                 if use_xml then "import " ++ xmlFileM opts else "",+                 if_glr "import qualified Data.Map(Map, lookup, toList)",+                 if_glr "import Data.Maybe(fromJust)",+                 "import " ++ errFileM      opts,+                 "",+                 if use_glr+                   then "type ParseFun a = [[Token]] -> (GLRResult, GLR_Output (Err a))"+                   else "type ParseFun a = [Token] -> Err a",+                 "",                  "myLLexer = " ++ if lay then "resolveLayout True . myLexer"                                          else "myLexer",                  "",@@ -173,32 +168,45 @@                  "putStrV :: Verbosity -> String -> IO ()",                  "putStrV v s = if v > 1 then putStrLn s else return ()",                  "",-		 "runFile :: (" ++ xpr ++ if_glr "TreeDecode a, " ++ "Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO ()",-		 "runFile v p f = putStrLn f >> readFile f >>= run v p",-		 "",-		 "run :: (" ++ xpr ++ if_glr "TreeDecode a, " ++ "Print a, Show a) => Verbosity -> ParseFun a -> String -> IO ()",-		 if use_glr then run_glr else run_std use_xml,-		 "",-		 "showTree :: (Show a, Print a) => Int -> a -> IO ()",-		 "showTree v tree",-		 " = do",-		 "      putStrV v $ \"\\n[Abstract Syntax]\\n\\n\" ++ show tree",-		 "      putStrV v $ \"\\n[Linearized tree]\\n\\n\" ++ printTree tree",-		 "",-		 "main :: IO ()",-		 "main = do args <- getArgs",-		 "          case args of",-		 "            [] -> hGetContents stdin >>= run 2 " ++ firstParser,-		 "            \"-s\":fs -> mapM_ (runFile 0 " ++ firstParser ++ ") fs",-		 "            fs -> mapM_ (runFile 2 " ++ firstParser ++ ") fs",-		 "",-		 if_glr $ "the_parser :: ParseFun " ++ topType,-		 if_glr $ "the_parser = lift_parser " ++ parserName,-		 if_glr $ "",-		 if_glr $ lift_parser-		 ]+                 "runFile :: (" ++ xpr ++ if_glr "TreeDecode a, " ++ "Print a, Show a) => Verbosity -> ParseFun a -> FilePath -> IO ()",+                 "runFile v p f = putStrLn f >> readFile f >>= run v p",+                 "",+                 "run :: (" ++ xpr ++ if_glr "TreeDecode a, " ++ "Print a, Show a) => Verbosity -> ParseFun a -> String -> IO ()",+                 if use_glr then runGlr else runStd use_xml,+                 "",+                 "showTree :: (Show a, Print a) => Int -> a -> IO ()",+                 "showTree v tree",+                 " = do",+                 "      putStrV v $ \"\\n[Abstract Syntax]\\n\\n\" ++ show tree",+                 "      putStrV v $ \"\\n[Linearized tree]\\n\\n\" ++ printTree tree",+                 "",+                 "usage :: IO ()",+                 "usage = do",+                 "  putStrLn $ unlines",+                 "    [ \"usage: Call with one of the following argument combinations:\"",+                 "    , \"  --help          Display this help message.\"",+                 "    , \"  (no arguments)  Parse stdin verbosely.\"",+                 "    , \"  (files)         Parse content of files verbosely.\"",+                 "    , \"  -s (files)      Silent mode. Parse content of files silently.\"",+                 "    ]",+                 "  exitFailure",+                 "",+                 "main :: IO ()",+                 "main = do", +                 "  args <- getArgs",+                 "  case args of",+                 "    [\"--help\"] -> usage",+                 "    [] -> hGetContents stdin >>= run 2 " ++ firstParser,+                 "    \"-s\":fs -> mapM_ (runFile 0 " ++ firstParser ++ ") fs",+                 "    fs -> mapM_ (runFile 2 " ++ firstParser ++ ") fs",+                 "",+                 if_glr $ "the_parser :: ParseFun " ++ show topType,+                 if_glr $ "the_parser = lift_parser " ++ render (parserName topType),+                 if_glr "",+                 if_glr liftParser+                 ] -run_std xml+runStd xml  = unlines    [ "run v p s = let ts = myLLexer s in case p ts of"    , "           Bad s    -> do putStrLn \"\\nParse              Failed...\\n\""@@ -214,7 +222,7 @@    , "                          exitSuccess"    ] -run_glr+runGlr  = unlines    [ "run v p s"    , " = let ts = map (:[]) $ myLLexer s"@@ -241,7 +249,7 @@    ]  -lift_parser+liftParser  = unlines    [ "type Forest = Data.Map.Map ForestId [Branch]      -- omitted in ParX export."    , "data GLR_Output a"
src/BNFC/Backend/Haskell/CFtoAbstract.hs view
@@ -20,12 +20,18 @@ module BNFC.Backend.Haskell.CFtoAbstract (cf2Abstract) where
 
 import BNFC.CF
-import BNFC.Utils((+++),(++++),prParenth)
-import Data.List(intersperse,intercalate)
+import BNFC.Utils((+++))
+import BNFC.Backend.Haskell.Utils (catToType, catvars)
+import Text.PrettyPrint
 
 -- to produce a Haskell module
-cf2Abstract :: Bool -> Bool -> String -> CF -> String
-cf2Abstract byteStrings ghcExtensions name cf = unlines $
+cf2Abstract :: Bool     -- ^ Use ByteString instead of String
+            -> Bool     -- ^ Use GHC specific extensions
+            -> Bool     -- ^ Make the tree a functor
+            -> String   -- ^ module name
+            -> CF       -- ^ Grammar
+            -> String
+cf2Abstract byteStrings ghcExtensions functor name cf = unlines $
   (if ghcExtensions then "{-# LANGUAGE DeriveDataTypeable #-}" else "") :
   (if ghcExtensions then "{-# LANGUAGE DeriveGeneric #-}" else "") :
   ("module "++name +++ "where\n") :
@@ -33,29 +39,121 @@   (if byteStrings then "import qualified Data.ByteString.Char8 as BS" else "") :
   (if ghcExtensions then "import Data.Data (Data,Typeable)" else "") :
   (if ghcExtensions then "import GHC.Generics (Generic)" else "") :
-  (map (prSpecialData byteStrings cf derivingClasses) (specialCats cf) ++ map (prData derivingClasses) (cf2data cf))
+  (map (render . \c -> prSpecialData byteStrings (isPositionCat cf c) derivingClasses c) (specialCats cf)
+  ++ map (render . prData functor derivingClasses) (cf2data cf))
   where
-    derivingClasses = prParenth . intercalate "," $ concat
-        [ ["Eq","Ord","Show","Read"]
-        , (if ghcExtensions then ["Data","Typeable","Generic"] else [])
-        ]
+    derivingClasses = ["Eq","Ord","Show","Read"]
+        ++ if ghcExtensions then ["Data","Typeable","Generic"] else []
 
-prData :: String -> Data -> String
-prData derivingClasses (cat,rules) =
-  "data" +++ show cat +++ "=\n   " ++
-  concat (intersperse "\n | " (map prRule rules)) ++++
-  "  deriving" +++ derivingClasses ++ "\n"
- where
-   prRule (fun,cats) = unwords (fun:map show cats)
+-- | >>> prData False ["Eq", "Ord", "Show", "Read"] (Cat "C", [("C1", [Cat "C"]), ("CIdent", [Cat "Ident"])])
+-- data C = C1 C | CIdent Ident
+--   deriving (Eq, Ord, Show, Read)
+-- <BLANKLINE>
+--
+-- Nota that the layout adapts if it doesn't fit in a line:
+-- >>> prData False ["Show"] (Cat "C", [("CAbracadabra",[]),("CEbrecedebre",[]),("CIbricidibri",[]),("CObrocodobro",[]),("CUbrucudubru",[])])
+-- data C
+--     = CAbracadabra
+--     | CEbrecedebre
+--     | CIbricidibri
+--     | CObrocodobro
+--     | CUbrucudubru
+--   deriving (Show)
+-- <BLANKLINE>
+--
+-- The if the first argument is True, generate a functor:
+-- >>> prData True ["Show"] (Cat "C", [("C1", [Cat "C"]), ("CIdent", [TokenCat "Ident"])])
+-- data C a = C1 a (C a) | CIdent a Ident
+--   deriving (Show)
+-- <BLANKLINE>
+-- instance Functor C where
+--     fmap f x = case x of
+--         C1 a c -> C1 (f a) (fmap f c)
+--         CIdent a ident -> CIdent (f a) ident
+--
+-- The case for lists
+-- >>> prData True ["Show"] (Cat "ExpList", [("Exps", [ListCat (Cat "Exp")])])
+-- data ExpList a = Exps a [Exp a]
+--   deriving (Show)
+-- <BLANKLINE>
+-- instance Functor ExpList where
+--     fmap f x = case x of
+--         Exps a exps -> Exps (f a) (map (fmap f) exps)
+prData :: Bool -> [String] -> Data -> Doc
+prData functor derivingClasses (cat,rules) =
+    hang ("data" <+> dataType) 4 (constructors rules)
+    $+$ nest 2 (deriving_ derivingClasses)
+    $+$ ""
+    $+$ if functor then genFunctorInstance (cat, rules) else empty
+  where
+    prRule (fun,cats) =
+        hsep $ concat [[text fun], ["a" | functor], map prArg cats]
+    dataType =
+        if functor then text (show cat) <+> "a"
+                   else text (show cat)
+    prArg c  = catToType (if functor then Just "a" else Nothing) c
+    constructors [] = empty
+    constructors (h:t) = sep ("=" <+> prRule h : map (("|" <+>) . prRule) t)
 
-prSpecialData :: Bool -> CF -> String -> Cat -> String
-prSpecialData byteStrings cf derivingClasses cat =
-  unwords [ "newtype", show cat, "=", show cat, contentSpec byteStrings cf cat
-          , "deriving", derivingClasses ]
+-- | Generate a functor instance declaration:
+-- >>> genFunctorInstance (Cat "C", [("C1", [Cat "C", Cat "C"]), ("CIdent", [TokenCat "Ident"])])
+-- instance Functor C where
+--     fmap f x = case x of
+--         C1 a c1 c2 -> C1 (f a) (fmap f c1) (fmap f c2)
+--         CIdent a ident -> CIdent (f a) ident
+-- >>> genFunctorInstance (Cat "SomeLists", [("Ints", [ListCat (TokenCat "Integer")]), ("Exps", [ListCat (Cat "Exp")])])
+-- instance Functor SomeLists where
+--     fmap f x = case x of
+--         Ints a integers -> Ints (f a) integers
+--         Exps a exps -> Exps (f a) (map (fmap f) exps)
+--
+genFunctorInstance :: Data -> Doc
+genFunctorInstance (cat, cons) =
+    "instance Functor" <+> text (show cat) <+> "where"
+    $+$ nest 4 ( "fmap f x = case x of" $+$ nest 4 (vcat (map mkCase cons)))
+  where
+    mkCase (f,args) =
+        let variables = catvars args
+        in text f <+> "a" <+> hsep variables
+          <+> "->" <+> text f <+> "(f a)" <+> hsep (map reccurse (zip args variables))
+    -- We reccursively call fmap on non-terminals only if they are not
+    -- token categories
+    reccurse (TokenCat _, var) = var
+    reccurse (ListCat (TokenCat _), var) = var
+    reccurse (ListCat _, var) = parens ("map (fmap f)" <+> var)
+    reccurse (_, var)          = parens ("fmap f" <+> var)
 
-contentSpec :: Bool -> CF -> Cat -> String
-contentSpec byteStrings cf cat = if isPositionCat cf cat then "((Int,Int),"++stringType++")" else stringType
+
+-- | Generate a newtype declaration for Ident types
+--
+-- >>> prSpecialData False False ["Show"] (Cat "Ident")
+-- newtype Ident = Ident String deriving (Show)
+--
+-- >>> prSpecialData False True ["Show"] (Cat "Ident")
+-- newtype Ident = Ident ((Int,Int),String) deriving (Show)
+--
+-- >>> prSpecialData True False ["Show"] (Cat "Ident")
+-- newtype Ident = Ident BS.ByteString deriving (Show)
+--
+-- >>> prSpecialData True True ["Show"] (Cat "Ident")
+-- newtype Ident = Ident ((Int,Int),BS.ByteString) deriving (Show)
+prSpecialData :: Bool     -- ^ If True, use ByteString instead of String
+              -> Bool     -- ^ If True, store the token position
+              -> [String] -- ^ Derived classes
+              -> Cat      -- ^ Category
+              -> Doc
+prSpecialData byteStrings position classes cat =
+    hang newtype_ 2 (deriving_ classes)
   where
-    stringType
-      | byteStrings = "BS.ByteString"
-      | otherwise   = "String"
+    ppcat = text (show cat)
+    newtype_ = "newtype" <+> ppcat <+> "=" <+> ppcat <+> contentSpec
+    contentSpec | position  = parens ( "(Int,Int)," <> stringType)
+                | otherwise = stringType
+    stringType | byteStrings = "BS.ByteString"
+               | otherwise   = "String"
+
+-- | Generate 'deriving' clause
+-- >>> deriving_ ["Show","Read"]
+-- deriving (Show, Read)
+deriving_ :: [String] -> Doc
+deriving_ cls = "deriving" <+> parens (hsep (punctuate "," (map text cls)))
src/BNFC/Backend/Haskell/CFtoAlex.hs view
@@ -25,7 +25,7 @@ import Data.List  cf2alex :: String -> String -> CF -> String-cf2alex name errMod cf = unlines $ concat $ intersperse [""] [+cf2alex name errMod cf = unlines $ intercalate [""] [   prelude name errMod,   cMacros,   rMacros cf,@@ -84,7 +84,7 @@  where   mkEsc = unwords . map ( f . (:[]))   f s = if all isSpec s then '^':s else s-  isSpec = flip elem "$+-*=<>[](){}!?.,;:^~|&%#/\\$_@\""+  isSpec = flip elem ("$+-*=<>[](){}!?.,;:^~|&%#/\\$_@\"" :: String)  restOfAlex :: CF -> [String] restOfAlex cf = [@@ -148,7 +148,7 @@   "eitherResIdent :: (String -> Tok) -> String -> Tok",   "eitherResIdent tv s = if isResWord s then (TS s) else (tv s) where",   "  isResWord s = isInTree s $",-  "    " ++ (show $ sorted2tree $ sort resws),+  "    " ++ show (sorted2tree $ sort resws),   "",   "data BTree = N | B String BTree BTree deriving (Show)",   "",@@ -175,18 +175,18 @@    ifC cat s = if isUsedCat cf cat then s else ""    lexComments ([],[])           = []    lexComments (xs,s1:ys) = "<>         ::= " ++ ('^':intersperse '^' s1) ++ " [.]* ^n\n" ++ lexComments (xs,ys)-   lexComments (([l1,l2],[r1,r2]):xs,[]) = concat $-					[-					"<>         ::= ",-					('^':l1:' ':'^':l2:" ([^u # ^"),-					(l2:"] | ^"),-					(r1:" [^u # ^"),-					(r2:"])* (^"),-					(r1:")+ ^"),-					(r2:"\n"),-					lexComments (xs,[])-					]-   lexComments ((_:xs),[]) = lexComments (xs,[])+   lexComments (([l1,l2],[r1,r2]):xs,[]) = concat+                                        [+                                        "<>         ::= ",+                                        '^':l1:' ':'^':l2:" ([^u # ^",+                                        l2:"] | ^",+                                        r1:" [^u # ^",+                                        r2:"])* (^",+                                        r1:")+ ^",+                                        r2:"\n",+                                        lexComments (xs,[])+                                        ]+   lexComments (_ : xs, []) = lexComments (xs,[]) ---   lexComments (xs,(_:ys)) = lexComments (xs,ys)    pTSpec ([],[]) = ""    pTSpec xp =@@ -195,13 +195,13 @@    aux ([],_) = " %r "    aux (_,_) = " %s | %r " -   userDefTokenTypes = unlines $+   userDefTokenTypes = unlines      ["<mk_" ++ show name ++ "> ::= " ++ printRegAlex exp ++       "%{ mk_" ++ show name ++ " p = PT p . eitherResIdent T_"  ++ show name ++ " %}"                                         | (name,exp) <- tokenPragmas cf]-   userDefTokenConstrs = unlines $+   userDefTokenConstrs = unlines      [" | T_" ++ name ++ " String" | name <- tokenNames cf]-   userDefTokenPrint = unlines $+   userDefTokenPrint = unlines      ["  PT _ (T_" ++ name ++ " s) -> s" | name <- tokenNames cf]     identAndRes = --This has to be there for Reserved Words. Michael@@ -215,4 +215,4 @@ sorted2tree :: [String] -> BTree sorted2tree [] = N sorted2tree xs = B x (sorted2tree t1) (sorted2tree t2) where-  (t1,(x:t2)) = splitAt (length xs `div` 2) xs+  (t1, x : t2) = splitAt (length xs `div` 2) xs
src/BNFC/Backend/Haskell/CFtoAlex2.hs view
@@ -41,7 +41,7 @@  cf2alex2 :: String -> String -> String -> Bool -> Bool -> CF -> String cf2alex2 name errMod shareMod shareStrings byteStrings cf =-  unlines $ concat $ intersperse [""] [+  unlines $ intercalate [""] [     prelude name errMod shareMod shareStrings byteStrings,     cMacros,     rMacros cf,@@ -138,7 +138,7 @@   "",   "prToken t = case t of",   "  PT _ (TS s _) -> s",-  "  PT _ (TL s)   -> s",+  "  PT _ (TL s)   -> show s",   "  PT _ (TI s)   -> s",   "  PT _ (TV s)   -> s",   "  PT _ (TD s)   -> s",@@ -155,7 +155,7 @@   "                              | s > a  = treeFind right",   "                              | s == a = t",   "",-  "resWords = " ++ (show $ sorted2tree $ zip (sort resws) [1..]),+  "resWords = " ++ show (sorted2tree $ zip (sort resws) [1..]),   "   where b s n = let bs = "++stringPack++" s",   "                  in B bs (TS bs n)",   "",@@ -220,31 +220,31 @@    ifC cat s = if isUsedCat cf cat then s else ""    lexComments ([],[])           = []    lexComments (xs,s1:ys) = '\"' : s1 ++ "\"" ++ " [.]* ; -- Toss single line comments\n" ++ lexComments (xs, ys)-   lexComments (([l1,l2],[r1,r2]):xs,[]) = concat $-					[-					('\"':l1:l2:"\" ([$u # \\"), -- FIXME quotes or escape?-					(r1:"] | \\"),-					(r1:"+ [$u # [\\"),-					(r1:" \\"),-					(r2:"]])* (\""),-					(r1:"\")+ \""),-					(r2:"\" ; \n"),-					lexComments (xs, [])-					]-   lexComments ((_:xs),[]) = lexComments (xs,[])+   lexComments (([l1,l2],[r1,r2]):xs,[]) = concat+                                        [+                                        '\"':l1:l2:"\" ([$u # \\", -- FIXME quotes or escape?+                                        r1:"] | \\",+                                        r1:"+ [$u # [\\",+                                        r1:" \\",+                                        r2:"]])* (\"",+                                        r1:"\")+ \"",+                                        r2:"\" ; \n",+                                        lexComments (xs, [])+                                        ]+   lexComments (_:xs,[]) = lexComments (xs,[]) ---   lexComments (xs,(_:ys)) = lexComments (xs,ys)     -- tokens consisting of special symbols    pTSpec [] = ""    pTSpec _ = "@rsyms { tok (\\p s -> PT p (eitherResIdent (TV . share) s)) }" -   userDefTokenTypes = unlines $+   userDefTokenTypes = unlines      [printRegAlex exp ++       " { tok (\\p s -> PT p (eitherResIdent (T_"  ++ show name ++ " . share) s)) }"       | (name,exp) <- tokenPragmas cf]-   userDefTokenConstrs = unlines $+   userDefTokenConstrs = unlines      [" | T_" ++ name ++ " !"++stringType | name <- tokenNames cf]-   userDefTokenPrint = unlines $+   userDefTokenPrint = unlines      ["  PT _ (T_" ++ name ++ " s) -> s" | name <- tokenNames cf]     ident =@@ -259,14 +259,14 @@ instance Show BTree where     showsPrec _ N = showString "N"     showsPrec n (B s k l r) = wrap (showString "b " . shows s  . showChar ' '. shows k  . showChar ' '-				    . showsPrec 1 l . showChar ' '-				    . showsPrec 1 r)-	where wrap f = if n > 0 then showChar '(' . f . showChar ')' else f+                                    . showsPrec 1 l . showChar ' '+                                    . showsPrec 1 r)+        where wrap f = if n > 0 then showChar '(' . f . showChar ')' else f  sorted2tree :: [(String,Int)] -> BTree sorted2tree [] = N sorted2tree xs = B x n (sorted2tree t1) (sorted2tree t2) where-  (t1,((x,n):t2)) = splitAt (length xs `div` 2) xs+  (t1,(x,n):t2) = splitAt (length xs `div` 2) xs   -------------------------------------------------------------------@@ -285,17 +285,17 @@ render :: [String] -> String render = rend 0     where rend :: Int -> [String] -> String-	  rend i ss = case ss of-		        "["      :ts -> cons "["  $ rend i ts-			"("      :ts -> cons "("  $ rend i ts-			t  : "," :ts -> cons t    $ space "," $ rend i ts-		        t  : ")" :ts -> cons t    $ cons ")"  $ rend i ts-			t  : "]" :ts -> cons t    $ cons "]"  $ rend i ts-			t        :ts -> space t   $ rend i ts-			_            -> ""+          rend i ss = case ss of+                        "["      :ts -> cons "["  $ rend i ts+                        "("      :ts -> cons "("  $ rend i ts+                        t  : "," :ts -> cons t    $ space "," $ rend i ts+                        t  : ")" :ts -> cons t    $ cons ")"  $ rend i ts+                        t  : "]" :ts -> cons t    $ cons "]"  $ rend i ts+                        t        :ts -> space t   $ rend i ts+                        _            -> "" -	  cons s t  = s ++ t-	  space t s = if null s then t else t ++ " " ++ s+          cons s t  = s ++ t+          space t s = if null s then t else t ++ " " ++ s  parenth :: [String] -> [String] parenth ss = ["("] ++ ss ++ [")"]@@ -304,14 +304,14 @@ class Print a where   prt :: Int -> a -> [String]   prtList :: [a] -> [String]-  prtList = concat . map (prt 0)+  prtList = concatMap (prt 0)  instance Print a => Print [a] where   prt _ = prtList  instance Print Char where   prt _ c = if isAlphaNum c then [[c]] else ['\\':[c]]-  prtList s = map (concat . prt 0) s+  prtList = map (concat . prt 0)  prPrec :: Int -> Int -> [String] -> [String] prPrec i j = if j<i then parenth else id@@ -321,18 +321,18 @@  instance Print Reg where   prt i e = case e of-   RSeq reg0 reg -> prPrec i 2 (concat [prt 2 reg0 , prt 3 reg])+   RSeq reg0 reg -> prPrec i 2 (prt 2 reg0 ++ prt 3 reg)    RAlt reg0 reg -> prPrec i 1 (concat [prt 1 reg0 , ["|"] , prt 2 reg])    RMinus reg0 reg -> prPrec i 1 (concat [prt 2 reg0 , ["#"] , prt 2 reg])-   RStar reg -> prPrec i 3 (concat [prt 3 reg , ["*"]])-   RPlus reg -> prPrec i 3 (concat [prt 3 reg , ["+"]])-   ROpt reg  -> prPrec i 3 (concat [prt 3 reg , ["?"]])-   REps  -> prPrec i 3 (["()"])-   RChar c -> prPrec i 3 (concat [prt 0 c])+   RStar reg -> prPrec i 3 (prt 3 reg ++ ["*"])+   RPlus reg -> prPrec i 3 (prt 3 reg ++ ["+"])+   ROpt reg  -> prPrec i 3 (prt 3 reg ++ ["?"])+   REps  -> prPrec i 3 ["()"]+   RChar c -> prPrec i 3 (prt 0 c)    RAlts str -> prPrec i 3 (concat [["["],prt 0 str,["]"]])-   RSeqs str -> prPrec i 2 (concat (map (prt 0) str))-   RDigit  -> prPrec i 3 (concat [["$d"]])-   RLetter  -> prPrec i 3 (concat [["$l"]])-   RUpper  -> prPrec i 3 (concat [["$c"]])-   RLower  -> prPrec i 3 (concat [["$s"]])-   RAny  -> prPrec i 3 (concat [["$u"]])+   RSeqs str -> prPrec i 2 (concatMap (prt 0) str)+   RDigit  -> prPrec i 3 ["$d"]+   RLetter  -> prPrec i 3 ["$l"]+   RUpper  -> prPrec i 3 ["$c"]+   RLower  -> prPrec i 3 ["$s"]+   RAny  -> prPrec i 3 ["$u"]
src/BNFC/Backend/Haskell/CFtoAlex3.hs view
@@ -30,7 +30,7 @@  cf2alex3 :: String -> String -> String -> Bool -> Bool -> CF -> String cf2alex3 name errMod shareMod shareStrings byteStrings cf =-  unlines $ concat $ intersperse [""] [+  unlines $ intercalate [""] [     prelude name errMod shareMod shareStrings byteStrings,     cMacros,     rMacros cf,@@ -143,7 +143,7 @@   "prToken :: Token -> String",   "prToken t = case t of",   "  PT _ (TS s _) -> s",-  "  PT _ (TL s)   -> s",+  "  PT _ (TL s)   -> show s",   "  PT _ (TI s)   -> s",   "  PT _ (TV s)   -> s",   "  PT _ (TD s)   -> s",@@ -161,7 +161,7 @@   "                              | s == a = t",   "",   "resWords :: BTree",-  "resWords = " ++ (show $ sorted2tree $ cfTokens $ cf),+  "resWords = " ++ show (sorted2tree $ cfTokens cf),   "   where b s n = let bs = "++stringPack++" s",   "                  in B bs (TS bs n)",   "",@@ -252,31 +252,31 @@    ifC cat s = if isUsedCat cf cat then s else ""    lexComments ([],[])           = []    lexComments (xs,s1:ys) = '\"' : s1 ++ "\"" ++ " [.]* ; -- Toss single line comments\n" ++ lexComments (xs, ys)-   lexComments (([l1,l2],[r1,r2]):xs,[]) = concat $-					[-					('\"':l1:l2:"\" ([$u # \\"), -- FIXME quotes or escape?-					(r1:"] | \\"),-					(r1:"+ [$u # [\\"),-					(r1:" \\"),-					(r2:"]])* (\""),-					(r1:"\")+ \""),-					(r2:"\" ;\n"),-					lexComments (xs, [])-					]-   lexComments ((_:xs),[]) = lexComments (xs,[])+   lexComments (([l1,l2],[r1,r2]):xs,[]) = concat+                                        [+                                        '\"':l1:l2:"\" ([$u # \\", -- FIXME quotes or escape?+                                        r1:"] | \\",+                                        r1:"+ [$u # [\\",+                                        r1:" \\",+                                        r2:"]])* (\"",+                                        r1:"\")+ \"",+                                        r2:"\" ;\n",+                                        lexComments (xs, [])+                                        ]+   lexComments (_ : xs, []) = lexComments (xs,[]) ---   lexComments (xs,(_:ys)) = lexComments (xs,ys)     -- tokens consisting of special symbols    pTSpec [] = ""    pTSpec _ = "@rsyms { tok (\\p s -> PT p (eitherResIdent (TV . share) s)) }" -   userDefTokenTypes = unlines $+   userDefTokenTypes = unlines      [printRegAlex exp ++       " { tok (\\p s -> PT p (eitherResIdent (T_"  ++ show name ++ " . share) s)) }"       | (name,exp) <- tokenPragmas cf]-   userDefTokenConstrs = unlines $+   userDefTokenConstrs = unlines      [" | T_" ++ name ++ " !"++stringType | name <- tokenNames cf]-   userDefTokenPrint = unlines $+   userDefTokenPrint = unlines      ["  PT _ (T_" ++ name ++ " s) -> s" | name <- tokenNames cf]     ident =@@ -289,14 +289,14 @@ instance Show BTree where     showsPrec _ N = showString "N"     showsPrec n (B s k l r) = wrap (showString "b " . shows s  . showChar ' '. shows k  . showChar ' '-				    . showsPrec 1 l . showChar ' '-				    . showsPrec 1 r)-	where wrap f = if n > 0 then showChar '(' . f . showChar ')' else f+                                    . showsPrec 1 l . showChar ' '+                                    . showsPrec 1 r)+        where wrap f = if n > 0 then showChar '(' . f . showChar ')' else f  sorted2tree :: [(String,Int)] -> BTree sorted2tree [] = N sorted2tree xs = B x n (sorted2tree t1) (sorted2tree t2) where-  (t1,((x,n):t2)) = splitAt (length xs `div` 2) xs+  (t1, (x,n) : t2) = splitAt (length xs `div` 2) xs   -------------------------------------------------------------------@@ -315,17 +315,17 @@ render :: [String] -> String render = rend 0     where rend :: Int -> [String] -> String-	  rend i ss = case ss of-		        "["      :ts -> cons "["  $ rend i ts-			"("      :ts -> cons "("  $ rend i ts-			t  : "," :ts -> cons t    $ space "," $ rend i ts-		        t  : ")" :ts -> cons t    $ cons ")"  $ rend i ts-			t  : "]" :ts -> cons t    $ cons "]"  $ rend i ts-			t        :ts -> space t   $ rend i ts-			_            -> ""+          rend i ss = case ss of+                        "["      :ts -> cons "["  $ rend i ts+                        "("      :ts -> cons "("  $ rend i ts+                        t  : "," :ts -> cons t    $ space "," $ rend i ts+                        t  : ")" :ts -> cons t    $ cons ")"  $ rend i ts+                        t  : "]" :ts -> cons t    $ cons "]"  $ rend i ts+                        t        :ts -> space t   $ rend i ts+                        _            -> "" -	  cons s t  = s ++ t-	  space t s = if null s then t else t ++ " " ++ s+          cons s t  = s ++ t+          space t s = if null s then t else t ++ " " ++ s  parenth :: [String] -> [String] parenth ss = ["("] ++ ss ++ [")"]@@ -334,7 +334,7 @@ class Print a where   prt :: Int -> a -> [String]   prtList :: [a] -> [String]-  prtList = concat . map (prt 0)+  prtList = concatMap (prt 0)  instance Print a => Print [a] where   prt _ = prtList@@ -345,8 +345,8 @@              '\t' -> ["\\t"]              c | isAlphaNum c -> [[c]]              c | isPrint c    -> ['\\':[c]]-             c | otherwise    -> ['\\':show (ord c)]-  prtList s = map (concat . prt 0) s+             c                -> ['\\':show (ord c)]+  prtList = map (concat . prt 0)  prPrec :: Int -> Int -> [String] -> [String] prPrec i j = if j<i then parenth else id@@ -356,18 +356,18 @@  instance Print Reg where   prt i e = case e of-   RSeq reg0 reg -> prPrec i 2 (concat [prt 2 reg0 , prt 3 reg])-   RAlt reg0 reg -> prPrec i 1 (concat [prt 1 reg0 , ["|"] , prt 2 reg])-   RMinus reg0 reg -> prPrec i 1 (concat [prt 2 reg0 , ["#"] , prt 2 reg])-   RStar reg -> prPrec i 3 (concat [prt 3 reg , ["*"]])-   RPlus reg -> prPrec i 3 (concat [prt 3 reg , ["+"]])-   ROpt reg  -> prPrec i 3 (concat [prt 3 reg , ["?"]])-   REps  -> prPrec i 3 (["()"])-   RChar c -> prPrec i 3 (concat [prt 0 c])-   RAlts str -> prPrec i 3 (concat [["["],prt 0 str,["]"]])-   RSeqs str -> prPrec i 2 (concat (map (prt 0) str))-   RDigit  -> prPrec i 3 (concat [["$d"]])-   RLetter  -> prPrec i 3 (concat [["$l"]])-   RUpper  -> prPrec i 3 (concat [["$c"]])-   RLower  -> prPrec i 3 (concat [["$s"]])-   RAny  -> prPrec i 3 (concat [["$u"]])+   RSeq reg0 reg    -> prPrec i 2 (prt 2 reg0 ++ prt 3 reg)+   RAlt reg0 reg    -> prPrec i 1 (concat [prt 1 reg0 , ["|"] , prt 2 reg])+   RMinus reg0 reg  -> prPrec i 1 (concat [prt 2 reg0 , ["#"] , prt 2 reg])+   RStar reg        -> prPrec i 3 (prt 3 reg ++ ["*"])+   RPlus reg        -> prPrec i 3 (prt 3 reg ++ ["+"])+   ROpt reg         -> prPrec i 3 (prt 3 reg ++ ["?"])+   REps             -> prPrec i 3 ["()"]+   RChar c          -> prPrec i 3 (prt 0 c)+   RAlts str        -> prPrec i 3 (concat [["["],prt 0 str,["]"]])+   RSeqs str        -> prPrec i 2 (concatMap (prt 0) str)+   RDigit           -> prPrec i 3 ["$d"]+   RLetter          -> prPrec i 3 ["$l"]+   RUpper           -> prPrec i 3 ["$c"]+   RLower           -> prPrec i 3 ["$s"]+   RAny             -> prPrec i 3 ["$u"]
src/BNFC/Backend/Haskell/CFtoHappy.hs view
@@ -17,15 +17,15 @@     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA -} -module BNFC.Backend.Haskell.CFtoHappy where+module BNFC.Backend.Haskell.CFtoHappy (cf2HappyS, convert) where -import Text.PrettyPrint import BNFC.CF import BNFC.Backend.Common.StrUtils (escapeChars)+import BNFC.Backend.Haskell.Utils (parserName, catToType) --import Lexer-import Data.List (intersperse) import Data.Char import BNFC.Options (HappyMode(..))+import BNFC.PrettyPrint -- Type declarations  type Rules       = [(NonTerminal,[(Pattern,Action)])]@@ -35,39 +35,46 @@  -- default naming -moduleName  = "HappyParser" tokenName   = "Token"  -- Happy mode   -cf2HappyS :: String -> String -> String -> String -> HappyMode -> Bool -> CF -> String+cf2HappyS :: String     -- ^ This module's name+          -> String     -- ^ Abstract syntax module name+          -> String     -- ^ Lexer module name+          -> String     -- ^ ErrM module name+          -> HappyMode  -- ^ Happy mode+          -> Bool       -- ^ Use bytestring?+          -> Bool       -- ^ AST is a functor?+          -> CF         -- ^ Grammar+          -> String     -- ^ Generated code ---- cf2HappyS :: String -> CF -> String cf2HappyS = cf2Happy  -- The main function, that given a CF and a CFCat to parse according to, -- generates a happy module.-cf2Happy name absName lexName errName mode byteStrings cf+cf2Happy name absName lexName errName mode byteStrings functor cf  = unlines     [header name absName lexName errName mode byteStrings,-     declarations mode (allEntryPoints cf),+     render $ declarations mode (allEntryPoints cf),      tokens (cfTokens cf),      specialToks cf,      delimiter,      specialRules byteStrings cf,-     prRules (rulesForHappy cf),+     render $ prRules functor (rulesForHappy absName functor cf),      finalize byteStrings cf]  -- construct the header. header :: String -> String -> String -> String -> HappyMode -> Bool -> String header modName absName lexName errName mode byteStrings = unlines          ["-- This Happy file was machine-generated by the BNF converter",-	  "{",-	  "{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-}",+          "{",+          "{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-}",           case mode of-	    Standard -> "module " ++ modName ++ " where"-	    GLR      -> "-- module name filled in by Happy",+            Standard -> "module " ++ modName ++ " where"+            GLR      -> "-- module name filled in by Happy",           "import " ++ absName,           "import " ++ lexName,           "import " ++ errName,@@ -75,45 +82,24 @@           "}"          ] -{- -----cf2Happy :: String -> CF -> String-cf2Happy name cf- = unlines-    [header name,-     declarations (allEntryPoints cf),-     tokens (cfTokens cf),-     specialToks cf,-     delimiter,-     specialRules cf,-     prRules (rulesForHappy cf),-     finalize cf]---- construct the header.-header :: String -> String-header name = unlines-         ["-- This Happy file was machine-generated by the BNF converter",-	  "{",-          "module Par" ++ name ++ " where",-          "import Abs"++name,-          "import Lex"++name,-          "import ErrM",-          "}"-         ]--}---- The declarations of a happy file.-declarations :: HappyMode -> [Cat] -> String-declarations mode ns = unlines-                 [generateP ns,-          	  case mode of-                    Standard -> "-- no lexer declaration"-                    GLR      -> "%lexer { myLexer } { Err _ }",-                  "%monad { Err } { thenM } { returnM }",-                  "%tokentype { " ++ tokenName ++ " }"]-   where generateP []     = []--	 generateP (n:ns) = concat ["%name p",n'," ",n',"\n",generateP ns]-                               where n' = identCat n+-- | The declarations of a happy file.+-- >>> declarations Standard [Cat "A", Cat "B", ListCat (Cat "B")]+-- %name pA A+-- %name pB B+-- %name pListB ListB+-- -- no lexer declaration+-- %monad { Err } { thenM } { returnM }+-- %tokentype {Token}+declarations :: HappyMode -> [Cat] -> Doc+declarations mode ns = vcat+    [ vcat $ map generateP ns+    , case mode of+        Standard -> "-- no lexer declaration"+        GLR      -> "%lexer { myLexer } { Err _ }",+      "%monad { Err } { thenM } { returnM }",+      "%tokentype" <+> braces (text tokenName) ]+  where generateP n = "%name" <+> parserName n <+> text n'+          where n' = identCat n  -- The useless delimiter symbol. delimiter :: String@@ -133,39 +119,60 @@ convert :: String -> Doc convert = quotes . text . escapeChars -rulesForHappy :: CF -> Rules-rulesForHappy cf = map mkOne $ ruleGroups cf where-  mkOne (cat,rules) = constructRule cf rules cat+rulesForHappy :: String -> Bool -> CF -> Rules+rulesForHappy absM functor cf = map mkOne $ ruleGroups cf+  where+    mkOne (cat,rules) = (cat, map (constructRule absM functor reversibles) rules)+    reversibles = reversibleCats cf --- For every non-terminal, we construct a set of rules. A rule is a sequence of--- terminals and non-terminals, and an action to be performed--- As an optimization, a pair of list rules [C] ::= "" | C k [C]--- is left-recursivized into [C] ::= "" | [C] C k.+-- | For every non-terminal, we construct a set of rules. A rule is a sequence+-- of terminals and non-terminals, and an action to be performed+-- >>> constructRule "Foo" False [] (Rule "EPlus" (Cat "Exp") [Left (Cat "Exp"), Right "+", Left (Cat "Exp")])+-- ("Exp '+' Exp","Foo.EPlus $1 $3")+--+-- If we're using functors, it adds an void value:+-- >>> constructRule "Foo" True [] (Rule "EPlus" (Cat "Exp") [Left (Cat "Exp"), Right "+", Left (Cat "Exp")])+-- ("Exp '+' Exp","Foo.EPlus () $1 $3")+--+-- List constructors should not be prefixed by the abstract module name:+-- >>> constructRule "Foo" False [] (Rule "(:)" (ListCat (Cat "A")) [Left (Cat "A"), Right",", Left (ListCat (Cat "A"))])+-- ("A ',' ListA","(:) $1 $3")+-- >>> constructRule "Foo" False [] (Rule "(:[])" (ListCat (Cat "A")) [Left (Cat "A")])+-- ("A","(:[]) $1")+--+-- Coercion are much simpler:+-- >>> constructRule "Foo" True [] (Rule "_" (Cat "Exp") [Right "(", Left (Cat "Exp"), Right ")"])+-- ("'(' Exp ')'","$2")+--+-- As an optimization, a pair of list rules [C] ::= "" | C k [C] is+-- left-recursivized into [C] ::= "" | [C] C k. -- This could be generalized to cover other forms of list rules.-constructRule :: CF -> [Rule] -> NonTerminal -> (NonTerminal,[(Pattern,Action)])-constructRule cf rules nt = (nt,[(p,generateAction nt (revF b r) m) |-     r0 <- rules,-     let (b,r) = if isConsFun (funRule r0) && elem (valCat r0) revs-                   then (True,revSepListRule r0)-                 else (False,r0),-     let (p,m) = generatePatterns cf r])- where-   revF b r = if b then ("flip " ++ funRule r) else (underscore $ funRule r)-   revs = reversibleCats cf-   underscore f | isDefinedRule f   = f ++ "_"-		| otherwise	    = f---- Generates a string containing the semantic action.--- An action can for example be: Sum $1 $2, that is, construct an AST--- with the constructor Sum applied to the two metavariables $1 and $2.-generateAction :: NonTerminal -> Fun -> [MetaVar] -> Action-generateAction _ f ms = unwords $ (if isCoercion f then [] else [f]) ++ ms+-- >>> constructRule "Foo" False [ListCat (Cat "A")] (Rule "(:)" (ListCat (Cat "A")) [Left (Cat "A"), Right",", Left (ListCat (Cat "A"))])+-- ("ListA A ','","flip (:) $1 $2")+--+-- Note that functors don't concern list constructors:+-- >>> constructRule "Abs" True [ListCat (Cat "A")] (Rule "(:)" (ListCat (Cat "A")) [Left (Cat "A"), Right",", Left (ListCat (Cat "A"))])+-- ("ListA A ','","flip (:) $1 $2")+constructRule :: String -> Bool -> [Cat] -> Rule -> (Pattern,Action)+constructRule absName functor revs r0@(Rule fun cat _) = (pattern, action)+  where+    (pattern,metavars) = generatePatterns revs r+    action | isCoercion fun                 = unwords metavars+           | isConsFun fun && elem cat revs = unwords ("flip" : fun : metavars)+           | isNilCons fun                  = unwords (underscore fun : metavars)+           | functor                        = unwords (underscore fun : "()" : metavars)+           | otherwise                      = unwords (underscore fun : metavars)+    r | isConsFun (funRule r0) && elem (valCat r0) revs = revSepListRule r0+      | otherwise                                       = r0+    underscore f | isConsFun f || isNilCons f = f+                 | isDefinedRule f = absName ++ "." ++ f ++ "_"+                 | otherwise       = absName ++ "." ++ f  -- Generate patterns and a set of metavariables indicating -- where in the pattern the non-terminal -generatePatterns :: CF -> Rule -> (Pattern,[MetaVar])-generatePatterns cf r = case rhsRule r of+generatePatterns :: [Cat] -> Rule -> (Pattern,[MetaVar])+generatePatterns revs r = case rhsRule r of   []  -> ("{- empty -}",[])   its -> (unwords (map mkIt its), metas its)  where@@ -173,26 +180,51 @@      Left c -> identCat c      Right s -> render (convert s)    metas its = [revIf c ('$': show i) | (i,Left c) <- zip [1 ::Int ..] its]-   revIf c m = if (not (isConsFun (funRule r)) && elem c revs)-                 then ("(reverse " ++ m ++ ")")-               else m  -- no reversal in the left-recursive Cons rule itself-   revs = reversibleCats cf+   revIf c m = if not (isConsFun (funRule r)) && elem c revs+                 then "(reverse " ++ m ++ ")"+                 else m  -- no reversal in the left-recursive Cons rule itself  -- We have now constructed the patterns and actions, -- so the only thing left is to merge them into one string. -prRules :: Rules -> String-prRules = unlines . map prOne+-- |+-- >>> prRules False [(Cat "Expr", [("Integer", "EInt $1"), ("Expr '+' Expr", "EPlus $1 $3")])]+-- Expr :: { Expr }+-- Expr : Integer { EInt $1 } | Expr '+' Expr { EPlus $1 $3 }+--+-- if there's a lot of cases, print on several lignes:+-- >>> prRules False [(Cat "Expr", [("Abcd", "Action"), ("P2", "A2"), ("P3", "A3"), ("P4", "A4"), ("P5","A5")])]+-- Expr :: { Expr }+-- Expr : Abcd { Action }+--      | P2 { A2 }+--      | P3 { A3 }+--      | P4 { A4 }+--      | P5 { A5 }+--+-- >>> prRules False [(Cat "Internal", [])] -- nt has only internal use+-- <BLANKLINE>+--+-- The functor case:+-- >>> prRules True [(Cat "Expr", [("Integer", "EInt () $1"), ("Expr '+' Expr", "EPlus () $1 $3")])]+-- Expr :: { (Expr ()) }+-- Expr : Integer { EInt () $1 } | Expr '+' Expr { EPlus () $1 $3 }+--+-- A list with coercion: in the type signature we need to get rid of the+-- coercion+-- >>> prRules True [(ListCat (CoercCat "Exp" 2), [("Exp2", "(:[]) $1"), ("Exp2 ',' ListExp2","(:) $1 $3")])]+-- ListExp2 :: { [Exp ()] }+-- ListExp2 : Exp2 { (:[]) $1 } | Exp2 ',' ListExp2 { (:) $1 $3 }+prRules :: Bool -> Rules -> Doc+prRules functor = vcat . map prOne   where-    prOne (_,[]) = [] -- nt has only internal use-    prOne (nt,((p,a):ls)) =-      unwords [nt', "::", "{", show $ normCat nt, "}\n" ++-               nt', ":" , p, "{", a, "}", "\n" ++ pr ls] ++ "\n"+    type' = catToType (if functor then Just "()" else Nothing)+    prOne (_,[]) = empty -- nt has only internal use+    prOne (nt,(p,a):ls) =+      hsep [ nt', "::", "{", type' nt, "}" ]+      $$ nt' <+> sep (pr ":" (p, a) : map (pr "|") ls)      where-       nt' = identCat nt-       pr [] = []-       pr ((p,a):ls) =-         unlines [(concat $ intersperse " " ["  |", p, "{", a , "}"])] ++ pr ls+       nt' = text (identCat nt)+       pr pre (p,a) = hsep [pre, text p, "{", text a , "}"]  -- Finally, some haskell code. @@ -222,22 +254,21 @@  definedRules cf = [ mkDef f xs e | FunDef f xs e <- pragmasOfCF cf ]     where-	mkDef f xs e = unwords $ (f ++ "_") : xs' ++ ["=", show e']-	    where-		xs' = map (++"_") xs-		e'  = underscore e-	underscore (App x es)-	    | isLower $ head x	= App (x ++ "_") $ map underscore es-	    | otherwise		= App x $ map underscore es-	underscore e	      = e+        mkDef f xs e = unwords $ (f ++ "_") : xs' ++ ["=", show e']+            where+                xs' = map (++"_") xs+                e'  = underscore e+        underscore (App x es)+            | isLower $ head x  = App (x ++ "_") $ map underscore es+            | otherwise         = App x $ map underscore es+        underscore e          = e  -- aarne's modifs 8/1/2002: -- Markus's modifs 11/02/2002  -- GF literals specialToks :: CF -> String-specialToks cf = unlines $-		 (map aux (literals cf))+specialToks cf = unlines (map aux (literals cf))  where aux cat =         case show cat of           "Ident"  -> "L_ident  { PT _ (TV $$) }"@@ -256,12 +287,12 @@    aux cat =      case show cat of          "Ident"   -> "Ident   :: { Ident }   : L_ident  { Ident $1 }"-	 "String"  -> "String  :: { String }  : L_quoted { "++stringUnpack++" $1 }"-	 "Integer" -> "Integer :: { Integer } : L_integ  { (read ("++stringUnpack++" $1)) :: Integer }"-	 "Double"  -> "Double  :: { Double }  : L_doubl  { (read ("++stringUnpack++" $1)) :: Double }"-	 "Char"    -> "Char    :: { Char }    : L_charac { (read ("++stringUnpack++" $1)) :: Char }"-	 own       -> own ++ "    :: { " ++ own ++ "} : L_" ++ own ++ " { " ++ own ++ " ("++ posn ++ "$1)}"-		-- PCC: take "own" as type name? (manual says newtype)+         "String"  -> "String  :: { String }  : L_quoted { "++stringUnpack++" $1 }"+         "Integer" -> "Integer :: { Integer } : L_integ  { (read ("++stringUnpack++" $1)) :: Integer }"+         "Double"  -> "Double  :: { Double }  : L_doubl  { (read ("++stringUnpack++" $1)) :: Double }"+         "Char"    -> "Char    :: { Char }    : L_charac { (read ("++stringUnpack++" $1)) :: Char }"+         own       -> own ++ "    :: { " ++ own ++ "} : L_" ++ own ++ " { " ++ own ++ " ("++ posn ++ "$1)}"+                -- PCC: take "own" as type name? (manual says newtype)       where          posn = if isPositionCat cf cat then "mkPosToken " else "" 
src/BNFC/Backend/Haskell/CFtoLayout.hs view
@@ -81,30 +81,6 @@   "    -- to keep opening and closing braces.",   "    | isLayoutOpen t0 = moveAlong (Explicit:st) [t0] ts",   "",-  "  res _ st (t0:ts)",-  "    -- Start a new layout block if the first token is a layout word",-  "    | isLayout t0 =",-  "        case ts of",-  "            -- Explicit layout, just move on. The case above",-  "            -- will push an explicit layout block.",-  "            t1:_ | isLayoutOpen t1 -> moveAlong st [t0] ts",-  "                     -- at end of file, the start column doesn't matter",-  "            _ -> let col = if null ts then column t0 else column (head ts)",-  "                     -- insert an open brace after the layout word",-  "                     b:ts' = addToken (nextPos t0) layoutOpen ts",-  "                     -- save the start column",-  "                     st' = Implicit col:st",-  "                  in moveAlong st' [t0,b] ts'",-  "",-  "    -- If we encounter a closing brace, exit the first explicit layout block.",-  "    | isLayoutClose t0 =",-  "          let st' = drop 1 (dropWhile isImplicit st)",-  "           in if null st'",-  "                 then error $ \"Layout error: Found \" ++ layoutClose ++ \" at (\"",-  "                              ++ show (line t0) ++ \",\" ++ show (column t0)",-  "                              ++ \") without an explicit layout block.\"",-  "                 else moveAlong st' [t0] ts",-  "",   "  -- We are in an implicit layout block",   "  res pt st@(Implicit n:ns) (t0:ts)",   "",@@ -123,14 +99,49 @@   "        in moveAlong ns' ts1 ts2",   "",   "    -- End of an implicit layout block",-  "    | newLine && column t0 < n  =",+  "    | newLine pt t0 && column t0 < n  = ",   "           -- Insert a closing brace after the previous token.",   "       let b:t0':ts' = addToken (afterPrev pt) layoutClose (t0:ts)",   "           -- Repeat, with the current block removed from the stack",   "        in moveAlong ns [b] (t0':ts')",   "",+  "  res pt st (t0:ts)",+  "    -- Start a new layout block if the first token is a layout word",+  "    | isLayout t0 =",+  "        case ts of",+  "            -- Explicit layout, just move on. The case above",+  "            -- will push an explicit layout block.",+  "            t1:_ | isLayoutOpen t1 -> moveAlong st [t0] ts",+  "                     -- at end of file, the start column doesn't matter",+  "            _ -> let col = if null ts then column t0 else column (head ts)",+  "                     -- insert an open brace after the layout word",+  "                     b:ts' = addToken (nextPos t0) layoutOpen ts",+  "                     -- save the start column",+  "                     st' = Implicit col:st ",+  "                 in -- Do we have to insert an extra layoutSep?",+  "                case st of",+  "                  Implicit n:_",+  "                    | newLine pt t0 && column t0 == n",+  "                      && not (isNothing pt ||",+  "                              isTokenIn [layoutSep,layoutOpen] (fromJust pt)) ->",+  "                     let b':t0':b'':ts'' =",+  "                           addToken (afterPrev pt) layoutSep (t0:b:ts')",+  "                     in moveAlong st' [b',t0',b''] ts'",+  "                  _ -> moveAlong st' [t0,b] ts'",+  "",+  "    -- If we encounter a closing brace, exit the first explicit layout block.",+  "    | isLayoutClose t0 = ",+  "          let st' = drop 1 (dropWhile isImplicit st)",+  "           in if null st' ",+  "                 then error $ \"Layout error: Found \" ++ layoutClose ++ \" at (\" ",+  "                              ++ show (line t0) ++ \",\" ++ show (column t0) ",+  "                              ++ \") without an explicit layout block.\"",+  "                 else moveAlong st' [t0] ts",+  "",+  "  -- Insert separator if necessary.",+  "  res pt st@(Implicit n:ns) (t0:ts)",   "    -- Encounted a new line in an implicit layout block.",-  "    | newLine && column t0 == n =",+  "    | newLine pt t0 && column t0 == n = ",   "       -- Insert a semicolon after the previous token.",   "       -- unless we are the beginning of the file,",   "       -- or the previous token is a semicolon or open brace.",@@ -138,9 +149,6 @@   "          then moveAlong st [t0] ts",   "          else let b:t0':ts' = addToken (afterPrev pt) layoutSep (t0:ts)",   "                in moveAlong st [b,t0'] ts'",-  "   where newLine = case pt of",-  "                           Nothing -> True",-  "                           Just t  -> line t /= line t0",   "",   "  -- Nothing to see here, move along.",   "  res _ st (t:ts)  = moveAlong st [t] ts",@@ -170,6 +178,11 @@   "            -> [Token]",   "  moveAlong _  [] _  = error $ \"Layout error: moveAlong got [] as old tokens\"",   "  moveAlong st ot ts = ot ++ res (Just $ last ot) st ts",+  "",+  "  newLine :: Maybe Token -> Token -> Bool",+  "  newLine pt t0 = case pt of",+  "    Nothing -> True",+  "    Just t  -> line t /= line t0",   "",   "data Block = Implicit Int -- ^ An implicit layout block with its start column.",   "           | Explicit",
src/BNFC/Backend/Haskell/CFtoPrinter.hs view
@@ -17,27 +17,33 @@     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA -} -module BNFC.Backend.Haskell.CFtoPrinter (cf2Printer) where+module BNFC.Backend.Haskell.CFtoPrinter (cf2Printer, compareRules) where +import BNFC.Backend.Haskell.Utils (hsReservedWords) import BNFC.CF import BNFC.Utils-import Data.List (intersperse) import Data.Char(toLower)+import Data.Either (lefts)+import Data.List (sortBy)+import Data.Maybe (fromJust)+import Text.PrettyPrint  -- derive pretty-printer from a BNF grammar. AR 15/2/2002-cf2Printer :: Bool -> String -> String -> CF -> String-cf2Printer byteStrings name absMod cf = unlines [-  prologue byteStrings name absMod,+cf2Printer :: Bool -> Bool -> Bool -> String -> String -> CF -> String+cf2Printer byteStrings functor useGadt name absMod cf = unlines [+  prologue byteStrings useGadt name absMod,   integerRule cf,   doubleRule cf,   if hasIdent cf then identRule byteStrings cf else "",   unlines [ownPrintRule byteStrings cf own | (own,_) <- tokenPragmas cf],-  rules cf+  rules functor cf   ]  -prologue :: Bool -> String -> String -> String-prologue byteStrings name absMod = unlines [+prologue :: Bool -> Bool -> String -> String -> String+prologue byteStrings useGadt name absMod = unlines $+  ["{-# LANGUAGE GADTs, TypeSynonymInstances, FlexibleInstances #-}" | useGadt]+  ++ [   "{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}",   "module " ++ name +++ "where\n",   "-- pretty-printer generated by the BNF converter\n",@@ -86,15 +92,15 @@   "-- the printer class does the job",   "class Print a where",   "  prt :: Int -> a -> Doc",-  "  prtList :: [a] -> Doc",-  "  prtList = concatD . map (prt 0)",+  "  prtList :: Int -> [a] -> Doc",+  "  prtList i = concatD . map (prt i)",   "",   "instance Print a => Print [a] where",-  "  prt _ = prtList",+  "  prt = prtList",   "",   "instance Print Char where",   "  prt _ s = doc (showChar '\\'' . mkEsc '\\'' s . showChar '\\'')",-  "  prtList s = doc (showChar '\"' . concatS (map (mkEsc '\"') s) . showChar '\"')",+  "  prtList _ s = doc (showChar '\"' . concatS (map (mkEsc '\"') s) . showChar '\"')",   "",   "mkEsc :: Char -> Char -> ShowS",   "mkEsc q s = case s of",@@ -133,56 +139,142 @@  -- copy and paste from BNFC.Backend.Haskell.CFtoTemplate -rules :: CF -> String-rules cf = unlines $-  map (\(s,xs) -> case_fun s (map toArgs xs) ++ ifList cf s) $ cf2data cf+rules :: Bool -> CF -> String+rules functor cf = unlines $++  map (\(s,xs) -> render (case_fun functor s (map toArgs xs)) ++++ ifList cf s) $ cf2data cf  where-   toArgs (cons,args) = ((cons, names (map (checkRes . var) args) (0 :: Int)), ruleOf cons)-   names [] _ = []-   names (x:xs) n-     | elem x xs = (x ++ show n) : names xs (n+1)-     | otherwise = x             : names xs n-   var (ListCat c)  = var c ++ "s"-   var (Cat "Ident")   = "id"-   var (Cat "Integer") = "n"-   var (Cat "String")  = "str"-   var (Cat "Char")    = "c"-   var (Cat "Double")  = "d"-   var xs        = map toLower $ show xs-   checkRes s-        | elem s reservedHaskell = s ++ "'"-	| otherwise              = s-   reservedHaskell = ["case","class","data","default","deriving","do","else","if",-		      "import","in","infix","infixl","infixr","instance","let","module",-		      "newtype","of","then","type","where","as","qualified","hiding"]-   ruleOf s = maybe undefined id $ lookupRule s (rulesOfCF cf)+   toArgs (cons,_) = (cons, ruleOf cons)+   ruleOf s = fromJust $ lookupRule s (rulesOfCF cf) ---- case_fun :: Cat -> [(Constructor,Rule)] -> String-case_fun cat xs = unlines [-  "instance Print" +++ show cat +++ "where",-  "  prt i" +++ "e = case e of",-  unlines $ map (\ ((c,xx),r) ->-    "   " ++ c +++ unwords xx +++ "->" +++-    "prPrec i" +++ show (precCat (fst r)) +++ mkRhs xx (snd r)) xs-  ]+-- |+-- >>> case_fun False (Cat "A") [("AA", (Cat "AB", [Right "xxx"]))]+-- instance Print A where+--   prt i e = case e of+--     AA -> prPrec i 0 (concatD [doc (showString "xxx")])+case_fun :: Bool -> Cat -> [(String, (Cat, [Either Cat String]))] -> Doc+case_fun functor cat xs = vcat+    [ "instance Print" <+> type_ <+> "where"+    , nest 2 $ vcat+        [ "prt i e = case e of"+        , nest 2 $ vcat (map (mkPrintCase functor) xs)+        ]+    ]+  where+    type_ | functor   = parens (text (show cat) <+> "a")+          | otherwise = text (show cat) -ifList cf cat = mkListRule $ nil cat ++ one cat ++ cons cat where-  nil cat  = ["   [] -> " ++ mkRhs [] its |-                            Rule f c its <- rulesOfCF cf, isNilFun f , normCatOfList c == cat]-  one cat  = ["   [x] -> " ++ mkRhs ["x"] its |-                            Rule f c its <- rulesOfCF cf, isOneFun f , normCatOfList c == cat]-  cons cat = ["   x:xs -> " ++ mkRhs ["x","xs"] its |-                            Rule f c its <- rulesOfCF cf, isConsFun f , normCatOfList c == cat]-  mkListRule [] = ""-  mkListRule rs = unlines $ ("  prtList" +++ "es = case es of"):rs+--  When writing the Print instance for a category (in case_fun), we have+-- a different case for each constructor for this category.+-- >>> mkPrintCase False ("AA", (Cat "A", [Right "xxx"]))+-- AA -> prPrec i 0 (concatD [doc (showString "xxx")])+--+-- Coercion levels are passed to prPrec+-- >>> mkPrintCase False ("EInt", (CoercCat "Expr" 2, [Left (TokenCat "Integer")]))+-- EInt n -> prPrec i 2 (concatD [prt 0 n])+-- >>> mkPrintCase False ("EPlus", (CoercCat "Expr" 1, [Left (Cat "Expr"), Right "+", Left (Cat "Expr")]))+-- EPlus expr0 expr -> prPrec i 1 (concatD [prt 0 expr0, doc (showString "+"), prt 0 expr])+--+-- If the AST is a functor, ignore first argument+-- >>> mkPrintCase True ("EInt", (CoercCat "Expr" 2, [Left (TokenCat "Integer")]))+-- EInt _ n -> prPrec i 2 (concatD [prt 0 n])+--+-- Skip intertal categories+-- >>> mkPrintCase True ("EInternal", (Cat "Expr", [Left InternalCat, Left (Cat "Expr")]))+-- EInternal _ expr -> prPrec i 0 (concatD [prt 0 expr])+mkPrintCase :: Bool -> (Fun, (Cat, [Either Cat String])) -> Doc+mkPrintCase functor (f, (cat, rhs)) =+    text f <+> (if functor then "_" else empty) <+> hsep variables <+> "->"+    <+> "prPrec i" <+> integer (precCat cat) <+> mkRhs (map render variables) rhs+  where+    -- Creating variables names used in pattern matching. In addition to+    -- haskell's reserved words, `e` and `i` are used in the printing function+    -- and should be avoided+    names = map var (filter (/=InternalCat) $ lefts rhs)+    variables = map text $ mkNames ("e":"i":hsReservedWords) LowerCase names+    var (ListCat c)  = var c ++ "s"+    var (TokenCat "Ident")   = "id"+    var (TokenCat "Integer") = "n"+    var (TokenCat "String")  = "str"+    var (TokenCat "Char")    = "c"+    var (TokenCat "Double")  = "d"+    var xs        = map toLower $ show xs +ifList :: CF -> Cat -> String+ifList cf cat = render $ nest 2 $ vcat [ mkPrtListCase r | r <- rules ]+  where+    rules = sortBy compareRules $ rulesForNormalizedCat cf (ListCat cat) ++-- | Pattern match on the list constructor and the coercion level+-- >>> mkPrtListCase (Rule "[]" (ListCat (Cat "Foo")) [])+-- prtList _ [] = (concatD [])+-- >>> mkPrtListCase (Rule "(:[])" (ListCat (Cat "Foo")) [Left (Cat "FOO")])+-- prtList _ [x] = (concatD [prt 0 x])+-- >>> mkPrtListCase (Rule "(:)" (ListCat (Cat "Foo")) [Left (Cat "Foo"), Left (ListCat (Cat "Foo"))])+-- prtList _ (x:xs) = (concatD [prt 0 x, prt 0 xs])+-- >>> mkPrtListCase (Rule "[]" (ListCat (CoercCat "Foo" 2)) [])+-- prtList 2 [] = (concatD [])+-- >>> mkPrtListCase (Rule "(:[])" (ListCat (CoercCat "Foo" 2)) [Left (CoercCat "Foo" 2)])+-- prtList 2 [x] = (concatD [prt 2 x])+-- >>> mkPrtListCase (Rule "(:)" (ListCat (CoercCat "Foo" 2)) [Left (CoercCat "Foo" 2), Left (ListCat (CoercCat "Foo" 2))])+-- prtList 2 (x:xs) = (concatD [prt 2 x, prt 2 xs])+mkPrtListCase :: Rule -> Doc+mkPrtListCase (Rule f (ListCat c) rhs)+  | isNilFun f = "prtList" <+> precPattern <+> "[]" <+> "=" <+> body+  | isOneFun f = "prtList" <+> precPattern <+> "[x]" <+> "=" <+> body+  | isConsFun f = "prtList" <+> precPattern <+> "(x:xs)" <+> "=" <+> body+  | otherwise = empty -- (++) constructor+  where+    precPattern = case precCat c of 0 -> "_" ; p -> integer p+    body = mkRhs ["x", "xs"] rhs+++-- | Define an ordering on lists' rules with the following properties:+-- - rules with a higher coercion level should come first, i.e. the rules for+--   [Foo3] are before rules for [Foo1] and they are both lower than rules for+--   [Foo].+-- - [] < [_] < _:_+-- This is desiged to correctly order the rules in the prtList function so that+-- the pattern matching works as expectd.+--+-- >>> compareRules (Rule "[]" (ListCat (CoercCat "Foo" 3)) []) (Rule "[]" (ListCat (CoercCat "Foo" 1)) [])+-- LT+-- >>> compareRules (Rule "[]" (ListCat (CoercCat "Foo" 3)) []) (Rule "[]" (ListCat (Cat "Foo")) [])+-- LT+-- >>> compareRules (Rule "[]" (ListCat (Cat "Foo")) []) (Rule "(:[])" (ListCat (Cat "Foo")) [])+-- LT+-- >>> compareRules (Rule "(:[])" (ListCat (Cat "Foo")) []) (Rule "(:)" (ListCat (Cat "Foo")) [])+-- LT+compareRules :: Rule -> Rule -> Ordering+compareRules r1 r2 | precRule r1 > precRule r2 = LT+compareRules r1 r2 | precRule r1 < precRule r2 = GT+compareRules (Rule "[]" _ _) (Rule "[]" _ _) = EQ+compareRules (Rule "[]" _ _) _ = LT+compareRules (Rule "(:[])" _ _) (Rule "[]" _ _) = GT+compareRules (Rule "(:[])" _ _) (Rule "(:[])" _ _) = EQ+compareRules (Rule "(:[])" _ _) (Rule "(:)" _ _) = LT+compareRules (Rule "(:)" _ _) (Rule "(:)" _ _) = EQ+compareRules (Rule "(:)" _ _) _ = GT+compareRules _ _ = EQ+++-- |+-- >>> mkRhs ["expr1", "n", "expr2"] [Left (Cat "Expr"), Right "-", Left (TokenCat "Integer"), Left (Cat "Expr")]+-- (concatD [prt 0 expr1, doc (showString "-"), prt 0 n, prt 0 expr2])+--+-- Coercions on the right hand side should be passed to prt:+-- >>> mkRhs ["expr1"] [Left (CoercCat "Expr" 2)]+-- (concatD [prt 2 expr1])+-- >>> mkRhs ["expr2s"] [Left (ListCat (CoercCat "Expr" 2))]+-- (concatD [prt 2 expr2s])+mkRhs :: [String] -> [Either Cat String] -> Doc mkRhs args its =-  "(concatD [" ++ unwords (intersperse "," (mk args its)) ++ "])"+    parens ("concatD" <+> brackets (hsep (punctuate "," (mk args its))))  where-  mk args (Left InternalCat : items)      = mk args items-  mk (arg:args) (Left c : items)  = (prt c +++ arg)        : mk args items-  mk args       (Right s : items) = ("doc (showString" +++ show s ++ ")") : mk args items-  mk _ _ = []-  prt c = "prt" +++ show (precCat c)+  mk args (Left InternalCat : items) = mk args items+  mk (arg:args) (Left c  : items)    = (prt c <+> text arg) : mk args items+  mk args       (Right s : items)    = ("doc (showString" <+> text (show s) <> ")") : mk args items+  mk _          _                    = []+  prt c = "prt" <+> integer (precCat c) 
src/BNFC/Backend/Haskell/CFtoTemplate.hs view
@@ -18,56 +18,25 @@ -}  -module BNFC.Backend.Haskell.CFtoTemplate (-		    cf2Template-                    ) where+module BNFC.Backend.Haskell.CFtoTemplate (cf2Template) where +import BNFC.Backend.Haskell.Utils (catvars) import BNFC.CF-import Data.Char+import BNFC.PrettyPrint  type ModuleName = String-type Constructor = String -cf2Template :: ModuleName -> ModuleName -> ModuleName -> CF -> String-cf2Template skelName absName errName cf = unlines-  [-  "module "++ skelName ++ " where\n",-  "-- Haskell module generated by the BNF converter\n",-  "import " ++ absName,-  "import " ++ errName,-  "type Result = Err String\n",-  "failure :: Show a => a -> Result",-  "failure x = Bad $ \"Undefined case: \" ++ show x\n",-  unlines $ map (\(s,xs) -> case_fun s (toArgs xs)) $ specialData cf ++ cf2data cf-  ]- where toArgs               [] = []-       toArgs ((cons,args):xs)-	   = (cons ++ " " ++  names False (map (checkRes . var) args) (1 :: Int)) : toArgs xs-       names _ [] _ = []-       names b (x:xs) n-        | elem x xs = (x ++ show n) ++ " " ++ names True xs (n+1)-	| otherwise = (x ++ if b then show n else "") ++ " " ++ names b xs (if b then n+1 else n)-{--       toArgs ((cons,args):xs)-	   = (cons ++ " " ++  names (map (checkRes . var) args) (0 :: Int)) : toArgs xs-       names [] _ = []-       names (x:xs) n-        | elem x xs = (x ++ show n) ++ " " ++ names xs (n+1)-	| otherwise = x ++ " " ++ names xs n--}-       var (ListCat c) = var c ++ "s"-       var (Cat "Ident")   = "id"-       var (Cat "Integer") = "n"-       var (Cat "String")  = "str"-       var (Cat "Char")    = "c"-       var (Cat "Double")  = "d"-       var xs        = map toLower (show xs)-       checkRes s-        | elem s reservedHaskell = s ++ "'"-	| otherwise              = s-       reservedHaskell =  ["case","class","data","default","deriving","do","else","if",-			   "import","in","infix","infixl","infixr","instance","let","module",-			   "newtype","of","then","type","where","as","qualified","hiding"]+cf2Template :: ModuleName -> ModuleName -> ModuleName -> Bool -> CF -> String+cf2Template skelName absName errName functor cf = unlines+    [ "module "++ skelName ++ " where\n"+    , "-- Haskell module generated by the BNF converter\n"+    , "import " ++ absName+    , "import " ++ errName+    , "type Result = Err String\n"+    , "failure :: Show a => a -> Result"+    , "failure x = Bad $ \"Undefined case: \" ++ show x\n"+    , unlines $ map (render . \(s,xs) -> case_fun functor s xs) $ specialData cf ++ cf2data cf+    ]  {- ---- cf2Template :: ModuleName -> CF -> String@@ -104,10 +73,38 @@ 			  "newtype","of","then","type","where","as","qualified","hiding"] -} -case_fun :: Cat -> [Constructor] -> String-case_fun cat xs =- unlines $-	 ["trans" ++ cat' ++ " :: " ++ cat' ++ " -> Result",-	  "trans" ++ cat' ++ " x = case x of",-	  unlines $ map (\s -> "  " ++ s ++ " -> " ++ "failure x") xs]-  where cat' = show cat+-- |+-- >>> case_fun False (Cat "Expr") [("EInt", [TokenCat "Integer"]), ("EAdd", [Cat "Expr", Cat "Expr"])]+-- transExpr :: Expr -> Result+-- transExpr x = case x of+--   EInt integer -> failure x+--   EAdd expr1 expr2 -> failure x+--+-- >>> case_fun True (Cat "Expr") [("EInt", [TokenCat "Integer"]), ("EAdd", [Cat "Expr", Cat "Expr"])]+-- transExpr :: Show a => Expr a -> Result+-- transExpr x = case x of+--   EInt _ integer -> failure x+--   EAdd _ expr1 expr2 -> failure x+--+-- TokenCat are not generated as functors:+-- >>> case_fun True (TokenCat "MyIdent") [("MyIdent", [TokenCat "String"])]+-- transMyIdent :: MyIdent -> Result+-- transMyIdent x = case x of+--   MyIdent string -> failure x+case_fun :: Bool -> Cat -> [(Fun,[Cat])] -> Doc+case_fun functor' cat xs = vcat+    [ fname <+> "::" <+> iffunctor "Show a =>" <+> type_ <+> "-> Result"+    , fname <+> "x = case x of"+    , nest 2 $ vcat (map mkOne xs)+    ]+  where+    -- If the functor option is set AND the category is not a token type,+    -- then the type is a functor.+    iffunctor doc | functor' && not (isTokenCat cat) = doc+                  | otherwise = empty+    type_ = cat' <+> iffunctor "a"+    fname = "trans" <> cat'+    cat' =  text (show cat)+    mkOne (cons, args) =+        let ns = catvars args -- names False (map (checkRes .var) args) 1+        in  text cons <+> iffunctor "_" <+> hsep ns <+> "-> failure x"
src/BNFC/Backend/Haskell/HsOpts.hs view
@@ -1,40 +1,38 @@-module BNFC.Backend.Haskell.HsOpts  where+module BNFC.Backend.Haskell.HsOpts where  import BNFC.Utils import BNFC.Options-import System.FilePath (pathSeparator)+import System.FilePath (pathSeparator, (<.>))+import Data.List (intercalate)+import Data.Maybe (catMaybes)  type Options = SharedOptions  alex1 opts = alexMode opts == Alex1 -absFile, absFileM, alexFile, alexFileM, dviFile,+absFile, absFileM,+ alexFile, alexFileM,  composOpFile, composOpFileM,- gfAbs, gfConc,+ gfAbs,  happyFile, happyFileM,- latexFile, errFile, errFileM,+ errFile, errFileM,  templateFile, templateFileM,  printerFile, printerFileM,  layoutFile, layoutFileM,- psFile, tFile, tFileM :: Options -> String-absFile       = mkFile withLangAbs "Abs" "hs"-absFileM      = mkMod  withLangAbs "Abs"+ tFile :: Options -> String+absFile       = mkFile withLang "Abs" "hs"+absFileM      = mkMod  withLang "Abs" alexFile      = mkFile withLang "Lex" "x" alexFileM     = mkMod  withLang "Lex" happyFile     = mkFile withLang "Par" "y" happyFileM    = mkMod  withLang "Par"-latexFile     = mkFile withLang "Doc" "tex" txtFile       = mkFile withLang "Doc" "txt" templateFile  = mkFile withLang "Skel" "hs" templateFileM = mkMod  withLang "Skel" printerFile   = mkFile withLang "Print" "hs" printerFileM  = mkMod  withLang "Print"-dviFile       = mkFile withLang "Doc" "dvi"-psFile        = mkFile withLang "Doc" "ps"-gfAbs         = mkFile withLangAbs "" "Abs.gf"-gfConc        = mkFile withLang "" "Conc.gf"+gfAbs         = mkFile withLang "" "Abs.gf" tFile         = mkFile withLang "Test" "hs"-tFileM        = mkMod  withLang "Test" errFile       = mkFile noLang   "ErrM" "hs" errFileM      = mkMod  noLang   "ErrM" shareFile     = mkFile noLang   "SharedString" "hs"@@ -53,26 +51,79 @@ noLang _ name = name  withLang :: Options -> String -> String-withLang opts name = name ++ lang opts--withLangAbs :: Options -> String -> String-withLangAbs opts name = postp $ name ++ lang opts-  where-    postp nam = nam -- if multi opts then takeWhile (/='_') nam else nam+withLang opts name = name ++ mkName [] CamelCase (lang opts)  pkgToDir :: String -> FilePath pkgToDir s = replace '.' pathSeparator s  +-- |+-- >>> mkMod withLang "Abstract" defaultOptions { lang = "abc" }+-- "AbstractAbc"+-- >>> mkMod noLang "Abstract" defaultOptions { lang = "abc" }+-- "Abstract"+-- >>> mkMod withLang "Abstract" defaultOptions { lang = "abc", inPackage = Just "A.B.C" }+-- "A.B.C.AbstractAbc"+-- >>> mkMod withLang "Abstract" defaultOptions { lang = "abc", inDir = True }+-- "Abc.Abstract"+-- >>> mkMod withLang "Abstract" defaultOptions { lang = "abc", inDir = True, inPackage = Just "A.B.C" }+-- "A.B.C.Abc.Abstract" mkMod :: (Options -> String -> String) -> String -> Options -> String-mkMod addLang name opts =-    pref ++ if inDir opts then lang opts ++ "." ++ name else addLang opts name-	where pref = maybe "" (++".") (inPackage opts)-+mkMod addLang name opts = mkNamespace opts <.> mod+  where+    [] <.> s = s+    s1 <.> s2 = s1 ++ "." ++ s2+    mod | inDir opts = name+        | otherwise  = addLang opts name+-- |+-- >>> mkFile withLang "Abstract" "hs" defaultOptions { lang = "abc" }+-- "AbstractAbc.hs"+-- >>> mkFile noLang "Abstract" "hs" defaultOptions { lang = "abc" }+-- "Abstract.hs"+-- >>> mkFile withLang "Abstract" "" defaultOptions { lang = "abc" }+-- "AbstractAbc"+-- >>> mkFile noLang "Abstract" "" defaultOptions { lang = "abc" }+-- "Abstract"+-- >>> mkFile withLang "Abstract" "hs" defaultOptions { lang = "abc", inDir = True }+-- "Abc/Abstract.hs"+-- >>> mkFile withLang "Abstract" "hs" defaultOptions { lang = "abc", inDir = True, inPackage = Just "A.B.C" }+-- "A/B/C/Abc/Abstract.hs" mkFile :: (Options -> String -> String) -> String -> String -> Options -> FilePath-mkFile addLang name ext opts =-    pref ++ if inDir opts-       then lang opts ++ [pathSeparator] ++ name ++ ext'-       else addLang opts name ++ if null ext then "" else ext'-    where pref = maybe "" (\p->pkgToDir p++[pathSeparator]) (inPackage opts)-	  ext' = if null ext then "" else "." ++ ext+mkFile addLang name ext opts = pkgToDir (mkMod addLang name opts) <.> ext++mkFileName :: String -> String -> FilePath+mkFileName module' ext = pkgToDir module' <.> ext+++-- | Determine the modules' namespace+--+-- >>> mkNamespace defaultOptions+-- ""+-- >>> mkNamespace defaultOptions { lang = "Bla", inDir = True }+-- "Bla"+-- >>> mkNamespace defaultOptions { inPackage = Just "My.Cool.Package" }+-- "My.Cool.Package"+-- >>> mkNamespace defaultOptions { lang = "bla_bla", inDir = True }+-- "BlaBla"+-- >>> mkNamespace defaultOptions { lang = "bla", inDir = True, inPackage = Just "P"}+-- "P.Bla"+mkNamespace :: Options -> FilePath+mkNamespace opts = intercalate "." $ catMaybes [inPackage opts, dir]+  where+    dir | inDir opts = Just (mkName [] CamelCase (lang opts))+        | otherwise  = Nothing++-- | Determine the directory corresponding to the modules' namespace+--+-- >>> codeDir defaultOptions+-- ""+-- >>> codeDir defaultOptions { lang = "Bla", inDir = True }+-- "Bla"+-- >>> codeDir defaultOptions { inPackage = Just "My.Cool.Package" }+-- "My/Cool/Package"+-- >>> codeDir defaultOptions { lang = "bla_bla", inDir = True }+-- "BlaBla"+-- >>> codeDir defaultOptions { lang = "bla", inDir = True, inPackage = Just "P"}+-- "P/Bla"+codeDir :: Options -> FilePath+codeDir = pkgToDir . mkNamespace
src/BNFC/Backend/Haskell/MkErrM.hs view
@@ -18,45 +18,43 @@     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA -} module BNFC.Backend.Haskell.MkErrM where- errM :: String -> b -> String-errM errMod _ = unlines-	   [-	    "-- BNF Converter: Error Monad",-	    "-- Copyright (C) 2004  Author:  Aarne Ranta",-	    "",-	    "-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.",-	    "module " ++ errMod ++ " where",-	    "",-	    "-- the Error monad: like Maybe type with error msgs",-	    "",-      "import Control.Monad (MonadPlus(..), liftM)",-      "import Control.Applicative (Applicative(..), Alternative(..))",-      "",-	    "data Err a = Ok a | Bad String",-	    "  deriving (Read, Show, Eq, Ord)",-	    "",-	    "instance Monad Err where",-	    "  return      = Ok",-	    "  fail        = Bad",-	    "  Ok a  >>= f = f a",-	    "  Bad s >>= _ = Bad s",-      "",-      "instance Applicative Err where",-      "  pure = Ok",-      "  (Bad s) <*> _ = Bad s",-      "  (Ok f) <*> o  = liftM f o",-      "",-      "",-      "instance Functor Err where",-      "  fmap = liftM",-      "",-      "instance MonadPlus Err where",-      "  mzero = Bad \"Err.mzero\"",-      "  mplus (Bad _) y = y",-      "  mplus x       _ = x",-      "",-      "instance Alternative Err where",-      "  empty = mzero",-      "  (<|>) = mplus"-	   ]+errM errMod _ = +  unlines+    ["-- BNF Converter: Error Monad"+    ,"-- Copyright (C) 2004  Author:  Aarne Ranta"+    ,""+    ,"-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE."+    ,"module " ++ errMod ++ " where"+    ,""+    ,"-- the Error monad: like Maybe type with error msgs"+    ,""+    ,"import Control.Monad (MonadPlus(..), liftM)"+    ,"import Control.Applicative (Applicative(..), Alternative(..))"+    ,""+    ,"data Err a = Ok a | Bad String"+    ,"  deriving (Read, Show, Eq, Ord)"+    ,""+    ,"instance Monad Err where"+    ,"  return      = Ok"+    ,"  fail        = Bad"+    ,"  Ok a  >>= f = f a"+    ,"  Bad s >>= _ = Bad s"+    ,""+    ,"instance Applicative Err where"+    ,"  pure = Ok"+    ,"  (Bad s) <*> _ = Bad s"+    ,"  (Ok f) <*> o  = liftM f o"+    ,""+    ,""+    ,"instance Functor Err where"+    ,"  fmap = liftM"+    ,""+    ,"instance MonadPlus Err where"+    ,"  mzero = Bad \"Err.mzero\""+    ,"  mplus (Bad _) y = y"+    ,"  mplus x       _ = x"+    ,""+    ,"instance Alternative Err where"+    ,"  empty = mzero"+    ,"  (<|>) = mplus"]
+ src/BNFC/Backend/Haskell/Utils.hs view
@@ -0,0 +1,120 @@+module BNFC.Backend.Haskell.Utils+  ( parserName+  , hsReservedWords+  , catToType+  , catvars+  ) where++import Text.PrettyPrint+import BNFC.CF (Cat(..), identCat, normCat)+import BNFC.Utils (mkNames, NameStyle(..))++-- | Create a valid parser function name for a given category+-- >>> parserName (Cat "Abcd")+-- pAbcd+-- >>> parserName (ListCat (Cat "Xyz"))+-- pListXyz+parserName :: Cat -> Doc+parserName = ("p" <>) . text . identCat++-- | Haskell's reserved words+hsReservedWords :: [String]+hsReservedWords =+    [ "as"+    , "case"+    , "class"+    , "data"+    , "default"+    , "deriving"+    , "do"+    , "else"+    , "hiding"+    , "if"+    , "import"+    , "in"+    , "infix"+    , "infixl"+    , "infixr"+    , "instance"+    , "let"+    , "module"+    , "newtype"+    , "of"+    , "qualified"+    , "then"+    , "type"+    , "where"+    ]+++-- | Render a category from the grammar to a Haskell type+-- >>> catToType Nothing (Cat "A")+-- A+-- >>> catToType Nothing (ListCat (Cat "A"))+-- [A]+-- >>> catToType Nothing (TokenCat "Ident")+-- Ident+--+-- Note that there is no haskell type for coerced categories: they should be+-- normalized+-- >>> catToType Nothing (CoercCat "Expr" 2)+-- Expr+--+-- If a type parameter is given it is added to the type name:+-- >>> catToType (Just "a") (Cat "A")+-- (A a)+--+-- >>> catToType (Just "a") (ListCat (Cat "A"))+-- [A a]+--+-- but not added to Token categories:+-- >>> catToType (Just "a") (TokenCat "Integer")+-- Integer+--+-- >>> catToType (Just "a") (ListCat (TokenCat "Integer"))+-- [Integer]+--+-- >>> catToType Nothing (ListCat (CoercCat "Exp" 2))+-- [Exp]+--+-- >>> catToType (Just "()") (ListCat (CoercCat "Exp" 2))+-- [Exp ()]+catToType :: Maybe Doc -> Cat -> Doc+catToType param cat = maybeParens $ catToType' param cat+  where+    maybeParens = case (param,cat) of+        (Just _, Cat _) -> parens+        _ -> id+    catToType' _ InternalCat = error "Can't create a haskell type for internal category"+    catToType' Nothing c = text $ show $ normCat c+    catToType' (Just p) (Cat c) = text c <+> p+    catToType' (Just p) (CoercCat c _) = text c <+> p+    catToType' (Just _) (TokenCat c) = text c+    catToType' (Just p) (ListCat c) = lbrack <> catToType' (Just p) c <> rbrack+++-- | gives you a list of variables usable for pattern matching.+-- Ex: if you have the rule Aba. S ::= A B A ; with the generated data type+--   data S = Aba A B A+-- Given the lit of categories in the RHS of the rule (A B A), we generate the+-- list [a1,b,a2] to be used in a pattern matching like+-- case s of+--     Aba a1 b a2 -> ...+--     ...+--+-- >>> catvars [Cat "A", Cat "B", Cat "A"]+-- [a1,b,a2]+--+-- It should avoid reserved words+-- >>> catvars [Cat "IF", Cat "Case", Cat "Type", Cat "If"]+-- [if_1,case_,type_,if_2]+--+-- It uses an -s to mark lists:+-- >>> catvars [Cat "A", ListCat (Cat "A"), ListCat (ListCat (Cat "A"))]+-- [a,as_,ass]+catvars :: [Cat] -> [Doc]+catvars = map text . mkNames hsReservedWords LowerCase . map var+  where+    var (ListCat c) = var c ++ "s"+    var xs          = show xs+
src/BNFC/Backend/HaskellGADT.hs view
@@ -32,7 +32,7 @@ import BNFC.Backend.Haskell.CFtoAlex3 import BNFC.Backend.HaskellGADT.CFtoAbstractGADT import BNFC.Backend.HaskellGADT.CFtoTemplateGADT-import BNFC.Backend.HaskellGADT.CFtoPrinterGADT+import BNFC.Backend.Haskell.CFtoPrinter import BNFC.Backend.Haskell.CFtoLayout import BNFC.Backend.XML import BNFC.Backend.Haskell.MkErrM@@ -67,10 +67,10 @@         mkfile (alexFile opts) $ cf2alex3 lexMod errMod shareMod (shareStrings opts) (byteStrings opts) cf         liftIO $ putStrLn "   (Use Alex 3.0 to compile.)"     mkfile (happyFile opts) $-		 cf2HappyS parMod absMod lexMod errMod (glr opts) (byteStrings opts) cf+      cf2HappyS parMod absMod lexMod errMod (glr opts) (byteStrings opts) False cf     liftIO $ putStrLn "   (Tested with Happy 1.15)"     mkfile (templateFile opts) $ cf2Template (templateFileM opts) absMod errMod cf-    mkfile (printerFile opts)  $ cf2Printer prMod absMod cf+    mkfile (printerFile opts)  $ cf2Printer False False True prMod absMod cf     when (hasLayout cf) $ mkfile (layoutFile opts) $ cf2Layout (alexMode opts == Alex1) (inDir opts) layMod lexMod cf     mkfile (tFile opts)        $ Haskell.testfile opts cf     mkfile (errFile opts)      $ errM errMod cf@@ -80,7 +80,6 @@       2 -> makeXML opts True cf       1 -> makeXML opts False cf       _ -> return ()-  composOp :: String -> String composOp composOpMod = unlines
− src/BNFC/Backend/HaskellGADT/CFtoPrinterGADT.hs
@@ -1,155 +0,0 @@-{--    BNF Converter: GADT Pretty-printer generator-    Copyright (C) 2004-2005  Author:  Aarne Ranta, Björn Bringert--    This program is free software; you can redistribute it and/or modify-    it under the terms of the GNU General Public License as published by-    the Free Software Foundation; either version 2 of the License, or-    (at your option) any later version.--    This program 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 General Public License for more details.--    You should have received a copy of the GNU General Public License-    along with this program; if not, write to the Free Software-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA--}--module BNFC.Backend.HaskellGADT.CFtoPrinterGADT (cf2Printer) where--import BNFC.CF-import BNFC.Utils-import Data.List (intersperse)--import BNFC.Backend.HaskellGADT.HaskellGADTCommon---- derive pretty-printer from a BNF grammar. AR 15/2/2002-cf2Printer :: String -> String -> CF -> String-cf2Printer name absMod cf = unlines $ [-  prologue name absMod,-  integerRule cf,-  doubleRule cf]-  ++ prPrt cf-  ++ [""]-  ++ concatMap (prPrtList cf) (filter isList (allCats cf))--prologue :: String -> String -> String-prologue name absMod = unlines [-  "{-# LANGUAGE GADTs, TypeSynonymInstances, FlexibleInstances #-}",-  "module " ++ name +++ "where\n",-  "-- pretty-printer generated by the BNF converter\n",-  "import " ++ absMod,-  "import Data.Char",-  "import Data.List (intersperse)",-  "",-  "-- the top-level printing method",-  "printTree :: Print a => a -> String",-  "printTree = render . prt 0",-  "",-  "type Doc = [ShowS] -> [ShowS]",-  "",-  "doc :: ShowS -> Doc",-  "doc = (:)",-  "",-  "render :: Doc -> String",-  "render d = rend 0 (map ($ \"\") $ d []) \"\" where",-  "  rend i ss = case ss of",-  "    \"[\"      :ts -> showChar '[' . rend i ts",-  "    \"(\"      :ts -> showChar '(' . rend i ts",-  "    \"{\"      :ts -> showChar '{' . new (i+1) . rend (i+1) ts",-  "    \"}\" : \";\":ts -> new (i-1) . space \"}\" . showChar ';' . new (i-1) . rend (i-1) ts",-  "    \"}\"      :ts -> new (i-1) . showChar '}' . new (i-1) . rend (i-1) ts",-  "    \";\"      :ts -> showChar ';' . new i . rend i ts",-  "    t  : \",\" :ts -> showString t . space \",\" . rend i ts",-  "    t  : \")\" :ts -> showString t . showChar ')' . rend i ts",-  "    t  : \"]\" :ts -> showString t . showChar ']' . rend i ts",-  "    t        :ts -> space t . rend i ts",-  "    _            -> id",-  "  new i   = showChar '\\n' . replicateS (2*i) (showChar ' ') . dropWhile isSpace",-  "  space t = showString t . (\\s -> if null s then \"\" else (' ':s))",-  "",-  "parenth :: Doc -> Doc",-  "parenth ss = doc (showChar '(') . ss . doc (showChar ')')",-  "",-  "concatS :: [ShowS] -> ShowS",-  "concatS = foldr (.) id",-  "",-  "concatD :: [Doc] -> Doc",-  "concatD = foldr (.) id",-  "",-  "unwordsD :: [Doc] -> Doc",-  "unwordsD = concatD . intersperse (doc (showChar ' '))",-  "",-  "replicateS :: Int -> ShowS -> ShowS",-  "replicateS n f = concatS (replicate n f)",-  "",-  "-- the printer class does the job",-  "class Print a where",-  "  prt :: Int -> a -> Doc",-  "",-  "instance Print Char where",-  "  prt _ s = doc (showChar '\\'' . mkEsc '\\'' s . showChar '\\'')",-  "",-  "instance Print String where",-  "  prt _ s = doc (showChar '\"' . concatS (map (mkEsc '\"') s) . showChar '\"')",-  "",-  "mkEsc :: Char -> Char -> ShowS",-  "mkEsc q s = case s of",-  "  _ | s == q -> showChar '\\\\' . showChar s",-  "  '\\\\'-> showString \"\\\\\\\\\"",-  "  '\\n' -> showString \"\\\\n\"",-  "  '\\t' -> showString \"\\\\t\"",-  "  _ -> showChar s",-  "",-  "prPrec :: Int -> Int -> Doc -> Doc",-  "prPrec i j = if j<i then parenth else id",-  ""-  ]--integerRule cf = showsPrintRule cf "Integer"-doubleRule cf = showsPrintRule cf "Double"--showsPrintRule _ t = unlines $ [-  "instance Print " ++ t ++ " where",-  "  prt _ x = doc (shows x)",-  ""]--prPrt :: CF -> [String]-prPrt cf = ["instance Print (Tree c) where",-	     "  prt _i e = case e of"-	    ] ++ map prPrtCons (cf2cons cf)-  where-  prPrtCons c = "    " ++ consFun c +++ unwords (vars c) +++ "->" +++-                "prPrec _i" +++ show (consPrec c) +++ rhs-    -- for token rules, just print the string argument unquoted-    where rhs | isToken c = let [v] = vars c in "(doc (showString " ++ v ++ "))"-              | otherwise = mkRhs (vars c) (consRhs c)-  vars = map snd . consVars-  isToken c = consCat c `elem` specialCats cf--prPrtList :: CF -> Cat -> [String]-prPrtList cf cat = mkListRule (nil ++ one ++ cons)- where-  nil  = ["   [] -> " ++ mkRhs [] its |-                         Rule f _ its <- rules, isNilFun f]-  one  = ["   [x] -> " ++ mkRhs ["x"] its |-                         Rule f _ its <- rules, isOneFun f]-  cons = ["   x:xs -> " ++ mkRhs ["x","xs"] its |-                         Rule f _ its <- rules, isConsFun f]-  mkListRule [] = []-  mkListRule rs = ["instance Print" +++ show (normCat cat) +++ "where",-		 "  prt _" +++ "es = case es of"] ++ rs-  rules = rulesForCat cf cat--mkRhs :: [String] -> [Either Cat String] -> String-mkRhs args its =-  "(concatD [" ++ unwords (intersperse "," (mk args its)) ++ "])"- where-  mk args (Left InternalCat : items)      = mk args items-  mk (arg:args) (Left c : items)  = (prt c +++ arg) : mk args items-  mk args       (Right s : items) = ("doc (showString" +++ show s ++ ")") : mk args items-  mk _ _                          = []-  prt c = "prt" +++ show (precCat c)-
src/BNFC/Backend/HaskellProfile.hs view
@@ -19,18 +19,17 @@  module BNFC.Backend.HaskellProfile (makeHaskellProfile) where --- import Utils+import Control.Monad (when)+import Data.Maybe (isJust)+ import BNFC.CF-import BNFC.Options+import BNFC.Options hiding (Backend)+import BNFC.Backend.Base import BNFC.Backend.HaskellProfile.CFtoHappyProfile import BNFC.Backend.Haskell.CFtoAlex import BNFC.Backend.Haskell.CFtoAlex2 import BNFC.Backend.Haskell.MkErrM-import BNFC.Utils -import Data.Maybe (isJust)-import Control.Monad(when)- -- naming conventions  nameMod :: String -> Bool -> String -> FilePath@@ -57,7 +56,7 @@ errFile b n   = if b then n ++ "/" ++ "ErrM.hs" else "ErrM.hs" errFileM b n  = if b then n ++ "." ++ "ErrM" else "ErrM" -makeHaskellProfile :: SharedOptions -> CFP -> IO ()+makeHaskellProfile :: SharedOptions -> CFP -> Backend makeHaskellProfile opts cfp = do   let absMod = absFileM      (inDir opts) name       lexMod = alexFileM     (inDir opts) name@@ -65,28 +64,26 @@       errMod = errFileM      (inDir opts) name   let cf = cfp2cf cfp   do-    when (inDir opts) (prepareDir name)-----    writeFileRep (absFile  (inDir opts) name) $ cf2Abstract (absFileM (inDir opts) name) cf-    if (alexMode opts == Alex1) then do-		    writeFileRep (alexFile (inDir opts) name) $ cf2alex lexMod errMod cf-		    putStrLn "   (Use Alex 1.1 to compile.)"-	       else do-		    writeFileRep (alexFile (inDir opts) name) $ cf2alex2 lexMod errMod "" False False cf-                    putStrLn "   (Use Alex 2.0 to compile.)"-    writeFileRep (happyFile (inDir opts) name) $-		 cf2HappyProfileS parMod absMod lexMod errMod cfp-    putStrLn "   (Tested with Happy 1.13)"-----    writeFileRep (templateFile (inDir opts) name) $-----		 cf2Template tplMod absMod errMod cf-----    writeFileRep (printerFile (inDir opts) name)  $ cf2Printer prMod absMod cf+----    mkfile (absFile  (inDir opts) name) $ cf2Abstract (absFileM (inDir opts) name) cf+    if alexMode opts == Alex1 then do+                    mkfile (alexFile (inDir opts) name) $ cf2alex lexMod errMod cf+                    liftIO $ putStrLn "   (Use Alex 1.1 to compile.)"+               else do+                    mkfile (alexFile (inDir opts) name) $ cf2alex2 lexMod errMod "" False False cf+                    liftIO $ putStrLn "   (Use Alex 2.0 to compile.)"+    mkfile (happyFile (inDir opts) name) $+                 cf2HappyProfileS parMod absMod lexMod errMod cfp+    liftIO $ putStrLn "   (Tested with Happy 1.13)"+----    mkfile (templateFile (inDir opts) name) $+----             cf2Template tplMod absMod errMod cf+----    mkfile (printerFile (inDir opts) name)  $ cf2Printer prMod absMod cf ----    if hasLayout cf then-----      writeFileRep (layoutFile (inDir opts) name) $ cf2Layout alex1 (inDir opts) layMod lexMod cf+----      mkfile (layoutFile (inDir opts) name) $ cf2Layout alex1 (inDir opts) layMod lexMod cf ----      else return ()-    writeFileRep (tFile (inDir opts) name)        $ testfile (inDir opts) name (xml opts>0) cf-    writeFileRep (errFile (inDir opts) name)      $ errM errMod cf-    if (isJust $ make opts)-       then (writeFileRep (mFile (inDir opts) name) $ makefile (inDir opts) name)-       else return ()+    mkfile (tFile (inDir opts) name)        $ testfile (inDir opts) name (xml opts>0) cf+    mkfile (errFile (inDir opts) name)      $ errM errMod cf+    when (isJust $ make opts)+        (mkfile (mFile (inDir opts) name) $ makefile (inDir opts) name) ----    case xml of ----      2 -> makeXML name True cf ----      1 -> makeXML name False cf@@ -100,34 +97,34 @@                       if inDir then name ++ "/" ++ "Test" else "Test" ++ name   makeA = unlines                 [- 		 "all:",+                 "all:",                  "\thappy -gca " ++ happyFile False name',-		 "\talex "  ++ alexFile  False name',-		 "\t" ++ if inDir then-		           "(" ++ "cd ..; " ++ ghcCommand ++ ")"+                 "\talex "  ++ alexFile  False name',+                 '\t' : if inDir then+                           "(" ++ "cd ..; " ++ ghcCommand ++ ")"                          else ghcCommand,-		 "clean:",-		 "\t rm -f *.hi *.o",-		 "distclean: " ++ if inDir then "" else "clean",-		 if inDir then-		   "\t rm -rf ../" ++ name -- erase this directory!-		 else-		   "\t rm -f " ++ unwords [-					   "Doc" ++ name ++ ".*",-					   "Lex" ++ name ++ ".*",-					   "Par" ++ name ++ ".*",-----					   "Layout" ++ name ++ ".*",-----					   "Skel" ++ name ++ ".*",-----					   "Print" ++ name ++ ".*",-					   "Test" ++ name ++ ".*",-----					   "Abs" ++ name ++ ".*",-					   "Test" ++ name,-					   "ErrM.*",+                 "clean:",+                 "\t rm -f *.hi *.o",+                 "distclean: " ++ if inDir then "" else "clean",+                 if inDir then+                   "\t rm -rf ../" ++ name -- erase this directory!+                 else+                   "\t rm -f " ++ unwords [+                                           "Doc" ++ name ++ ".*",+                                           "Lex" ++ name ++ ".*",+                                           "Par" ++ name ++ ".*",+----                                       "Layout" ++ name ++ ".*",+----                                       "Skel" ++ name ++ ".*",+----                                       "Print" ++ name ++ ".*",+                                           "Test" ++ name ++ ".*",+----                                       "Abs" ++ name ++ ".*",+                                           "Test" ++ name,+                                           "ErrM.*", ----                                       name ++ ".dtd",-----					   "XML" ++ name ++ ".*",-					   "Makefile*"-					  ]-		]+----                                       "XML" ++ name ++ ".*",+                                           "Makefile*"+                                          ]+                ]   testfile :: Bool -> String -> Bool -> CF -> String@@ -135,32 +132,33 @@   makeA = let lay = hasLayout cf          in unlines-	        ["-- automatically generated by BNF Converter",-		 "module Main where\n",-	         "",+                ["-- automatically generated by BNF Converter",+                 "module Main where\n",+                 "",                  "import Trees",                  "import Profile",-	         "import System.IO ( stdin, hGetContents )",-	         "import System.Environment ( getArgs, getProgName )",-		 "",-		 "import " ++ alexFileM     inDir name,-		 "import " ++ happyFileM    inDir name,-----		 "import " ++ templateFileM inDir name,-----	         "import " ++ printerFileM  inDir name,-----	         "import " ++ absFileM      inDir name,-----	         if lay then ("import " ++ layoutFileM inDir name) else "",-----	         if xml then ("import " ++ xmlFileM inDir name) else "",-	         "import " ++ errFileM      inDir name,-		 "",-		 "type ParseFun = [Token] -> Err CFTree",-	         "",+                 "import System.IO ( stdin, hGetContents )",+                 "import System.Environment ( getArgs, getProgName )",+                 "import System.Exit ( exitFailure )",+                 "",+                 "import " ++ alexFileM     inDir name,+                 "import " ++ happyFileM    inDir name,+----             "import " ++ templateFileM inDir name,+----             "import " ++ printerFileM  inDir name,+----             "import " ++ absFileM      inDir name,+----             if lay then ("import " ++ layoutFileM inDir name) else "",+----             if xml then ("import " ++ xmlFileM inDir name) else "",+                 "import " ++ errFileM      inDir name,+                 "",+                 "type ParseFun = [Token] -> Err CFTree",+                 "",                  "myLLexer = " ++ if lay then "resolveLayout True . myLexer"                                          else "myLexer",                  "",-		 "runFile :: ParseFun -> FilePath -> IO ()",-		 "runFile p f = readFile f >>= run p",-		 "",-		 "run :: ParseFun -> String -> IO ()",+                 "runFile :: ParseFun -> FilePath -> IO ()",+                 "runFile p f = readFile f >>= run p",+                 "",+                 "run :: ParseFun -> String -> IO ()",   "run p s = do",   "  let ts = myLLexer s",   "  let etree = p ts",@@ -178,13 +176,25 @@   "      putStrLn s",   "      putStrLn \"\\nParse failed... tokenization:\"",   "      print ts",-		 "",-		 "main :: IO ()",-		 "main = do args <- getArgs",-		 "          case args of",-		 "            []  -> hGetContents stdin >>= run " ++ firstParser,-		 "            [f] -> runFile " ++ firstParser ++ " f",-		 "            _   -> do progName <- getProgName",-		 "                      putStrLn $ progName ++ \": excess arguments.\""-		 ]-		  where firstParser = 'p' : show (firstEntry cf)+                 "",+                 "usage :: IO ()",+                 "usage = do",+                 "  putStrLn $ unlines",+                 "    [ \"usage: Call with one of the following argument combinations:\"",+                 "    , \"  --help          Display this help message.\"",+                 "    , \"  (no arguments)  Parse stdin.\"",+                 "    , \"  (file)          Parse content of file.\"",+                 "    ]",+                 "  exitFailure",+                 "",+                 "main :: IO ()",+                 "main = do",+                 "  args <- getArgs",+                 "  case args of",+                 "    [\"--help\"] -> usage",+                 "    []  -> hGetContents stdin >>= run " ++ firstParser,+                 "    [f] -> runFile " ++ firstParser ++ " f",+                 "    _   -> do progName <- getProgName",+                 "              putStrLn $ progName ++ \": excess arguments.\""+                 ]+                  where firstParser = 'p' : show (firstEntry cf)
src/BNFC/Backend/Java.hs view
@@ -52,80 +52,79 @@ import BNFC.Backend.Java.CFtoAbstractVisitor import BNFC.Backend.Java.CFtoFoldVisitor import BNFC.Backend.Java.CFtoAllVisitor-import Data.List(intersperse) import qualified BNFC.Backend.Common.Makefile as Makefile+import BNFC.PrettyPrint ------------------------------------------------------------------- -- | Build the Java output. -- FIXME: get everything to put the files in the right places. -- Adapt Makefile to do the business. ------------------------------------------------------------------- makeJava :: SharedOptions -> CF -> MkFiles ()-makeJava options cf =+makeJava options@Options{..} cf =     do -- Create the package directories if necessary.        let packageBase = case inPackage of-                             Nothing -> name-                             Just p -> p ++ "." ++ name-	   packageAbsyn = packageBase ++ "." ++ "Absyn"-	   dirBase = pkgToDir packageBase-	   dirAbsyn = pkgToDir packageAbsyn+                             Nothing -> lang+                             Just p -> p ++ "." ++ lang+           packageAbsyn = packageBase ++ "." ++ "Absyn"+           dirBase = pkgToDir packageBase+           dirAbsyn = pkgToDir packageAbsyn        let absynFiles = remDups $ cf2JavaAbs packageBase packageAbsyn cf-	   absynBaseNames = map fst absynFiles-	   absynFileNames = map (dirAbsyn ++) absynBaseNames+           absynBaseNames = map fst absynFiles+           absynFileNames = map (dirAbsyn ++) absynBaseNames        let writeAbsyn (filename, contents) =-	       mkfile (dirAbsyn ++ filename ++ ".java") contents-       mapM writeAbsyn absynFiles+               mkfile (dirAbsyn ++ filename ++ ".java") contents+       mapM_ writeAbsyn absynFiles        mkfile (dirBase ++ "PrettyPrinter.java") $ cf2JavaPrinter packageBase packageAbsyn cf        mkfile (dirBase ++ "VisitSkel.java") $ cf2VisitSkel packageBase packageAbsyn cf        mkfile (dirBase ++ "ComposVisitor.java") $ cf2ComposVisitor packageBase packageAbsyn cf        mkfile (dirBase ++ "AbstractVisitor.java") $ cf2AbstractVisitor packageBase packageAbsyn cf        mkfile (dirBase ++ "FoldVisitor.java") $ cf2FoldVisitor packageBase packageAbsyn cf        mkfile (dirBase ++ "AllVisitor.java") $ cf2AllVisitor packageBase packageAbsyn cf-       mkfile (dirBase ++ "Test.java") $ javaTest packageBase packageAbsyn cf+       mkfile (dirBase ++ "Test.java") $ render $ javaTest packageBase packageAbsyn cf ---       mkfile ("Test" ++ name) $ "java " ++ dirBase ++ "Test $(1)"-       let (lex, env) = cf2jlex packageBase packageAbsyn cf-       mkfile (dirBase ++ "Yylex") lex+       let (lex, env) = cf2jlex packageBase cf jflex+       mkfile (dirBase ++ "Yylex") (render lex)        liftIO $ putStrLn "   (Tested with JLex 1.2.6.)"-       mkfile (dirBase ++ name ++ ".cup") $ cf2Cup packageBase packageAbsyn cf env+       mkfile (dirBase ++ lang ++ ".cup") $ cf2Cup packageBase packageAbsyn cf env        -- FIXME: put in a doc directory?        liftIO $ putStrLn $ "   (Parser created for category " ++ show (firstEntry cf) ++ ")"        liftIO $ putStrLn "   (Tested with CUP 0.10k)"-       Makefile.mkMakefile options $ makefile name dirBase dirAbsyn absynFileNames+       Makefile.mkMakefile options $ makefile lang dirBase dirAbsyn absynFileNames jflex     where       remDups [] = []       remDups ((a,b):as) = case lookup a as of-			     Just {} -> remDups as-			     Nothing -> (a, b) : (remDups as)+                             Just {} -> remDups as+                             Nothing -> (a, b) : remDups as        pkgToDir :: String -> FilePath       pkgToDir s = replace '.' pathSeparator s ++ [pathSeparator]-      inPackage = Options.inPackage options-      name = Options.lang options  -- FIXME get filenames right. -- FIXME It's almost certainly better to just feed all the Java source -- files to javac in one go. -- Replace with an ANT script?-makefile :: String -> FilePath -> FilePath -> [String] -> String-makefile name dirBase dirAbsyn absynFileNames =-  (++) (unlines [ "JAVAC = javac",-                  "JAVAC_FLAGS = -sourcepath .", "",-                  "JAVA = java",-                  "JAVA_FLAGS =", "",-                  "CUP = java_cup.Main",-                  "CUPFLAGS = -nopositions -expect 100", "",-                  "JLEX = JLex.Main", "" ])+makefile :: String -> FilePath -> FilePath -> [String] -> Bool -> String+makefile name dirBase dirAbsyn absynFileNames jflex =+    Makefile.mkVar "JAVAC" "javac"+  $ Makefile.mkVar "JAVAC_FLAGS" "-sourcepath ."+  $ Makefile.mkVar "JAVA" "java"+  $ Makefile.mkVar "JAVA_FLAGS" ""+  $ Makefile.mkVar "CUP" "java_cup.Main"+  $ Makefile.mkVar "CUPFLAGS" "-nopositions -expect 100"+  $ (if jflex then Makefile.mkVar "JFLEX" "jflex"+              else Makefile.mkVar "JLEX" "JLex.Main" )   $ Makefile.mkRule "all" [ "test" ]     []-  $ Makefile.mkRule "test" ("absyn":(map (dirBase ++) [ "Yylex.class",-				                       "PrettyPrinter.class",-				                       "Test.class",+  $ Makefile.mkRule "test" ("absyn" : map (dirBase ++) [ "Yylex.class",+                                                       "PrettyPrinter.class",+                                                       "Test.class",                                                        "ComposVisitor.class",                                                        "AbstractVisitor.class",                                                        "FoldVisitor.class",                                                        "AllVisitor.class",-				                       "parser.class",-				                       "sym.class",-				                       "Test.class"]))+                                                       "parser.class",+                                                       "sym.class",+                                                       "Test.class"])     []   $ Makefile.mkRule ".PHONY" ["absyn"]     []@@ -134,7 +133,7 @@   $ Makefile.mkRule "absyn" [absynJavaSrc]     [ "${JAVAC} ${JAVAC_FLAGS} $^" ]   $ Makefile.mkRule (dirBase ++ "Yylex.java") [ dirBase ++ "Yylex" ]-    [ "${JAVA} ${JAVA_FLAGS} ${JLEX} " ++ dirBase ++ "Yylex" ]+    [ (if jflex then "${JFLEX} " else "${JAVA} ${JAVA_FLAGS} ${JLEX} ") ++ dirBase ++ "Yylex" ]   $ Makefile.mkRule (dirBase ++ "sym.java " ++ dirBase ++ "parser.java")                     [ dirBase ++ name ++ ".cup" ]     [ "${JAVA} ${JAVA_FLAGS} ${CUP} ${CUPFLAGS} " ++ dirBase ++ name ++ ".cup"@@ -152,8 +151,7 @@     [] -- FIXME   $ Makefile.mkRule "clean" []-    [ "rm -f " ++ dirAbsyn ++ "*.class" ++ " " ++ dirBase ++ "*.class"-    , "rm -f " ++ ".dvi " ++ name ++ ".aux " ++ name ++ ".log " ++ name ++ ".ps " ++ " *.class" ]+    [ "rm -f " ++ dirAbsyn ++ "*.class" ++ " " ++ dirBase ++ "*.class" ]   $ Makefile.mkRule "distclean" [ "vclean" ]     []   $ Makefile.mkRule "vclean" []@@ -162,84 +160,80 @@ --     , "rm -f " ++ "Test" ++ name     , " rmdir " ++ dirAbsyn     , " rm -f " ++ unwords (map (dirBase ++) [-					        "Yylex",-						name ++ ".cup",-						"Yylex.java",-						"VisitSkel.java",+                                                "Yylex",+                                                name ++ ".cup",+                                                "Yylex.java",+                                                "VisitSkel.java",                                                 "ComposVisitor.java",                                                 "AbstractVisitor.java",                                                 "FoldVisitor.java",                                                 "AllVisitor.java",-						"PrettyPrinter.java",-						"Skeleton.java",-						"Test.java",-						"sym.java",-						"parser.java",-						"*.class"])+                                                "PrettyPrinter.java",+                                                "Skeleton.java",+                                                "Test.java",+                                                "sym.java",+                                                "parser.java",+                                                "*.class"])     , "rm -f Makefile"     , "rmdir -p " ++ dirBase ]   ""     where absynJavaSrc = unwords (map (++ ".java") absynFileNames)-	  absynJavaClass = unwords (map (++ ".class") absynFileNames)+          absynJavaClass = unwords (map (++ ".class") absynFileNames) -javaTest :: String -> String -> CF -> String-javaTest packageBase packageAbsyn cf =-    unlines-    [-     "package" +++ packageBase ++ ";",-     "import java_cup.runtime.*;",-     "import" +++ packageBase ++ ".*;",-     "import" +++ packageAbsyn ++ ".*;",-     "import java.io.*;",-     "",-     "public class Test",-     "{",-     "  public static void main(String args[]) throws Exception",-     "  {",-     "    Yylex l = null;",-     "    parser p;",-     "    try",-     "    {",-     "      if (args.length == 0) l = new Yylex(System.in);",-     "      else l = new Yylex(new FileReader(args[0]));",-     "    }",-     "    catch(FileNotFoundException e)",-     "    {",-     "     System.err.println(\"Error: File not found: \" + args[0]);",-     "     System.exit(1);",-     "    }",-     "    p = new parser(l);",-     "    /* The default parser is the first-defined entry point. */",-     "    /* You may want to change this. Other options are: */",-     "    /* " ++ (concat (intersperse ", " (showOpts (tail eps)))) ++ " */",-     "    try",-     "    {",-     "      " ++ packageAbsyn ++ "." ++ show def +++ "parse_tree = p.p"-     ++ show def ++ "();",-     "      System.out.println();",-     "      System.out.println(\"Parse Succesful!\");",-     "      System.out.println();",-     "      System.out.println(\"[Abstract Syntax]\");",-     "      System.out.println();",-     "      System.out.println(PrettyPrinter.show(parse_tree));",-     "      System.out.println();",-     "      System.out.println(\"[Linearized Tree]\");",-     "      System.out.println();",-     "      System.out.println(PrettyPrinter.print(parse_tree));",-     "    }",-     "    catch(Throwable e)",-     "    {",-     "      System.err.println(\"At line \" + String.valueOf(l.line_num()) + \", near \\\"\" + l.buff() + \"\\\" :\");",-     "      System.err.println(\"     \" + e.getMessage());",-     "      System.exit(1);",-     "    }",-     "  }",-     "}"+javaTest :: String -> String -> CF -> Doc+javaTest packageBase packageAbsyn cf = vcat+    [ "package" <+> text packageBase <> ";"+    , "import java_cup.runtime.*;"+    , "import" <+> text packageBase <> ".*;"+    , "import" <+> text packageAbsyn <> ".*;"+    , "import java.io.*;"+    , ""+    , "public class Test"+    , codeblock 2+        [ "public static void main(String args[]) throws Exception"+        , codeblock 2+            [ "Yylex l = null;"+            , "parser p;"+            , "try"+            , codeblock 2+                [ "if (args.length == 0) l = new Yylex(new InputStreamReader(System.in));"+                , "else l = new Yylex(new FileReader(args[0]));" ]+            , "catch(FileNotFoundException e)"+            , "{"+            , " System.err.println(\"Error: File not found: \" + args[0]);"+            , " System.exit(1);"+            , "}"+            , "p = new parser(l);"+            , "/* The default parser is the first-defined entry point. */"+            , "/* You may want to change this. Other options are: */"+            , "/* " <> fsep (punctuate "," (showOpts (tail eps))) <> " */"+            , "try"+            , "{"+            , "  " <> text packageAbsyn <> "." <> text (show def) <+> "parse_tree = p.p"+             <> text (show def) <> "();"+            , "  System.out.println();"+            , "  System.out.println(\"Parse Succesful!\");"+            , "  System.out.println();"+            , "  System.out.println(\"[Abstract Syntax]\");"+            , "  System.out.println();"+            , "  System.out.println(PrettyPrinter.show(parse_tree));"+            , "  System.out.println();"+            , "  System.out.println(\"[Linearized Tree]\");"+            , "  System.out.println();"+            , "  System.out.println(PrettyPrinter.print(parse_tree));"+            , "}"+            , "catch(Throwable e)"+            , "{"+            , "  System.err.println(\"At line \" + String.valueOf(l.line_num()) + \", near \\\"\" + l.buff() + \"\\\" :\");"+            , "  System.err.println(\"     \" + e.getMessage());"+            , "  System.exit(1);"+            , "}"+            ]+        ]     ]-    where eps = allEntryPoints cf-	  def = head eps-	  showOpts [] = []--	  showOpts (x:[]) = if normCat x /= x then [] else ['p' : (identCat x)]-	  showOpts (x:xs) = if normCat x /= x then (showOpts xs)-			    else ('p' : (identCat x)) : (showOpts xs)+  where+    eps = allEntryPoints cf+    def = head eps+    showOpts [] = []+    showOpts (x:xs) | normCat x /= x = showOpts xs+                    | otherwise      = text ('p' : identCat x) : showOpts xs
src/BNFC/Backend/Java/CFtoComposVisitor.hs view
@@ -25,6 +25,8 @@ import BNFC.Utils ((+++)) import BNFC.Backend.Common.NamedVariables import Data.List+import Data.Either (lefts)+import BNFC.PrettyPrint  cf2ComposVisitor :: String -> String -> CF -> String cf2ComposVisitor packageBase packageAbsyn cf =@@ -53,58 +55,65 @@     q ++ ".Visitor<" ++ q ++ ",A>"   where q = packageAbsyn ++ "." ++ identCat cat -commaList :: [String] -> String-commaList = concat . intersperse ", "- --Traverses a category based on its type. prData :: String -> [UserDef] -> (Cat, [Rule]) -> String prData packageAbsyn user (cat, rules) =     unlines [              "/* " ++ identCat cat ++ " */",-	     concatMap (prRule packageAbsyn user cat) rules+	     concatMap (render . prRule packageAbsyn user cat) rules 	    ]---traverses a standard rule.-prRule :: String -> [UserDef] -> Cat -> Rule -> String+-- | traverses a standard rule.+-- >>> prRule "lang.absyn" [Cat "A"] (Cat "B") (Rule "F" (Cat "B") [Left (Cat "A"), Right "+", Left (ListCat (Cat "B"))])+--     public B visit(lang.absyn.F p, A arg)+--     {+--       String a_ = p.a_;+--       ListB listb_ = new ListB();+--       for (B x : p.listb_)+--       {+--         listb_.add(x.accept(this,arg));+--       }+--       return new lang.absyn.F(a_, listb_);+--     }+prRule :: String -> [UserDef] -> Cat -> Rule -> Doc prRule packageAbsyn user cat (Rule fun _ cats)-    | not (isCoercion fun || isDefinedRule fun) = unlines-  [-   "    public " ++ identCat cat ++ " visit(" ++ cls ++ " p, A arg)",-   "    {",-   unlines (map ("      "++) visitVars),-   "      return new " ++ cls ++ "(" ++ commaList children ++ ");",-   "    }"-  ]-   where-    cats' = if allTerms cats-        then []-    	else [ (c,v) |-	       (Left c, Left v) <- zip cats (fixOnes (numVars [] cats)), c /= InternalCat ]-    cls = packageAbsyn ++ "." ++ fun-    allTerms [] = True-    allTerms (Left _:_) = False-    allTerms (_:zs) = allTerms zs-    children = map snd cats'-    visitVars = concatMap (uncurry (prCat user)) cats'+  | not (isCoercion fun || isDefinedRule fun) = nest 4 $ vcat+    [ "public " <> text(identCat cat) <> " visit(" <> cls <> " p, A arg)"+    , codeblock 2+        [ vcat (map (prCat user) cats')+        , "return new" <+> cls <> parens (hsep (punctuate "," vnames)) <> ";" ] ]+  where+    cats' = filter ((/= InternalCat) . fst) (lefts (numVars cats))+    cls = text (packageAbsyn ++ "." ++ fun)+    vnames = map snd cats' prRule  _ _ _ _ = "" ---Traverses a class's instance variables.-prCat :: [UserDef]-      -> Cat       -- ^ Variable category-      -> String    -- ^ Variable name-      -> [String]  -- ^ Code for visiting the variable-prCat user cat nt-    | isBasicType user varType || (isList cat && isBasicType user et) = [decl var]-    | isList cat = listAccept-    | otherwise = [decl (var ++ ".accept(this, arg)")]-      where-      var = "p." ++ nt+-- | Traverses a class's instance variables.+-- >>> prCat [Cat "A"] (Cat "A", "a_")+-- String a_ = p.a_;+-- >>> prCat [] (ListCat (Cat "Integer"), "listinteger_")+-- ListInteger listinteger_ = p.listinteger_;+-- >>> prCat [] (ListCat (Cat "N"), "listn_")+-- ListN listn_ = new ListN();+-- for (N x : p.listn_)+-- {+--   listn_.add(x.accept(this,arg));+-- }+-- >>> prCat [] (Cat "N", "n_")+-- N n_ = p.n_.accept(this, arg);+prCat :: [UserDef]  -- ^ User defined token categories+      -> (Cat, Doc) -- ^ Variable category and names+      -> Doc        -- ^ Code for visiting the variable+prCat user (cat, nt)+  | isBasicType user varType || (isList cat && isBasicType user et) = decl var+  | isList cat = decl ("new" <+> text varType <> "()")+              $$ "for (" <> text et <> " x : " <> var <> ")"+              $$ codeblock 2 [ nt <> ".add(x.accept(this,arg));" ]+  | otherwise = decl (var <> ".accept(this, arg)")+  where+      var = "p." <> nt       varType = typename (identCat (normCat cat)) user       et = typename (show$normCatOfList cat) user-      decl v = varType +++ nt +++ "=" +++ v ++ ";"-      listAccept = [decl ("new"+++varType++"()"),-                    "for (" ++ et ++ " x : " ++ var ++ ") {",-                    "  " ++ nt ++ ".add(x.accept(this,arg));",-	            "}"]+      decl v = text varType <+> nt <+> "=" <+> v <> ";"  --Just checks if something is a basic or user-defined type. isBasicType :: [UserDef] -> String -> Bool
src/BNFC/Backend/Java/CFtoCup15.hs view
@@ -40,11 +40,11 @@ module BNFC.Backend.Java.CFtoCup15 ( cf2Cup ) where  import BNFC.CF-import Data.List (intersperse)+import Data.List import BNFC.Backend.Common.NamedVariables import BNFC.Utils ( (+++) ) import BNFC.TypeChecker  -- We need to (re-)typecheck to figure out list instances in-		    -- defined rules.+                    -- defined rules. import ErrM  import Data.Char@@ -71,80 +71,80 @@       header :: String       header = unlines          ["// -*- Java -*- This Cup file was machine-generated by BNFC",-	  "package" +++ packageBase ++ ";",-	  "",-	  "parser code {:",-	  parseMethod packageAbsyn (firstEntry cf),+          "package" +++ packageBase ++ ";",+          "",+          "parser code {:",+          parseMethod packageAbsyn (firstEntry cf),           "public <B,A extends java.util.LinkedList<? super B>> A cons_(B x, A xs) { xs.addFirst(x); return xs; }",-	  definedRules packageAbsyn cf,-	  -- unlines $ map (parseMethod packageAbsyn) (allEntryPoints cf),-	  "public void syntax_error(java_cup.runtime.Symbol cur_token)",-  	  "{",-    	  "\treport_error(\"Syntax Error, trying to recover and continue parse...\", cur_token);",-	  "}",-	  "",- 	  "public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception",- 	  "{",+          definedRules packageAbsyn cf,+          -- unlines $ map (parseMethod packageAbsyn) (allEntryPoints cf),+          "public void syntax_error(java_cup.runtime.Symbol cur_token)",+          "{",+          "\treport_error(\"Syntax Error, trying to recover and continue parse...\", cur_token);",+          "}",+          "",+          "public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception",+          "{",           "\tthrow new Exception(\"Unrecoverable Syntax Error\");",           "}",-	  "",-	  ":}"-	  ]+          "",+          ":}"+          ]  definedRules :: String -> CF -> String definedRules packageAbsyn cf =-	unlines [ rule f xs e | FunDef f xs e <- pragmasOfCF cf ]+        unlines [ rule f xs e | FunDef f xs e <- pragmasOfCF cf ]     where-	ctx = buildContext cf+        ctx = buildContext cf -	list = LC (\t -> "List" ++ unBase t) (const "cons")-	    where-		unBase (ListT t) = unBase t-		unBase (BaseT x) = show$normCat$strToCat x+        list = LC (\t -> "List" ++ unBase t) (const "cons")+            where+                unBase (ListT t) = unBase t+                unBase (BaseT x) = show$normCat$strToCat x -	rule f xs e =-	    case checkDefinition' list ctx f xs e of-		Bad err	-> error $ "Panic! This should have been caught already:\n" ++ err-		Ok (args,(e',t)) -> unlines-		    [ "public " ++ javaType t ++ " " ++ f ++ "_ (" ++-			concat (intersperse ", " $ map javaArg args) ++ ") {"-		    , "  return " ++ javaExp e' ++ ";"-		    , "}"-		    ]-	    where+        rule f xs e =+            case checkDefinition' list ctx f xs e of+                Bad err -> error $ "Panic! This should have been caught already:\n" ++ err+                Ok (args,(e',t)) -> unlines+                    [ "public " ++ javaType t ++ " " ++ f ++ "_ (" +++                        intercalate ", " (map javaArg args) ++ ") {"+                    , "  return " ++ javaExp e' ++ ";"+                    , "}"+                    ]+            where -		javaType :: Base -> String-		javaType (ListT (BaseT x)) = packageAbsyn ++ ".List" ++ (show$normCat$strToCat x)-		javaType (ListT t)	   = javaType t-		javaType (BaseT x)-		    | isToken x ctx = "String"-		    | otherwise	    = packageAbsyn ++ "." ++ (show$normCat$strToCat x)+                javaType :: Base -> String+                javaType (ListT (BaseT x)) = packageAbsyn ++ ".List" ++ show (normCat$strToCat x)+                javaType (ListT t)         = javaType t+                javaType (BaseT x)+                    | isToken x ctx = "String"+                    | otherwise     = packageAbsyn ++ "." ++ show (normCat$strToCat x) -		javaArg :: (String, Base) -> String-		javaArg (x,t) = javaType t ++ " " ++ x ++ "_"+                javaArg :: (String, Base) -> String+                javaArg (x,t) = javaType t ++ " " ++ x ++ "_" -		javaExp :: Exp -> String-		javaExp (App "null" []) = "null"-		javaExp (App x [])-		    | elem x xs		= x ++ "_"	-- argument-		javaExp (App t [e])-		    | isToken t ctx	= call ("new String") [e]-		javaExp (App x es)-		    | isUpper (head x)	= call ("new " ++ packageAbsyn ++ "." ++ x) es-		    | otherwise		= call (x ++ "_") es-		javaExp (LitInt n)	= "new Integer(" ++ show n ++ ")"-		javaExp (LitDouble x)	= "new Double(" ++ show x ++ ")"-		javaExp (LitChar c)	= "new Character(" ++ show c ++ ")"-		javaExp (LitString s)	= "new String(" ++ show s ++ ")"+                javaExp :: Exp -> String+                javaExp (App "null" []) = "null"+                javaExp (App x [])+                    | x `elem` xs       = x ++ "_"      -- argument+                javaExp (App t [e])+                    | isToken t ctx     = call "new String" [e]+                javaExp (App x es)+                    | isUpper (head x)  = call ("new " ++ packageAbsyn ++ "." ++ x) es+                    | otherwise         = call (x ++ "_") es+                javaExp (LitInt n)      = "new Integer(" ++ show n ++ ")"+                javaExp (LitDouble x)   = "new Double(" ++ show x ++ ")"+                javaExp (LitChar c)     = "new Character(" ++ show c ++ ")"+                javaExp (LitString s)   = "new String(" ++ show s ++ ")" -		call x es = x ++ "(" ++ concat (intersperse ", " $ map javaExp es) ++ ")"+                call x es = x ++ "(" ++ intercalate ", " (map javaExp es) ++ ")"   -- peteg: FIXME JavaCUP can only cope with one entry point AFAIK. prEntryPoint :: CF -> String prEntryPoint cf = unlines ["", "start with " ++ show (firstEntry cf) ++ ";", ""]---		    [ep]  -> unlines ["", "start with " ++ ep ++ ";", ""]---		    eps   -> error $ "FIXME multiple entry points." ++ show eps+--                  [ep]  -> unlines ["", "start with " ++ ep ++ ";", ""]+--                  eps   -> error $ "FIXME multiple entry points." ++ show eps  --This generates a parser method for each entry point. parseMethod :: String -> Cat -> String@@ -152,14 +152,14 @@   if normCat cat /= cat     then ""     else unlines-	     [-	      "  public" +++ packageAbsyn ++ "." ++ cat' +++ "p" ++ cat' ++ "()"-	        ++ " throws Exception",-	      "  {",-	      "\tjava_cup.runtime.Symbol res = parse();",-	      "\treturn (" ++ packageAbsyn ++ "." ++ cat' ++ ") res.value;",-	      "  }"-	     ]+             [+              "  public" +++ packageAbsyn ++ "." ++ cat' +++ "p" ++ cat' ++ "()"+                ++ " throws Exception",+              "  {",+              "\tjava_cup.runtime.Symbol res = parse();",+              "\treturn (" ++ packageAbsyn ++ "." ++ cat' ++ ") res.value;",+              "  }"+             ]     where cat' = identCat (normCat cat)  --non-terminal types@@ -167,7 +167,7 @@ declarations packageAbsyn ns = unlines (map (typeNT packageAbsyn) ns)  where    typeNT _nm nt = "nonterminal" +++ packageAbsyn ++ "."-		    ++ identCat (normCat nt) +++ identCat nt ++ ";"+                    ++ identCat (normCat nt) +++ identCat nt ++ ";"  --terminal types tokens :: SymEnv -> String@@ -215,19 +215,19 @@  -- Generates a string containing the semantic action. generateAction :: String -> NonTerminal -> Fun -> [MetaVar]-	       -> Bool   -- ^ Whether the list should be reversed or not.-		         --   Only used if this is a list rule.-	       -> Action+               -> Bool   -- ^ Whether the list should be reversed or not.+                         --   Only used if this is a list rule.+               -> Action generateAction packageAbsyn nt f ms rev     | isNilFun f = "RESULT = new " ++ c ++ "();"     | isOneFun f = "RESULT = new " ++ c ++ "(); RESULT.addLast(" ++ p_1 ++ ");"     | isConsFun f = "RESULT = " ++ p_2 ++ "; "-			   ++ p_2 ++ "." ++ add ++ "(" ++ p_1 ++ ");"+                           ++ p_2 ++ "." ++ add ++ "(" ++ p_1 ++ ");"     | isCoercion f = "RESULT = " ++ p_1 ++ ";"     | isDefinedRule f = "RESULT = parser." ++ f ++ "_"-                        ++ "(" ++ concat (intersperse "," ms) ++ ");"+                        ++ "(" ++ intercalate "," ms ++ ");"     | otherwise = "RESULT = new " ++ c-		  ++ "(" ++ concat (intersperse "," ms) ++ ");"+                  ++ "(" ++ intercalate "," ms ++ ");"    where      c = packageAbsyn ++ "." ++            if isNilFun f || isOneFun f || isConsFun f@@ -252,11 +252,11 @@         Left c -> c' ++ ":p_" ++ show (n :: Int) +++ mkIt (n+1) is           where               c' = case c of-                  Cat "Ident"   -> "_IDENT_"-                  Cat "Integer" -> "_INTEGER_"-                  Cat "Char"    -> "_CHAR_"-                  Cat "Double"  -> "_DOUBLE_"-                  Cat "String"  -> "_STRING_"+                  TokenCat "Ident"   -> "_IDENT_"+                  TokenCat "Integer" -> "_INTEGER_"+                  TokenCat "Char"    -> "_CHAR_"+                  TokenCat "Double"  -> "_DOUBLE_"+                  TokenCat "String"  -> "_STRING_"                   _         -> identCat c         Right s -> case lookup s env of             (Just x) -> x +++ mkIt (n+1) is@@ -269,9 +269,9 @@ prRules [] = [] prRules ((_, []):rs) = prRules rs --internal rule prRules ((nt,(p,a):ls):rs) =-  unwords [nt', "::=", p, "{:", a, ":}", "\n" ++ pr ls] ++ ";\n" ++ prRules rs+  unwords [nt', "::=", p, "{:", a, ":}", '\n' : pr ls] ++ ";\n" ++ prRules rs  where   nt' = identCat nt   pr []           = []-  pr ((p,a):ls)   = (unlines [(concat $ intersperse " " ["  |", p, "{:", a , ":}"])]) ++ pr ls+  pr ((p,a):ls)   = unlines [unwords ["  |", p, "{:", a , ":}"]] ++ pr ls 
src/BNFC/Backend/Java/CFtoFoldVisitor.hs view
@@ -24,6 +24,8 @@ import BNFC.Backend.Java.CFtoJavaAbs15 (typename) import BNFC.Utils ((+++)) import BNFC.Backend.Common.NamedVariables+import Data.Either (lefts)+import BNFC.PrettyPrint  cf2FoldVisitor :: String -> String -> CF -> String cf2FoldVisitor packageBase packageAbsyn cf =@@ -64,33 +66,36 @@   ++ ["      return r;",       "    }"]    where-    cats' = if allTerms cats-        then []-    	else [ (c,v) |-	       (Left c, Left v) <- zip cats (fixOnes (numVars [] cats)), c /= InternalCat ]+    cats' = filter ((/= InternalCat) . fst) (lefts (numVars cats))     cls = packageAbsyn ++ "." ++ fun-    allTerms [] = True-    allTerms (Left _:_) = False-    allTerms (_:zs) = allTerms zs-    visitVars = concatMap (uncurry (prCat user)) cats'+    visitVars = lines $ render $ vcat $ map (prCat user) cats' prRule  _ _ _ _ = "" ---Traverses a class's instance variables.+-- | Traverses a class's instance variables.+-- >>> prCat [Cat "A"] (Cat "A", "a_")+-- <BLANKLINE>+-- >>> prCat [] (ListCat (Cat "Integer"), "listinteger_")+-- <BLANKLINE>+-- >>> prCat [] (ListCat (Cat "N"), "listn_")+-- for (N x : p.listn_)+-- {+--   r = combine(x.accept(this, arg), r, arg);+-- }+-- >>> prCat [] (Cat "N", "n_")+-- r = combine(p.n_.accept(this, arg), r, arg); prCat :: [UserDef]-      -> Cat       -- ^ Variable category-      -> String    -- ^ Variable name-      -> [String]  -- ^ Code for visiting the variable-prCat user cat nt-    | isBasicType user varType || (isList cat && isBasicType user et) = []-    | isList cat = listAccept-    | otherwise = ["r = combine(" ++ var ++ ".accept(this, arg), r, arg);"]+      -> (Cat, Doc) -- ^ Variable category and name+      -> Doc        -- ^ Code for visiting the variable+prCat user (cat,nt)+    | isBasicType user varType || (isList cat && isBasicType user et) = empty+    | isList cat = vcat+        [ "for (" <> text et <> " x : " <> var <> ")"+        , codeblock 2 [ "r = combine(x.accept(this, arg), r, arg);" ] ]+    | otherwise = "r = combine(" <> var <> ".accept(this, arg), r, arg);"       where-      var = "p." ++ nt+      var = "p." <> nt       varType = typename (identCat (normCat cat)) user-      et = typename (show$normCatOfList cat) user-      listAccept = ["for (" ++ et ++ " x : " ++ var ++ ") {",-                    "  r = combine(x.accept(this,arg), r, arg);",-	            "}"]+      et      = typename (show$normCatOfList cat) user  --Just checks if something is a basic or user-defined type. isBasicType :: [UserDef] -> String -> Bool
src/BNFC/Backend/Java/CFtoJLex15.hs view
@@ -41,46 +41,53 @@  import BNFC.CF import BNFC.Backend.Java.RegToJLex-import BNFC.Utils		( (+++) )+import BNFC.Utils ( (+++) ) import BNFC.Backend.Common.NamedVariables+import Text.PrettyPrint  --The environment must be returned for the parser to use.-cf2jlex :: String -> String -> CF -> (String, SymEnv)-cf2jlex packageBase packageAbsyn cf = (unlines $ concat $+cf2jlex :: String -> CF -> Bool -> (Doc, SymEnv)+cf2jlex packageBase cf jflex = (vcat  [-  prelude packageBase packageAbsyn,+  prelude jflex packageBase,   cMacros,-  lexSymbols env,-  restOfJLex cf+  lexSymbols jflex env,+  text $ unlines $ restOfJLex cf  ], env)   where    env = makeSymEnv (symbols cf ++ reservedWords cf) (0 :: Int)    makeSymEnv [] _ = []-   makeSymEnv (s:symbs) n = (s, "_SYMB_" ++ (show n)) : (makeSymEnv symbs (n+1))+   makeSymEnv (s:symbs) n = (s, "_SYMB_" ++ show n) : makeSymEnv symbs (n+1) -prelude :: String -> String -> [String]-prelude packageBase _ =-    [-     "// This JLex file was machine-generated by the BNF converter",-     "package" +++ packageBase ++ ";",-     "",-     "import java_cup.runtime.*;",-     "%%",-     "%cup",-     "%unicode",-     "%line",-     "%public",-     "%{",-     "  String pstring = new String();",-     "  public int line_num() { return (yyline+1); }",-     "  public String buff() { return new String(yy_buffer,yy_buffer_index,10).trim(); }",-     "%}"++-- | File prelude+prelude :: Bool -> String -> Doc+prelude jflex packageBase = vcat+    [ "// This JLex file was machine-generated by the BNF converter"+    , "package" <+> text packageBase <> ";"+    , ""+    , "import java_cup.runtime.*;"+    , "%%"+    , "%cup"+    , "%unicode"+    , "%line"+    , "%public"+    , "%{"+    , nest 2 $ vcat+        [ "String pstring = new String();"+        , "public int line_num() { return (yyline+1); }"+        , "public String buff()" <+> braces+            (if jflex+            then "return new String(zzBuffer,zzCurrentPos,10).trim();"+            else "return new String(yy_buffer,yy_buffer_index,10).trim();")+        ]+    , "%}"     ]  --For now all categories are included. --Optimally only the ones that are used should be generated.-cMacros :: [String]-cMacros = [+cMacros :: Doc+cMacros = vcat [   "LETTER = ({CAPITAL}|{SMALL})",   "CAPITAL = [A-Z\\xC0-\\xD6\\xD8-\\xDE]",   "SMALL = [a-z\\xDF-\\xF6\\xF8-\\xFF]",@@ -95,12 +102,26 @@   "%%"   ] -lexSymbols :: SymEnv -> [String]-lexSymbols ss = map transSym ss+-- |+-- >>> lexSymbols False [("foo","bar")]+-- <YYINITIAL>foo { return new Symbol(sym.bar); }+-- >>> lexSymbols False [("\\","bar")]+-- <YYINITIAL>\\ { return new Symbol(sym.bar); }+-- >>> lexSymbols False [("/","bar")]+-- <YYINITIAL>/ { return new Symbol(sym.bar); }+-- >>> lexSymbols True [("/","bar")]+-- <YYINITIAL>\/ { return new Symbol(sym.bar); }+-- >>> lexSymbols True [("~","bar")]+-- <YYINITIAL>\~ { return new Symbol(sym.bar); }+lexSymbols :: Bool -> SymEnv -> Doc+lexSymbols jflex ss = vcat $  map transSym ss   where     transSym (s,r) =-      "<YYINITIAL>" ++ (escapeChars s) ++ " { return new Symbol(sym."-      ++ r ++ "); }"+      "<YYINITIAL>" <> text (escapeChars s) <> " { return new Symbol(sym."+      <> text r <> "); }"+    --Helper function that escapes characters in strings+    escapeChars :: String -> String+    escapeChars = concatMap (escapeChar jflex)  restOfJLex :: CF -> [String] restOfJLex cf =@@ -169,6 +190,3 @@ -- lexReserved :: String -> String -- lexReserved s = "<YYINITIAL>\"" ++ s ++ "\" { return new Symbol(sym.TS, yytext()); }" ---Helper function that escapes characters in strings-escapeChars :: String -> String-escapeChars = concatMap escapeChar
src/BNFC/Backend/Java/CFtoJavaAbs15.hs view
@@ -52,7 +52,7 @@ import Data.Function (on) import Data.List import Data.Char(toLower)-import Data.Maybe(catMaybes)+import Data.Maybe (mapMaybe) import Text.PrettyPrint  --Produces abstract data types in Java.@@ -72,34 +72,34 @@  where   header = "package " ++ packageAbsyn ++ "; // Java Package generated by the BNF Converter.\n"   user = [n | (n,_) <- tokenPragmas cf]-  rules = [ (normCat c,fs) | (c,fs) <- cf2dataLists cf]+  rules = getAbstractSyntax cf  --Generates a (possibly abstract) category class, and classes for all its rules. prData :: String -> String -> [UserDef] -> Data ->[(String, String)] prData header packageAbsyn user (cat, rules) =-  categoryClass ++ (catMaybes $ map (prRule header packageAbsyn funs user cat) rules)+  categoryClass ++ mapMaybe (prRule header packageAbsyn funs user cat) rules       where       funs = map fst rules       categoryClass-	  | show cat `elem` funs = [] -- the catgory is also a function, skip abstract class-	  | otherwise = [(identCat cat, header ++++-			 unlines [-				  "public abstract class" +++ cls+          | show cat `elem` funs = [] -- the catgory is also a function, skip abstract class+          | otherwise = [(identCat cat, header +++++                         unlines [+                                  "public abstract class" +++ cls                                     +++ "implements java.io.Serializable {",-				  "  public abstract <R,A> R accept("-				  ++ cls ++ ".Visitor<R,A> v, A arg);",-				  prVisitor packageAbsyn funs,-				  "}"-				 ])]+                                  "  public abstract <R,A> R accept("+                                  ++ cls ++ ".Visitor<R,A> v, A arg);",+                                  prVisitor packageAbsyn funs,+                                  "}"+                                 ])]                 where cls = identCat cat  prVisitor :: String -> [String] -> String prVisitor packageAbsyn funs =     unlines [-	     "  public interface Visitor <R,A> {",-	     unlines (map prVisitFun funs),-	     "  }"-	    ]+             "  public interface Visitor <R,A> {",+             unlines (map prVisitFun funs),+             "  }"+            ]     where     prVisitFun f = "    public R visit(" ++ packageAbsyn ++ "." ++ f ++ " p, A arg);" @@ -108,18 +108,16 @@        -> String   -- ^ Abstract syntax package name        -> [String] -- ^ Names of all constructors in the category        -> [UserDef] -> Cat -> (Fun, [Cat]) -> Maybe (String, String)-prRule h packageAbsyn funs user c (fun, cats) =-    if isNilFun fun || isOneFun fun-    then Nothing  --these are not represented in the AbSyn-    else if isConsFun fun-    then Just $ (fun', --this is the linked list case.+prRule h packageAbsyn funs user c (fun, cats)+  | isNilFun fun || isOneFun fun = Nothing  --these are not represented in the AbSyn+  | isConsFun fun =Just (fun', --this is the linked list case.     unlines     [      h,      "public class" +++ fun' +++ "extends java.util.LinkedList<"++ et ++"> {",      "}"     ])-    else Just $ (fun, --a standard rule+  | otherwise = Just (fun, --a standard rule     unlines     [      h,@@ -138,14 +136,14 @@      fun' = identCat (normCat c)      isAlsoCategory = fun == show c      --This handles the case where a LBNF label is the same as the category.-     ext = if isAlsoCategory then "" else " extends" +++ (identCat c)+     ext = if isAlsoCategory then "" else " extends" +++ identCat c      et = typename (show $ normCatOfList c) user   --The standard accept function for the Visitor pattern prAccept :: String -> Cat -> String -> String prAccept pack cat _ = "\n  public <R,A> R accept(" ++ pack ++ "." ++ show cat-		      ++ ".Visitor<R,A> v, A arg) { return v.visit(this, arg); }\n"+                      ++ ".Visitor<R,A> v, A arg) { return v.visit(this, arg); }\n"  -- Creates the equals() method. prEquals :: String -> String -> [IVar] -> String@@ -162,7 +160,7 @@                               "}"]   where   fqn = pack++"."++fun-  checkKids = concat $ intersperse " && " $ map checkKid vs+  checkKids = intercalate " && " $ map checkKid vs   checkKid iv = "this." ++ v ++ ".equals(x." ++ v ++ ")"       where v = render (iVarName iv) @@ -177,8 +175,7 @@   aPrime = 37   hashKids [] = show aPrime   hashKids (v:vs) = hashKids_ (hashKid v) vs-  hashKids_ r [] = r-  hashKids_ r (v:vs) = hashKids_ (show aPrime ++ "*" ++ "(" ++ r ++ ")+" ++ hashKid v) vs+  hashKids_ = foldl (\r v -> show aPrime ++ "*" ++ "(" ++ r ++ ")+" ++ hashKid v)   hashKid iv = "this." ++ render (iVarName iv) ++ ".hashCode()"  @@ -229,8 +226,8 @@ --Prints the parameters to the constructors. prParams :: [Cat] -> [UserDef] -> Int -> Int -> [(String,String)] prParams [] _ _ _ = []-prParams (c:cs) u n m = (typename (identCat c) u,"p" ++ (show (m-n)))-			: (prParams cs u (n-1) m)+prParams (c:cs) u n m = (typename (identCat c) u, 'p' : show (m-n))+                        : prParams cs u (n-1) m  --This algorithm peeks ahead in the list so we don't use map or fold prAssigns :: [IVar] -> [String] -> String@@ -256,16 +253,12 @@                                then 0 else n]  varName :: String -- ^ category name-	-> String -- ^ Variable name-varName c = (map toLower c) ++ "_"+        -> String -- ^ Variable name+varName c = map toLower c ++ "_"  --This makes up for the fact that there's no typedef in Java typename :: String -> [UserDef] -> String-typename t user =- if t == "Ident"-  then "String"-  else if t == "Char"-  then "Character"-  else if elem t (map show user)-  then "String"-  else t+typename t user | t == "Ident"            = "String"+                | t == "Char"             = "Character"+                | t `elem` map show user  = "String"+                | otherwise               = t
src/BNFC/Backend/Java/CFtoJavaPrinter15.hs view
@@ -49,10 +49,13 @@ import BNFC.Backend.Java.CFtoJavaAbs15  import BNFC.CF+import BNFC.Backend.Common (renderListSepByPrecedence) import BNFC.Backend.Common.NamedVariables import BNFC.Utils		( (+++) ) import Data.List import Data.Char	( toLower, isSpace )+import Data.Either (lefts)+import BNFC.PrettyPrint  --Produces the PrettyPrinter class. --It will generate two methods "print" and "show"@@ -81,6 +84,7 @@       "{",       "  //For certain applications increasing the initial size of the buffer may improve performance.",       "  private static final int INITIAL_BUFFER_SIZE = 128;",+      "  private static final int INDENT_WIDTH = 2;",       "  //You may wish to change the parentheses used in precedence.",       "  private static final String _L_PAREN = new String(\"(\");",       "  private static final String _R_PAREN = new String(\")\");",@@ -135,7 +139,7 @@       "       buf_.append(\"\\n\");",       "       indent();",       "       buf_.append(s);",-      "       _n_ = _n_ + 2;",+      "       _n_ = _n_ + INDENT_WIDTH;",       "       buf_.append(\"\\n\");",       "       indent();",       "    }",@@ -149,9 +153,11 @@       "    }",       "    else if (s.equals(\"}\"))",       "    {",-      "       _n_ = _n_ - 2;",-      "       backup();",-      "       backup();",+      "       int t;",+      "       _n_ = _n_ - INDENT_WIDTH;",+      "       for(t=0; t<INDENT_WIDTH; t++) {",+      "         backup();",+      "       }",       "       buf_.append(s);",       "       buf_.append(\"\\n\");",       "       indent();",@@ -214,7 +220,7 @@   "  private static void pp(" ++ packageAbsyn ++ "."       ++ identCat (normCat cat) +++ "foo, int _i_)",   "  {",-  (prList user cat rules) ++ "  }"+  render $ nest 5 $ prList user cat rules <> "  }"  ]  else unlines --not a list  [@@ -243,41 +249,61 @@       "       if (_i_ > " ++ (show p) ++ ") render(_R_PAREN);\n")     cats' = case cats of         [] -> ""-    	_  -> concatMap (prCat fnm) (zip (fixOnes (numVars [] cats)) (map getPrec cats))+    	_  -> concatMap (render . prCat (text fnm)) (numVars cats)     fnm = '_' : map toLower fun -    getPrec (Right {}) = 0-    getPrec (Left  c)  = precCat c- prRule _nm _ = "" -prList :: [UserDef] -> Cat -> [Rule] -> String-prList user c rules = unlines-  [-   "     for (java.util.Iterator<" ++ et-          ++ "> it = foo.iterator(); it.hasNext();)",-   "     {",-   "       pp(it.next(), 0);",-   "       if (it.hasNext()) {",-   "         render(\"" ++ sep ++ "\");",-   "       } else {",-   "         render(\"" ++ optsep ++ "\");",-   "       }",-   "     }"-  ]- where-    et = typename (show $ normCatOfList c) user+-- |+--+-- >>> let lfoo = ListCat (Cat "Foo")+-- >>> prList [] lfoo [Rule "[]" lfoo [], Rule "(:)" lfoo [Left (Cat "Foo"), Right ".", Left lfoo]]+-- for (java.util.Iterator<Foo> it = foo.iterator(); it.hasNext();)+-- {+--   pp(it.next(), _i_);+--   if (it.hasNext()) {+--     render(".");+--   } else {+--     render(".");+--   }+-- }+prList :: [UserDef] -> Cat -> [Rule] -> Doc+prList user c rules =+    "for (java.util.Iterator<" <> et <> "> it = foo.iterator(); it.hasNext();)"+    $$ codeblock 2+        [ "pp(it.next(), _i_);"+        , "if (it.hasNext()) {"+        , nest 2 (renderListSepByPrecedence "_i_" renderSep+            (getSeparatorByPrecedence rules))+        , "} else {"+        , nest 2 (renderSep optsep <> ";")+        , "}"+        ]+   where+    et = text (typename (show $ normCatOfList c) user)     sep = escapeChars $ getCons rules     optsep = if hasOneFunc rules then "" else sep+    renderSep x = "render(\"" <> text x <>"\")" -prCat fnm (c, p) =-    case c of-	   Right t -> "       render(\"" ++ escapeChars t ++ "\");\n"-	   Left nt | "string" `isPrefixOf` nt-                     -> "       printQuoted(" ++ fnm ++ "." ++ nt ++ ");\n"-                   | isInternalVar nt -> ""-                   | otherwise-                     -> "       pp(" ++ fnm ++ "." ++ nt ++ ", " ++ show p ++ ");\n"+-- |+-- >>> prCat "F" (Right "++")+--        render("++");+-- <BLANKLINE>+-- >>> prCat "F" (Left (Cat "String", "string_"))+--        printQuoted(F.string_);+-- <BLANKLINE>+-- >>> prCat "F" (Left (InternalCat, "#_"))+-- <BLANKLINE>+-- >>> prCat "F" (Left (Cat "Abc", "abc_"))+--        pp(F.abc_, 0);+-- <BLANKLINE>+prCat :: Doc -> Either (Cat, Doc) String -> Doc+prCat _ (Right t) = nest 7 ("render(\"" <> text(escapeChars t) <> "\");\n")+prCat fnm (Left (Cat "String", nt))+    = nest 7 ("printQuoted(" <> fnm <> "." <> nt <> ");\n")+prCat _ (Left (InternalCat, _)) = empty+prCat fnm (Left (cat, nt))+    = nest 7 ("pp(" <> fnm <> "." <> nt <> ", " <> integer (precCat cat) <> ");\n")  --The following methods generate the Show function. @@ -316,7 +342,7 @@      ]     cats' = if allTerms cats         then ""-    	else (concat (map (shCat fnm) (fixOnes (numVars [] cats))))+    	else concatMap (render . shCat (text fnm)) (lefts (numVars cats))     (lparen, rparen) =       if allTerms cats          then ("","")@@ -341,15 +367,24 @@     where     et = typename (show $ normCatOfList c) user -shCat fnm c =-    case c of-    Right {} -> ""-    Left nt | "list" `isPrefixOf` nt-                -> unlines ["       render(\"[\");",-		            "       sh(" ++ fnm ++ "." ++ nt ++ ");",-		            "       render(\"]\");"]-            | isInternalVar nt -> ""-            | otherwise  -> "       sh(" ++ fnm ++ "." ++ nt ++ ");\n"+-- |+-- >>> shCat "F" (ListCat (Cat "A"), "lista_")+--        render("[");+--        sh(F.lista_);+--        render("]");+-- <BLANKLINE>+-- >>> shCat "F" (InternalCat, "#_")+-- <BLANKLINE>+-- >>> shCat "F" (Cat "A", "a_")+--        sh(F.a_);+-- <BLANKLINE>+shCat :: Doc -> (Cat, Doc) -> Doc+shCat fnm (ListCat _, vname) = vcat+    [ "       render(\"[\");"+    , "       sh(" <> fnm <> "." <> vname <> ");"+    , "       render(\"]\");\n" ]+shCat _ (InternalCat, _)     = empty+shCat fname (_, vname)       = "       sh(" <> fname <> "." <> vname <> ");\n"  --Helper function that escapes characters in strings escapeChars :: String -> String@@ -357,5 +392,3 @@ escapeChars ('\\':xs) = '\\' : ('\\' : (escapeChars xs)) escapeChars ('\"':xs) = '\\' : ('\"' : (escapeChars xs)) escapeChars (x:xs) = x : (escapeChars xs)--isInternalVar x = x == show InternalCat ++ "_"
src/BNFC/Backend/Java/CFtoVisitSkel15.hs view
@@ -44,8 +44,8 @@ import BNFC.Backend.Java.CFtoJavaAbs15 (typename) import BNFC.Utils ((+++)) import BNFC.Backend.Common.NamedVariables-import Data.List-import Data.Char(toLower)+import Text.PrettyPrint+import Data.Either (lefts)  --Produces a Skeleton using the Visitor Design Pattern. --Thus the user can choose which Skeleton to use.@@ -59,7 +59,7 @@     "}"]   where     user = fst (unzip (tokenPragmas cf))-    groups = fixCoercions (ruleGroups cf)+    groups = fixCoercions (ruleGroupsInternals cf)     header = unlines [       "package" +++ packageBase ++ ";",       "import" +++ packageAbsyn ++ ".*;",@@ -83,59 +83,62 @@  else unlines ["  public class " ++ identCat cat ++ "Visitor<R,A> implements " 	       ++ identCat cat ++ ".Visitor<R,A>", 	       "  {",-	       concatMap (prRule packageAbsyn user) rules,+	       concatMap (render . nest 4 . prRule packageAbsyn user) rules, 	       "  }" 	      ] ---traverses a standard rule.-prRule :: String -> [UserDef] -> Rule -> String-prRule packageAbsyn user (Rule fun _ cats) | not (isCoercion fun || isDefinedRule fun) = unlines-  [-   "    public R visit(" ++ packageAbsyn ++ "." ++ fun ++ " p, A arg)",-   "    {",-   "      /* Code For " ++ fun ++ " Goes Here */",-   "",-   concatMap (uncurry (prCat user)) cats',-   "      return null;",-   "    }"-  ]-   where-    cats' = if allTerms cats-        then []-    	else [ (c,v) |-	       (Left c, Left v) <- zip cats (fixOnes (numVars [] cats)) ]-    allTerms [] = True-    allTerms (Left _:_) = False-    allTerms (_:zs) = allTerms zs+-- | traverses a standard rule.+-- >>> prRule "ABSYN" [] (Rule "EInt" undefined [Left (TokenCat "Integer"), Left (Cat "NT")])+-- public R visit(ABSYN.EInt p, A arg)+-- { /* Code For EInt Goes Here */+--   //p.integer_;+--   p.nt_.accept(new NTVisitor<R,A>(), arg);+--   return null;+-- }+--+-- It skips the internal category (indicating that a rule is not parsable)+-- >>> prRule "ABSYN" [] (Rule "EInt" undefined [Left (InternalCat), Left (TokenCat "Integer")])+-- public R visit(ABSYN.EInt p, A arg)+-- { /* Code For EInt Goes Here */+--   //p.integer_;+--   return null;+-- }+prRule :: String -> [UserDef] -> Rule -> Doc+prRule packageAbsyn user (Rule fun _ cats)+  | not (isCoercion fun || isDefinedRule fun) = vcat+    [ "public R visit(" <> text packageAbsyn <> "." <> fname <> " p, A arg)"+    , "{"+    , nest 2 ( "/* Code For " <> fname <> " Goes Here */"+            $$ vcat (map (prCat user) cats')+            $$ "return null;" )+    , "}" ]+  where+    fname = text fun                            -- function name+    cats' = filter ((/= InternalCat).fst) (lefts (numVars cats))  -- non-terminals in the rhs prRule _ _ _ = "" ---Traverses a class's instance variables.-prCat :: [UserDef]-      -> Cat       -- ^ Variable category-      -> String    -- ^ Variable name-      -> String    -- ^ Code for visiting the variable-prCat user cat nt | isBasic user nt = "      //" ++ var ++ ";\n"-		  | "list" `isPrefixOf` nt = listAccept-		  | otherwise = "      " ++ accept ++ "\n"-      where-      var = "p." ++ nt+-- | Traverses a class's instance variables.+-- >>> prCat [] (Cat "A", "a_")+-- p.a_.accept(new AVisitor<R,A>(), arg);+-- >>> prCat [] (TokenCat "Integer", "integer_")+-- //p.integer_;+-- >>> prCat [Cat "A"] (TokenCat "A", "a_")+-- //p.a_;+-- >>> prCat [Cat "A"] (TokenCat "A", "a_2")+-- //p.a_2;+-- >>> prCat [] (ListCat (Cat "A"), "lista_")+-- for (A x: p.lista_)+-- { /* ... */ }+prCat :: [UserDef]    -- ^ User defined tokens+      -> (Cat, Doc)   -- ^ Variable category and name+      -> Doc          -- ^ Code for visiting the variable+prCat user (cat, nt)+  | isTokenCat cat = "//" <> var <> ";"+  | isList cat           = "for" <+> parens (text et <+> "x:" <+> var)+                        $$ braces " /* ... */ "+  | otherwise            = accept+  where+      var = "p." <> nt       varType = typename (identCat (normCat cat)) user-      accept = var ++ ".accept(new " ++ varType ++ "Visitor<R,A>(), arg);"+      accept = var <> ".accept(new " <> text varType <> "Visitor<R,A>(), arg);"       et = typename (show $normCatOfList cat) user-      listAccept = unlines ["      for (" ++ et ++ " x : " ++ var ++ ") {",-			    "      }"]----Just checks if something is a basic or user-defined type.---This is because you don't -> a basic non-pointer type.-isBasic :: [UserDef] -> String -> Bool-isBasic user v =-  if elem (init v) user'-    then True-    else if "integer_" `isPrefixOf` v then True-    else if "char_" `isPrefixOf` v then True-    else if "string_" `isPrefixOf` v then True-    else if "double_" `isPrefixOf` v then True-    else if "ident_" `isPrefixOf` v then True-    else False-  where-   user' = map (map toLower.show) user
src/BNFC/Backend/Java/RegToJLex.hs view
@@ -36,18 +36,22 @@   prt _ = prtList  instance Print Char where-  prt _ c = [escapeChar c]+  prt _ c = [escapeChar False c]   prtList s = map (concat . prt 0) s -escapeChar :: Char -> String-escapeChar '^' = "\\x5E" -- special case, since \^ is a control character escape-escapeChar x | x `elem` jlexReserved = '\\' : [x]-escapeChar x = [x]+escapeChar :: Bool -> Char -> String+escapeChar _ '^' = "\\x5E" -- special case, since \^ is a control character escape+escapeChar False x | x `elem` jlexReserved = '\\' : [x]+escapeChar True x | x `elem` jflexReserved = '\\' : [x]+escapeChar _ x = [x]  -- Characters that must be escaped in JLex regular expressions jlexReserved :: [Char]-jlexReserved = ['?', '*', '+', '|', '(', ')', '^', '$', '.', '[', ']', '{', '}', '"', '\\']+jlexReserved = ['?','*','+','|','(',')','^','$','.','[',']','{','}','"','\\'] +jflexReserved :: [Char]+jflexReserved = '~':'!':'/':jlexReserved+ prPrec :: Int -> Int -> [String] -> [String] prPrec i j = if j<i then parenth else id @@ -79,6 +83,3 @@    RUpper  -> prPrec i 3 (concat [["{CAPITAL}"]])    RLower  -> prPrec i 3 (concat [["{SMALL}"]])    RAny  -> prPrec i 3 (concat [["."]])---
src/BNFC/Backend/Latex.hs view
@@ -24,7 +24,7 @@ import BNFC.Backend.Common.Makefile as Makefile import BNFC.CF import BNFC.Utils-import Data.List (intersperse)+import Data.List import System.FilePath ((<.>),replaceExtension) import Text.Printf @@ -37,14 +37,14 @@  cfToLatex :: String -> CF -> String cfToLatex name cf = unlines [-			    "\\batchmode",-			    beginDocument name,-			    macros,-			    introduction,-			    prtTerminals name cf,-			    prtBNF name cf,-			    endDocument-			    ]+                            "\\batchmode",+                            beginDocument name,+                            macros,+                            introduction,+                            prtTerminals name cf,+                            prtBNF name cf,+                            endDocument+                            ]   makefile_ = makefile@@ -65,33 +65,33 @@  introduction :: String introduction = concat-	       [-	       "\nThis document was automatically generated by ",-	       "the {\\em BNF-Converter}.",-	       " It was generated together with the lexer, the parser, and the",+               [+               "\nThis document was automatically generated by ",+               "the {\\em BNF-Converter}.",+               " It was generated together with the lexer, the parser, and the",                " abstract syntax module, which guarantees that the document",-	       " matches with the implementation of the language (provided no",+               " matches with the implementation of the language (provided no",                " hand-hacking has taken place).\n"-	       ]+               ]  prtTerminals :: String -> CF -> String prtTerminals name cf = unlines [-			       "\\section*{The lexical structure of " ++ name ++ "}",+                               "\\section*{The lexical structure of " ++ name ++ "}",                                identSection cf,-			       "\\subsection*{Literals}",+                               "\\subsection*{Literals}",                                prtLiterals name cf,                                unlines (map prtOwnToken (tokenPragmas cf)),-			       "\\subsection*{Reserved words and symbols}",-			       prtReserved name cf,-			       prtSymb name cf,-			       "\\subsection*{Comments}",-			       prtComments $ comments cf-			       ]+                               "\\subsection*{Reserved words and symbols}",+                               prtReserved name cf,+                               prtSymb name cf,+                               "\\subsection*{Comments}",+                               prtComments $ comments cf+                               ]  identSection cf = if not (hasIdent cf) then [] else                     unlines [-			       "\\subsection*{Identifiers}",-			       prtIdentifiers+                               "\\subsection*{Identifiers}",+                               prtIdentifiers                           ]  prtIdentifiers :: String@@ -137,49 +137,49 @@  prtComments :: ([(String,String)],[String]) -> String prtComments (xs,ys) = concat-		   [-		   if (null ys) then-		    "There are no single-line comments in the grammar. \\\\"-		   else-		    "Single-line comments begin with " ++ sing ++". \\\\",-		   if (null xs) then-		    "There are no multiple-line comments in the grammar."-		   else-		   "Multiple-line comments are  enclosed with " ++ mult ++"."-		   ]+                   [+                   if null ys then+                    "There are no single-line comments in the grammar. \\\\"+                   else+                    "Single-line comments begin with " ++ sing ++". \\\\",+                   if null xs then+                    "There are no multiple-line comments in the grammar."+                   else+                   "Multiple-line comments are  enclosed with " ++ mult ++"."+                   ]  where- sing = concat $ intersperse ", " $ map (symbol.prt) ys- mult = concat $ intersperse ", " $-	 map (\(x,y) -> (symbol (prt x))-		       ++ " and " ++-	              (symbol (prt y))) xs+ sing = intercalate ", " $ map (symbol.prt) ys+ mult = intercalate ", " $+         map (\(x,y) -> symbol (prt x)+                       ++ " and " +++                      symbol (prt y)) xs  prtSymb :: String -> CF -> String prtSymb name cf = case symbols cf of-		   [] -> "\nThere are no symbols in " ++ name ++ ".\\\\\n"+                   [] -> "\nThere are no symbols in " ++ name ++ ".\\\\\n"                    xs -> "The symbols used in " ++ name ++ " are the following: \\\\\n"                          ++-                         (tabular 3 $ three $ map (symbol.prt) xs)+                         tabular 3 (three $ map (symbol.prt) xs)  prtReserved :: String -> CF -> String prtReserved name cf = case reservedWords cf of-		       [] -> stringRes name ++-			     "\nThere are no reserved words in " ++ name ++ ".\\\\\n"+                       [] -> stringRes name +++                             "\nThere are no reserved words in " ++ name ++ ".\\\\\n"                        xs -> stringRes name ++-		             (tabular 3 $ three $ map (reserved.prt) xs)+                             tabular 3 (three $ map (reserved.prt) xs)  stringRes :: String -> String stringRes name = concat-		 ["The set of reserved words is the set of terminals ",-		  "appearing in the grammar. Those reserved words ",-		  "that consist of non-letter characters are called symbols, and ",-		  "they are treated in a different way from those that ",-		  "are similar to identifiers. The lexer ",-		  "follows rules familiar from languages ",-		  "like Haskell, C, and Java, including longest match ",-		  "and spacing conventions.",+                 ["The set of reserved words is the set of terminals ",+                  "appearing in the grammar. Those reserved words ",+                  "that consist of non-letter characters are called symbols, and ",+                  "they are treated in a different way from those that ",+                  "are similar to identifiers. The lexer ",+                  "follows rules familiar from languages ",+                  "like Haskell, C, and Java, including longest match ",+                  "and spacing conventions.",                   "\n\n",-		  "The reserved words used in " ++ name ++ " are the following: \\\\\n"]+                  "The reserved words used in " ++ name ++ " are the following: \\\\\n"]  three :: [String] -> [[String]] three []         = []@@ -189,39 +189,39 @@  prtBNF :: String -> CF -> String prtBNF name cf = unlines [-		     "\\section*{The syntactic structure of " ++ name ++"}",-		     "Non-terminals are enclosed between $\\langle$ and $\\rangle$. ",-		     "The symbols " ++ arrow ++ " (production), " +++                     "\\section*{The syntactic structure of " ++ name ++"}",+                     "Non-terminals are enclosed between $\\langle$ and $\\rangle$. ",+                     "The symbols " ++ arrow ++ " (production), " ++                       delimiter ++" (union) ",-		     "and " ++ empty ++ " (empty rule) belong to the BNF notation. ",-		     "All other symbols are terminals.\\\\",-		     prtRules (ruleGroups cf)-		     ]+                     "and " ++ empty ++ " (empty rule) belong to the BNF notation. ",+                     "All other symbols are terminals.\\\\",+                     prtRules (ruleGroups cf)+                     ]  prtRules :: [(Cat,[Rule])] -> String prtRules          [] = [] prtRules ((c,[]):xs)     = tabular 3 [[nonterminal c,arrow,[]]] ++ prtRules xs-prtRules ((c,(r:rs)):xs)+prtRules ((c, r : rs) : xs)     = tabular 3 ([[nonterminal c,arrow,prtSymbols $ rhsRule r]] ++                  [[[],delimiter,prtSymbols (rhsRule y)] | y <-  rs]) ++       prtRules xs  prtSymbols :: [Either Cat String] -> String prtSymbols [] = empty-prtSymbols xs = foldr (+++) [] (map p xs)+prtSymbols xs = foldr ((+++) . p) [] xs  where p (Left  r) = nonterminal r --- (prt r)        p (Right r) = terminal    (prt r)   prt :: String -> String prt = concatMap escape-  where escape '\\'                   = "$\\backslash$"-        escape '~'                    = "\\~{}"-        escape '^'                    = "{\\textasciicircum}"-        escape c | c `elem` "$&%#_{}" = ['\\', c]-        escape c | c `elem` "+=|<>-"  = "{$"  ++ [c] ++ "$}"-        escape c                      = [c]+  where escape '\\'                               = "$\\backslash$"+        escape '~'                                = "\\~{}"+        escape '^'                                = "{\\textasciicircum}"+        escape c | c `elem` ("$&%#_{}" :: String) = ['\\', c]+        escape c | c `elem` ("+=|<>-" :: String)  = "{$"  ++ [c] ++ "$}"+        escape c                                  = [c]  macros :: String macros =@@ -248,8 +248,8 @@  tabular :: Int -> [[String]] -> String tabular n xs = "\n\\begin{tabular}{" ++ concat (replicate n "l") ++ "}\n" ++-	       concat (map (\(a:as) -> foldr (+++) "\\\\\n" (a:(map ('&':) as))) xs) ++-	       "\\end{tabular}\\\\\n"+               concatMap (\(a:as) -> foldr (+++) "\\\\\n" (a: map ('&':) as)) xs +++               "\\end{tabular}\\\\\n"  terminal :: String -> String terminal s = "{\\terminal{" ++ s ++ "}}"
src/BNFC/Backend/OCaml/CFtoOCamlPrinter.hs view
@@ -23,10 +23,13 @@  import BNFC.CF import BNFC.Utils-import Data.List (intersperse)+import Data.List (intersperse, sortBy) import Data.Char(toLower) import BNFC.Backend.OCaml.OCamlUtil+import BNFC.PrettyPrint+import BNFC.Backend.Haskell.CFtoPrinter (compareRules) + -- derive pretty-printer from a BNF grammar. AR 15/2/2002 cf2Printer :: String -> String -> CF -> String cf2Printer name absMod cf = unlines [@@ -105,29 +108,29 @@  charRule cf = unlines [     "let rec prtChar (_:int) (c:char) : doc = render (\"'\" ^ Char.escaped c ^ \"'\")",-    ifList cf (Cat "Char"),+    ifList cf catChar,     ""     ]  integerRule cf = unlines [     "let rec prtInt (_:int) (i:int) : doc = render (string_of_int i)",-    ifList cf (Cat "Integer"),+    ifList cf catInteger,     ""     ]  doubleRule cf = unlines [     "let rec prtFloat (_:int) (f:float) : doc = render (sprintf \"%f\" f)",-    ifList cf (Cat "Double"),+    ifList cf catDouble,     ""     ]  stringRule cf = unlines [     "let rec prtString (_:int) (s:string) : doc = render (\"\\\"\" ^ String.escaped s ^ \"\\\"\")",-    ifList cf (Cat "String"),+    ifList cf catString,     ""     ] -identRule cf = ownPrintRule cf (Cat "Ident")+identRule cf = ownPrintRule cf catIdent  ownPrintRule cf own = unlines $ [   "let rec" +++ prtFun own +++ "_ (" ++ show own ++ posn ++ ") : doc = render i",@@ -142,7 +145,8 @@ rules cf = unlines $ mutualDefs $   map (\(s,xs) -> case_fun s (map toArgs xs) ++ ifList cf s) $ cf2data cf  where-   toArgs (cons,args) = ((cons, names (map (checkRes . var) args) (0 :: Int)), ruleOf cons)+   reserved = "i":"e":reservedOCaml+   toArgs (cons,args) = ((cons, mkNames reserved LowerCase (map var args)), ruleOf cons)    names [] _ = []    names (x:xs) n      | elem x xs = (x ++ show n) : names xs (n+1)@@ -168,16 +172,51 @@     "prPrec i" +++ show (precCat (fst r)) +++ mkRhs xx (snd r)) xs   ] -ifList cf cat = mkListRule $ nil cat ++ one cat ++ cons cat where-  nil cat  = ["    []    -> " ++ mkRhs [] its |-                            Rule f c its <- rulesOfCF cf, isNilFun f , normCatOfList c == cat]-  one cat  = ["  | [x]   -> " ++ mkRhs ["x"] its |-                            Rule f c its <- rulesOfCF cf, isOneFun f , normCatOfList c == cat]-  cons cat = ["  | x::xs -> " ++ mkRhs ["x","xs"] its |-                            Rule f c its <- rulesOfCF cf, isConsFun f , normCatOfList c == cat]-  mkListRule [] = ""-  mkListRule rs = unlines $ ("and prt" ++ fixTypeUpper cat ++ "ListBNFC" +++ "_ es : doc = match es with"):rs+-- ifList cf cat = mkListRule $ nil cat ++ one cat ++ cons cat where+--   nil cat  = ["    []    -> " ++ mkRhs [] its |+--                             Rule f c its <- rulesOfCF cf, isNilFun f , normCatOfList c == cat]+--   one cat  = ["  | [x]   -> " ++ mkRhs ["x"] its |+--                             Rule f c its <- rulesOfCF cf, isOneFun f , normCatOfList c == cat]+--   cons cat = ["  | x::xs -> " ++ mkRhs ["x","xs"] its |+--                             Rule f c its <- rulesOfCF cf, isConsFun f , normCatOfList c == cat]+--   mkListRule [] = ""+--   mkListRule rs = unlines $ ("and prt" ++ fixTypeUpper cat ++ "ListBNFC" +++ "_ es : doc = match es with"):rs +ifList :: CF -> Cat -> String+ifList cf cat = case cases of+    []        -> ""+    first:rest -> render $ vcat+        [ "and prt" <> text (fixTypeUpper cat)  <> "ListBNFC i es : doc = match (i, es) with"+        , nest 4 first+        , nest 2 $ vcat (map ("|" <+>) rest)+        ]+  where+    rules = sortBy compareRules $ rulesForNormalizedCat cf (ListCat cat)+    cases = [ mkPrtListCase r | r <- rules ]+++-- | Pattern match on the list constructor and the coercion level+-- >>> mkPrtListCase (Rule "[]" (ListCat (Cat "Foo")) [])+-- (_,[]) -> (concatD [])+-- >>> mkPrtListCase (Rule "(:[])" (ListCat (Cat "Foo")) [Left (Cat "Foo")])+-- (_,[x]) -> (concatD [prtFoo 0 x])+-- >>> mkPrtListCase (Rule "(:)" (ListCat (Cat "Foo")) [Left (Cat "Foo"), Left (ListCat (Cat "Foo"))])+-- (_,x::xs) -> (concatD [prtFoo 0 x ; prtFooListBNFC 0 xs])+-- >>> mkPrtListCase (Rule "[]" (ListCat (CoercCat "Foo" 2)) [])+-- (2,[]) -> (concatD [])+-- >>> mkPrtListCase (Rule "(:[])" (ListCat (CoercCat "Foo" 2)) [Left (CoercCat "Foo" 2)])+-- (2,[x]) -> (concatD [prtFoo 2 x])+-- >>> mkPrtListCase (Rule "(:)" (ListCat (CoercCat "Foo" 2)) [Left (CoercCat "Foo" 2), Left (ListCat (CoercCat "Foo" 2))])+-- (2,x::xs) -> (concatD [prtFoo 2 x ; prtFooListBNFC 2 xs])+mkPrtListCase :: Rule -> Doc+mkPrtListCase (Rule f (ListCat c) rhs)+  | isNilFun f  = parens (precPattern <> "," <> "[]") <+> "->" <+> body+  | isOneFun f  = parens (precPattern <> "," <> "[x]") <+> "->" <+> body+  | isConsFun f = parens (precPattern <> "," <>"x::xs") <+> "->" <+> body+  | otherwise = empty -- (++) constructor+  where+    precPattern = case precCat c of 0 -> "_" ; p -> integer p+    body = text $ mkRhs ["x", "xs"] rhs  mkRhs args its =   "(concatD [" ++ unwords (intersperse ";" (mk args its)) ++ "])"
src/BNFC/Backend/OCaml/CFtoOCamlYacc.hs view
@@ -44,22 +44,36 @@ cf2ocamlyacc :: String -> String -> String -> CF -> String cf2ocamlyacc name absName lexName cf  = unlines-    [header name absName lexName,+    [header name absName lexName cf,     declarations absName cf,     "%%",     rules cf     ]  -header :: String -> String -> String -> String-header _ absName _ = unlines+header :: String -> String -> String -> CF -> String+header _ absName _ cf = unlines          ["/* This ocamlyacc file was machine-generated by the BNF converter */",           "%{",           "open " ++ absName,           "open Lexing",+          "",+          definedRules cf,           "%}"          ] +definedRules :: CF -> String+definedRules cf = unlines [mkDef f xs e | FunDef f xs e <- pragmasOfCF cf]+    where+        mkDef f xs e = +            "let " ++ f ++ " " ++ mkTuple xs ++ " = " ++ ocamlExp e+            where+                ocamlExp :: Exp -> String+                ocamlExp (App s es) = s ++ ' ' : mkTuple (map ocamlExp es)+                ocamlExp (LitInt i) = show i+                ocamlExp (LitDouble d) = show d+                ocamlExp (LitChar c) = "\'" ++ c : "\'"+                ocamlExp (LitString s) = "\"" ++ s ++ "\""  declarations :: String -> CF -> String declarations absName cf = unlines@@ -114,11 +128,11 @@     where eps = (nub $ map normCat (allEntryPoints cf))           typing :: Cat -> String           typing c = "%type" +++ "<" ++ qualify c ++ ">" +++ epName c-          qualify c = if c `elem` [ Cat "Integer", Cat "Double", Cat "Char",-                                    Cat "String", ListCat (Cat "Integer"),-                                    ListCat (Cat "Double"),-                                    ListCat (Cat "Char"),-                                    ListCat (Cat "String") ]+          qualify c = if c `elem` [ TokenCat "Integer", TokenCat "Double", TokenCat "Char",+                                    TokenCat "String", ListCat (TokenCat "Integer"),+                                    ListCat (TokenCat "Double"),+                                    ListCat (TokenCat "Char"),+                                    ListCat (TokenCat "String") ]                       then fixType c                       else absName ++ "." ++ fixType c @@ -211,11 +225,11 @@  where    aux cat =      case cat of-         Cat "Ident"   -> "ident : TOK_Ident  { Ident $1 };"-         Cat "String"  -> "string : TOK_String { $1 };"-         Cat "Integer" -> "int :  TOK_Integer  { $1 };"-         Cat "Double"  -> "float : TOK_Double  { $1 };"-         Cat "Char"    -> "char : TOK_Char { $1 };"+         TokenCat "Ident"   -> "ident : TOK_Ident  { Ident $1 };"+         TokenCat "String"  -> "string : TOK_String { $1 };"+         TokenCat "Integer" -> "int :  TOK_Integer  { $1 };"+         TokenCat "Double"  -> "float : TOK_Double  { $1 };"+         TokenCat "Char"    -> "char : TOK_Char { $1 };"          own       -> (fixType own) ++ " : TOK_" ++ show own ++                       " { " ++ show own ++ " ("++ posn ++ "$1)};"                 -- PCC: take "own" as type name? (manual says newtype)
src/BNFC/Backend/OCaml/OCamlUtil.hs view
@@ -27,8 +27,8 @@ -- Note: OCaml (data-)types start with lowercase letter fixType :: Cat -> String fixType (ListCat c) = fixType c +++ "list"-fixType (Cat "Integer") = "int"-fixType (Cat "Double") = "float"+fixType (TokenCat "Integer") = "int"+fixType (TokenCat "Double") = "float" fixType cat = let c:cs = show cat in                 let ls = toLower c : cs in                   if (elem ls reservedOCaml) then (ls ++ "T") else ls
+ src/BNFC/Backend/Pygments.hs view
@@ -0,0 +1,157 @@+{- Generates a Pygments lexer from a BNF grammar.+ -+ - Resources:+ - * Pygments: http://pygments.org/+ - * Lexer development: http://pygments.org/docs/lexerdevelopment/+ - * Token types: http://pygments.org/docs/tokens/+ - -}+module BNFC.Backend.Pygments where+++import AbsBNF (Reg(..))+import BNFC.Backend.Base (mkfile, Backend)+import BNFC.CF+import BNFC.Lexing+import BNFC.Options hiding (Backend)+import BNFC.Utils+import BNFC.PrettyPrint++makePygments :: SharedOptions -> CF -> Backend+makePygments opts cf = do+    let lexerfile = render (lowerCase name <> "/__init__.py")+        setupfile = "setup.py"+    mkfile lexerfile (render $ lexer name cf)+    mkfile setupfile (render $ setup name)+  where name = lang opts++setup :: String -> Doc+setup name = vcat+    [ "from setuptools import setup, find_packages"+    , "setup" <> parens (fsep (punctuate ","+        [ "name" <=> quotes ("pygment-"<>lowerCase name)+        , "version" <=> "0.1"+        , "packages" <=> brackets (quotes moduleName)+        , "entry_points" <=> entryPoints+        , "install_requires = ['pygments']"+        ]))+    ]+  where+    className = camelCase name <> "Lexer"+    moduleName = lowerCase name+    entryPoints =+        braces( "'pygments.lexers':"+              <> doubleQuotes (moduleName <> "=" <> moduleName <> ":" <> className))++lexer :: String -> CF -> Doc+lexer name cf = vcat+    -- Import statments+    [ "import pygments.lexer"+    , "from pygments.token import *"+    -- Declare our lexer+    , "__all__" <=> brackets (doubleQuotes className)+    -- define lexer+    , "class" <+> className <> parens "pygments.lexer.RegexLexer" <> ":"+    , indent+        [ "name" <=> quotes (text name)+        , "aliases" <=> brackets (quotes (lowerCase name))+        -- filenames = ['*.cf', '*lbnf']+        , "KEYWORDS" <=> brackets keywords+        -- We override the get_tokens_unprocessed method to filter keywords+        -- from identifiers+        , "def get_tokens_unprocessed(self, text):"+        , indent+            [ "for index, token, value in super(" <> className <> ",self).get_tokens_unprocessed(text):"+            , indent+                [ "if token is Name and value in self.KEYWORDS:"+                , indent [ "yield index, Keyword, value" ]+                , "else:"+                , indent [ "yield index, token, value" ]+                ]+            ]+        -- The token is defined using regex+        , "tokens = {"+        , indent+            [ "'root': ["+            , indent (map prLexRule (mkLexer cf) ++ ["(r'\\s+', Token.Space)"])+            , "]"+            ]+        , "}"+        ]+    ]+  where+    className = camelCase name <> "Lexer"+    keywords = fsep (punctuate "," (map (quotes . text) (reservedWords cf)))+    indent = nest 4 . vcat+    prLexRule (reg,ltype) =+        parens ("r" <> quotes (pyRegex reg) <> "," <+> pyToken ltype) <> ","+    pyToken LexComment = "Comment"+    pyToken LexSymbols = "Operator"+    pyToken (LexToken "Integer") = "Number.Integer"+    pyToken (LexToken "Double") = "Number.Float"+    pyToken (LexToken "Char") = "String.Char"+    pyToken (LexToken "String") = "String.Double"+    pyToken (LexToken _) = "Name"++++-- | Convert a Reg to a python regex+-- >>> pyRegex (RSeqs "abc")+-- abc+-- >>> pyRegex (RAlt (RSeqs "::=") (RChar '.'))+-- ::=|\.+-- >>> pyRegex (RChar '=')+-- =+-- >>> pyRegex RAny+-- .+-- >>> pyRegex (RStar RAny)+-- .*+-- >>> pyRegex (RPlus (RSeqs "xxx"))+-- (xxx)++-- >>> pyRegex (ROpt (RSeqs "abc"))+-- (abc)?+-- >>> pyRegex (RSeq (RSeqs "--") (RSeq (RStar RAny) (RChar '\n')))+-- --.*\n+-- >>> pyRegex (RStar (RSeq (RSeqs "abc") (RChar '*')))+-- (abc\*)*+-- >>> pyRegex REps+-- <BLANKLINE>+-- >>> pyRegex (RAlts "abc[].")+-- [abc\[\]\.]+-- >>> pyRegex RDigit+-- \d+-- >>> pyRegex RLetter+-- [a-zA-Z]+-- >>> pyRegex RUpper+-- [A-Z]+-- >>> pyRegex RLower+-- [a-z]+-- >>> pyRegex (RMinus RAny RDigit)+-- (.)(?<!\d)+-- >>> pyRegex (RSeq (RAlt (RChar 'a') RAny) (RAlt (RChar 'b') (RChar 'c')))+-- (a|.)(b|c)+pyRegex :: Reg -> Doc+pyRegex reg = case reg of+    RSeqs s       -> text (concatMap escape s)+    RAlt r1 r2    -> pyRegex r1 <> "|" <> pyRegex r2+    RChar c       -> text (escape c)+    RAny          -> char '.'+    RStar RAny    -> ".*"+    RStar re      -> parens (pyRegex re) <> char '*'+    RPlus re      -> parens (pyRegex re) <> char '+'+    ROpt re       -> parens (pyRegex re) <> char '?'+    RSeq r1 r2    -> pyRegex' r1 <> pyRegex' r2+    REps          -> empty+    RAlts cs      -> brackets (hcat (map (pyRegex . RChar) cs))+    RDigit        -> "\\d"+    RUpper        -> "[A-Z]"+    RLower        -> "[a-z]"+    RLetter       -> "[a-zA-Z]"+    RMinus r1 r2  -> parens (pyRegex r1) <> parens ("?<!" <> pyRegex r2)+  where+    escape '\n' = "\\n"+    escape '\t' = "\\t"+    escape c | c `elem` (".'[]()|*+?{}\\" :: String) = ['\\',c]+    escape c = [c]+    pyRegex' r@(RAlt{}) = parens (pyRegex r)+    pyRegex' r = pyRegex r+
src/BNFC/Backend/Txt2Tag.hs view
@@ -22,45 +22,45 @@ import BNFC.CF import AbsBNF (Reg (..)) import BNFC.Utils-import Data.List (intersperse)+import Data.List  cfToTxt :: String -> CF -> String cfToTxt name cf = unlines [-			    beginDocument name,-			    introduction,-			    prtTerminals name cf,-			    prtBNF name cf-			    ]+                            beginDocument name,+                            introduction,+                            prtTerminals name cf,+                            prtBNF name cf+                            ]  introduction :: String introduction = concat-	       [-	       "\nThis document was automatically generated by ",-	       "the //BNF-Converter//.",-	       " It was generated together with the lexer, the parser, and the",+               [+               "\nThis document was automatically generated by ",+               "the //BNF-Converter//.",+               " It was generated together with the lexer, the parser, and the",                " abstract syntax module, which guarantees that the document",-	       " matches with the implementation of the language (provided no",+               " matches with the implementation of the language (provided no",                " hand-hacking has taken place).\n"-	       ]+               ]  prtTerminals :: String -> CF -> String prtTerminals name cf = unlines [-			       "==The lexical structure of " ++ name ++ "==",+                               "==The lexical structure of " ++ name ++ "==",                                identSection cf,-			       "===Literals===",+                               "===Literals===",                                prtLiterals name cf,                                unlines (map prtOwnToken (tokenPragmas cf)),-			       "===Reserved words and symbols===",-			       prtReserved name cf,-			       prtSymb name cf,-			       "===Comments===",-			       prtComments $ comments cf-			       ]+                               "===Reserved words and symbols===",+                               prtReserved name cf,+                               prtSymb name cf,+                               "===Comments===",+                               prtComments $ comments cf+                               ]  identSection cf = if not (hasIdent cf) then [] else                     unlines [-			       "===Identifiers===",-			       prtIdentifiers+                               "===Identifiers===",+                               prtIdentifiers                           ]  prtIdentifiers :: String@@ -78,7 +78,7 @@       literals cf  stringLit :: Cat -> String-stringLit cat = unlines $ case (show cat) of+stringLit cat = unlines $ case show cat of   "Char" -> ["Character literals //Char// have the form",              "``'``//c//``'``, where //c// is any single character.",              ""@@ -106,49 +106,47 @@  prtComments :: ([(String,String)],[String]) -> String prtComments (xs,ys) = concat-		   [-		   if (null ys) then-		    "There are no single-line comments in the grammar."-		   else-		    "Single-line comments begin with " ++ sing ++".",-		   if (null xs) then-		    "There are no multiple-line comments in the grammar."-		   else-		   "Multiple-line comments are  enclosed with " ++ mult ++"."-		   ]+                   [+                   if null ys then+                    "There are no single-line comments in the grammar."+                   else+                    "Single-line comments begin with " ++ sing ++".",+                   if null xs then+                    "There are no multiple-line comments in the grammar."+                   else+                   "Multiple-line comments are  enclosed with " ++ mult ++"."+                   ]  where- sing = concat $ intersperse ", " $ map (symbol.prt) ys- mult = concat $ intersperse ", " $-	 map (\(x,y) -> (symbol (prt x))-		       ++ " and " ++-	              (symbol (prt y))) xs+ sing = intercalate ", " $ map (symbol.prt) ys+ mult = intercalate ", " $+         map (\(x,y) -> symbol (prt x) ++ " and " ++ symbol (prt y)) xs  prtSymb :: String -> CF -> String prtSymb name cf = case symbols cf of-		   [] -> "\nThere are no symbols in " ++ name ++ ".\n"+                   [] -> "\nThere are no symbols in " ++ name ++ ".\n"                    xs -> "The symbols used in " ++ name ++ " are the following:\n"                          ++-                         (tabular 4 $ three $ map (symbol.prt) xs)+                         tabular 4 (three $ map (symbol.prt) xs)  prtReserved :: String -> CF -> String prtReserved name cf = case reservedWords cf of-		       [] -> stringRes name ++-			     "\nThere are no reserved words in " ++ name ++ ".\n"+                       [] -> stringRes name +++                             "\nThere are no reserved words in " ++ name ++ ".\n"                        xs -> stringRes name ++-		             (tabular 4 $ three $ map quote xs)+                             tabular 4 (three $ map quote xs)  stringRes :: String -> String stringRes name = concat-		 ["The set of reserved words is the set of terminals ",-		  "appearing in the grammar. Those reserved words ",-		  "that consist of non-letter characters are called symbols, and ",-		  "they are treated in a different way from those that ",-		  "are similar to identifiers. The lexer ",-		  "follows rules familiar from languages ",-		  "like Haskell, C, and Java, including longest match ",-		  "and spacing conventions.",+                 ["The set of reserved words is the set of terminals ",+                  "appearing in the grammar. Those reserved words ",+                  "that consist of non-letter characters are called symbols, and ",+                  "they are treated in a different way from those that ",+                  "are similar to identifiers. The lexer ",+                  "follows rules familiar from languages ",+                  "like Haskell, C, and Java, including longest match ",+                  "and spacing conventions.",                   "\n\n",-		  "The reserved words used in " ++ name ++ " are the following:\n"]+                  "The reserved words used in " ++ name ++ " are the following:\n"]  three :: [String] -> [[String]] three []         = []@@ -159,21 +157,21 @@  prtBNF :: String -> CF -> String prtBNF name cf = unlines [-		     "==The syntactic structure of " ++ name ++"==",-		     "Non-terminals are enclosed between < and >. ",-		     "The symbols " ++ arrow ++ " (production), " +++                     "==The syntactic structure of " ++ name ++"==",+                     "Non-terminals are enclosed between < and >. ",+                     "The symbols " ++ arrow ++ " (production), " ++                       delimiter ++" (union) ",-		     "and " ++ empty ++ " (empty rule) belong to the BNF notation. ",-		     "All other symbols are terminals.",+                     "and " ++ empty ++ " (empty rule) belong to the BNF notation. ",+                     "All other symbols are terminals.",                      "",-		     prtRules (ruleGroups cf)-		     ]+                     prtRules (ruleGroups cf)+                     ]  prtRules :: [(Cat,[Rule])] -> String prtRules          [] = [] prtRules ((c,[]):xs)     = tabular 3 [[nonterminal c,arrow,[]]] ++ prtRules xs-prtRules ((c,(r:rs)):xs)+prtRules ((c, r : rs) : xs)     = tabular 3 ([[nonterminal c,arrow,prtSymbols $ rhsRule r]] ++                  [[[],delimiter,prtSymbols (rhsRule y)] | y <-  rs]) ++     ---  "\n\n" ++ --- with empty lines good for latex, bad for html@@ -181,7 +179,7 @@  prtSymbols :: [Either Cat String] -> String prtSymbols [] = empty-prtSymbols xs = foldr (+++) [] (map p xs)+prtSymbols xs = foldr ((+++) . p) [] xs  where p (Left  r) = nonterminal r        p (Right r) = terminal r 
+ src/BNFC/Backend/Utils.hs view
@@ -0,0 +1,21 @@+-- | Functions that are used in multiple backends+module BNFC.Backend.Utils (isTokenType) where++import BNFC.CF (Cat(..))++-- | Checks if a category is a token type (either built-in or user-defined)+-- The first argument is the list of user-defined token type.+-- >>> isTokenType [] (Cat "Integer")+-- True+-- >>> isTokenType [Cat "Abc"] (Cat "Abc")+-- True+-- >>> isTokenType [] (Cat "Abc")+-- False+isTokenType :: [Cat] -> Cat -> Bool+isTokenType _ (Cat "Integer") = True+isTokenType _ (Cat "Char") = True+isTokenType _ (Cat "String") = True+isTokenType _ (Cat "Double") = True+isTokenType _ (Cat "Ident") = True+isTokenType user cat | cat `elem` user = True+isTokenType _ _ = False
src/BNFC/Backend/XML.hs view
@@ -28,6 +28,7 @@ import BNFC.Backend.Haskell.HsOpts (xmlFile, xmlFileM, absFileM) import Data.List (intersperse, intercalate) import Data.Char(toLower)+import Data.Maybe (fromMaybe)  type Coding = Bool ---- change to at least three values @@ -87,7 +88,7 @@ -- to show both types and constructors as tags; -- lengthy, but validation guarantees type correctness -- flag -xmlt-elemDataConstrs cf (cat,fcs) = elemc cat ([(f,rhsCat cf f cs) | (f,cs) <- fcs])+elemDataConstrs cf (cat,fcs) = elemc cat [(f,rhsCat cf f cs) | (f,cs) <- fcs] efunDefConstrs = "elemFun i t x = [replicate (i+i) ' ' ++ tag t ++ \" \" ++ etag x]" endtagDefConstrs = "endtag f c = tag (\"/\" ++ c)" @@ -95,7 +96,7 @@ -- to show constructors as empty tags; -- shorter than 0, but validation still guarantees type correctness -- flag -xmlt-elemDataConstr cf (cat,fcs) = elemc cat ([(f,rhsCat cf f cs) | (f,cs) <- fcs])+elemDataConstr cf (cat,fcs) = elemc cat [(f,rhsCat cf f cs) | (f,cs) <- fcs] efunDefConstr = "elemFun i t x = [replicate (i+i) ' ' ++ tag t ++ \" \" ++ etag x]" endtagDefConstr = "endtag f c = tag (\"/\" ++ c)" @@ -116,7 +117,7 @@  rhsCat :: CF -> Fun -> [Cat] -> String rhsCat cf fun cs = parenth (intercalate ", " (fun:map (symbCat cf) cs))-rhsCatNot cf cs = if null cs then "EMPTY" else concat (intersperse ", " (map (symbCatNot cf) cs))+rhsCatNot cf cs = if null cs then "EMPTY" else intercalate", " (map (symbCatNot cf) cs)  symbCat cf c   | isList c  = show (normCatOfList c) ++ if isEmptyListCat cf c then "*" else "+"@@ -181,14 +182,14 @@ doubleRule cf = showsPrintRule cf "Double" stringRule cf = showsPrintRule cf "Char" ++++ "  prtList i xs = elemTok i \"String\" xs" -showsPrintRule _ t = unlines $ [+showsPrintRule _ t = unlines [   "instance XPrint " ++ t ++ " where",   "  prt i x = elemTokS i" +++ "\"" ++ t ++ "\"" +++ "x"   ]  identRule cf = ownPrintRule cf (Cat "Ident") -ownPrintRule cf cat = unlines $ [+ownPrintRule cf cat = unlines [   "instance XPrint " ++ show cat ++ " where",   "  prt i (" ++ show cat ++ posn ++ ") = elemTok i" +++ "\"" ++ show cat ++ "\"" +++ "x"   ]@@ -202,7 +203,7 @@    toArgs (cons,args) = ((cons, names (map (checkRes . var) args) (0 :: Int)), ruleOf cons)    names [] _ = []    names (x:xs) n-     | elem x xs = (x ++ show n) : names xs (n+1)+     | x `elem` xs = (x ++ show n) : names xs (n+1)      | otherwise = x             : names xs n    var (ListCat c)  = var c ++ "s"    var (Cat "Ident")   = "id"@@ -212,12 +213,12 @@    var (Cat "Double")  = "d"    var cat            = map toLower (show cat)    checkRes s-        | elem s reservedHaskell = s ++ "'"-	| otherwise              = s+        | s `elem` reservedHaskell = s ++ "'"+        | otherwise              = s    reservedHaskell = ["case","class","data","default","deriving","do","else","if",-			  "import","in","infix","infixl","infixr","instance","let","module",-			  "newtype","of","then","type","where","as","qualified","hiding"]-   ruleOf s = maybe undefined id $ lookupRule s (rulesOfCF cf)+                          "import","in","infix","infixl","infixr","instance","let","module",+                          "newtype","of","then","type","where","as","qualified","hiding"]+   ruleOf s = fromMaybe undefined $ lookupRule s (rulesOfCF cf)  --- case_fun :: Cat -> [(Constructor,Rule)] -> String case_fun cat xs = unlines [
src/BNFC/CF.hs view
@@ -19,73 +19,77 @@ -}  module BNFC.CF (-	    -- Types.-	    CF,+            -- Types.+            CF,             CFG(..), pragmasOfCF, -- ...-	    Rule, Rul(..), lookupRule,-	    Pragma(..),-	    Exp(..),-	    Literal,-	    Symbol,-	    KeyWord,+            Rule, Rul(..), lookupRule,+            Pragma(..),+            Exp(..),+            Literal,+            Symbol,+            KeyWord,             Cat(..), strToCat,             catString, catInteger, catDouble, catChar, catIdent,             NonTerminal,-	    Fun,-	    Tree(..),-	    prTree,         -- print an abstract syntax tree-	    Data,           -- describes the abstract syntax of a grammar-	    cf2data,        -- translates a grammar to a Data object.-	    cf2dataLists,   -- translates to a Data with List categories included.-	    -- Literal categories, constants,-	    firstCat,       -- the first value category in the grammar.-	    firstEntry,     -- the first entry or the first value category-	    specialCats,    -- ident-	    specialCatsP,   -- all literals-	    specialData,    -- special data-	    isCoercion,     -- wildcards in grammar (avoid syntactic clutter)-	    isDefinedRule,  -- defined rules (allows syntactic sugar)-	    isProperLabel,  -- not coercion or defined rule-	    allCats,        -- all categories of a grammar+            Fun,+            Tree(..),+            prTree,         -- print an abstract syntax tree+            Data,           -- describes the abstract syntax of a grammar+            cf2data,        -- translates a grammar to a Data object.+            cf2dataLists,   -- translates to a Data with List categories included.+            getAbstractSyntax,+            -- Literal categories, constants,+            firstCat,       -- the first value category in the grammar.+            firstEntry,     -- the first entry or the first value category+            specialCats,    -- ident+            specialCatsP,   -- all literals+            specialData,    -- special data+            isCoercion,     -- wildcards in grammar (avoid syntactic clutter)+            isDefinedRule,  -- defined rules (allows syntactic sugar)+            isProperLabel,  -- not coercion or defined rule+            allCats,        -- all categories of a grammar             allCatsNorm,-	    allCatsIdNorm,-	    allEntryPoints,-	    reservedWords,+            allCatsIdNorm,+            allEntryPoints,+            reservedWords,             cfTokens,-	    symbols,-	    literals,-	    reversibleCats,-	    findAllReversibleCats, -- find all reversible categories-	    identCat,       -- transforms '[C]' to ListC (others, unchanged).-	    isParsable,-	    rulesOfCF,      -- All rules of a grammar.-	    rulesForCat,    -- rules for a given category-	    ruleGroups,     -- Categories are grouped with their rules.+            symbols,+            literals,+            reversibleCats,+            findAllReversibleCats, -- find all reversible categories+            identCat,       -- transforms '[C]' to ListC (others, unchanged).+            isParsable,+            rulesOfCF,      -- All rules of a grammar.+            rulesForCat,    -- rules for a given category+            rulesForNormalizedCat,    -- rules for a given category+            ruleGroups,     -- Categories are grouped with their rules.             ruleGroupsInternals, --As above, but includes internal cats.             notUniqueNames, -- list of not unique names (replaces the following 2)---	    notUniqueFuns,   -- Returns a list of function labels that are not unique.+--          notUniqueFuns,   -- Returns a list of function labels that are not unique. --            badInheritence, -- Returns a list of all function labels that can cause problems in languages with inheritence.-	    isList,         -- Checks if a category is a list category.-	    -- Information functions for list functions.-	    isNilFun,       -- empty list function? ([])-	    isOneFun,       -- one element list function? (:[])+            isList,         -- Checks if a category is a list category.+            isTokenCat,+            -- Information functions for list functions.+            isNilFun,       -- empty list function? ([])+            isOneFun,       -- one element list function? (:[])             hasOneFunc,             getCons,-	    isConsFun,      -- constructor function? (:)-	    isNilCons,      -- either three of above?+            getSeparatorByPrecedence,+            isConsFun,      -- constructor function? (:)+            isNilCons,      -- either three of above?             isEmptyListCat, -- checks if the list permits []-	    revSepListRule, -- reverse a rule, if it is of form C t [C].-	    normCat,+            revSepListRule, -- reverse a rule, if it is of form C t [C].+            normCat,             isDataCat,-	    normCatOfList,  -- Removes precendence information and enclosed List. C1 => C, C2 => C-	    catOfList,-	    comments,       -- translates the pragmas into two list containing the s./m. comments+            normCatOfList,  -- Removes precendence information and enclosed List. C1 => C, C2 => C+            catOfList,+            comments,       -- translates the pragmas into two list containing the s./m. comments             tokenPragmas,   -- get the user-defined regular expression tokens             tokenNames,     -- get the names of all user-defined tokens-	    precCat,        -- get the precendence level of a Cat C1 => 1, C => 0-	    precLevels,     -- get all precendence levels in the grammar, sorted in increasing order.-	    precRule,       -- get the precendence level of the value category of a rule.-	    precCF,         -- Check if the CF consists of precendence levels.+            precCat,        -- get the precendence level of a Cat C1 => 1, C => 0+            precLevels,     -- get all precendence levels in the grammar, sorted in increasing order.+            precRule,       -- get the precendence level of the value category of a rule.+            precCF,         -- Check if the CF consists of precendence levels.             isUsedCat,             isPositionCat,             hasIdent,@@ -95,7 +99,7 @@              CFP,            -- CF with profiles             RuleP,-	    FunP,+            FunP,             Prof,             cf2cfpRule,             cf2cfp,@@ -106,7 +110,8 @@            ) where  import BNFC.Utils (prParenth,(+++))-import Data.List (nub, intersperse, sort, group, intercalate, find)+import Control.Monad (guard)+import Data.List (nub, intersperse, sort, group, intercalate, find, sortBy) import Data.Char import AbsBNF (Reg()) import ParBNF (pCat)@@ -159,39 +164,39 @@  -- Expressions for function definitions data Exp = App String [Exp]-	 | LitInt Integer-	 | LitDouble Double-	 | LitChar Char-	 | LitString String+         | LitInt Integer+         | LitDouble Double+         | LitChar Char+         | LitString String   deriving (Eq)  instance Show Exp where     showsPrec p e =-	case listView e of-	    Right es	->-		showString "["-		. foldr (.) id (intersperse (showString ", ") $ map shows es)-		. showString "]"-	    Left (App x []) -> showString x-	    Left (App  "(:)" [e1,e2]) ->-		showParen (p>0)-		$ showsPrec 1 e1-		. showString " : "-		. shows e2-	    Left (App x es) ->-		showParen (p>1)-		$ foldr (.) id-		$ intersperse (showString " ")-		$ showString x : map (showsPrec 2) es-	    Left (LitInt n)	-> shows n-	    Left (LitDouble x)	-> shows x-	    Left (LitChar c)	-> shows c-	    Left (LitString s)	-> shows s-	where-	    listView (App "[]" []) = Right []-	    listView (App "(:)" [e1,e2])-		| Right es <- listView e2   = Right $ e1:es-	    listView x = Left x+        case listView e of+            Right es    ->+                showString "["+                . foldr (.) id (intersperse (showString ", ") $ map shows es)+                . showString "]"+            Left (App x []) -> showString x+            Left (App  "(:)" [e1,e2]) ->+                showParen (p>0)+                $ showsPrec 1 e1+                . showString " : "+                . shows e2+            Left (App x es) ->+                showParen (p>1)+                $ foldr (.) id+                $ intersperse (showString " ")+                $ showString x : map (showsPrec 2) es+            Left (LitInt n)     -> shows n+            Left (LitDouble x)  -> shows x+            Left (LitChar c)    -> shows c+            Left (LitString s)  -> shows s+        where+            listView (App "[]" []) = Right []+            listView (App "(:)" [e1,e2])+                | Right es <- listView e2   = Right $ e1:es+            listView x = Left x  -- | Pragmas data Pragma = CommentS  String -- ^ for single line comments@@ -201,13 +206,13 @@             | Layout [String]             | LayoutStop [String]             | LayoutTop-	    | FunDef String [String] Exp+            | FunDef String [String] Exp             -- ...-	      deriving (Show)+              deriving (Show)  -- | User-defined regular expression tokens tokenPragmas :: CFG f -> [(Cat,Reg)]-tokenPragmas cf = [(Cat name,e) | TokenReg name _ e <- pragmasOfCF cf]+tokenPragmas cf = [(TokenCat name,e) | TokenReg name _ e <- pragmasOfCF cf]  -- | The names of all user-defined tokens tokenNames :: CFG f -> [String]@@ -225,36 +230,47 @@   (t,ws,_) -> t || not (null ws)   -- (True,[],_) means: top-level layout only  -- | Literal: Char, String, Ident, Integer, Double-type Literal = Cat+type Literal = String type Symbol  = String type KeyWord = String +------------------------------------------------------------------------------+-- Categories+------------------------------------------------------------------------------+ -- | Categories are the Non-terminals of the grammar.-data Cat = InternalCat           -- | Internal category, inserted in 1st-                                      -- position in "internal" rules,-                                      -- essentially ensuring that they are-                                      -- never parsed.-              | Cat String-              | ListCat Cat-              | CoercCat String Integer+data Cat = InternalCat       -- | Internal category, inserted in 1st+                             -- position in "internal" rules,+                             -- essentially ensuring that they are+                             -- never parsed.+         | Cat String+         | TokenCat String   -- ^ Token types (like Ident)+         | ListCat Cat+         | CoercCat String Integer   deriving (Eq, Ord)+ -- An alias for Cat used in many backends: type NonTerminal = Cat --- | Show instance for category symbols--- >>> show (Cat "Def")+-- | Render category symbols as strings+-- >>> catToStr (Cat "Def") -- "Def"--- >>> show (ListCat (Cat "Thing"))+-- >>> catToStr (ListCat (Cat "Thing")) -- "[Thing]"--- >>> show (CoercCat "Expr" 3)+-- >>> catToStr (CoercCat "Expr" 3) -- "Expr3"--- >>> show (ListCat (CoercCat "Expr" 2))+-- >>> catToStr (ListCat (CoercCat "Expr" 2)) -- "[Expr2]"+-- >>> catToStr (TokenCat "Abc")+-- "Abc"+catToStr InternalCat = "#"+catToStr (Cat s) = s+catToStr (TokenCat s) = s+catToStr (ListCat c) = "[" ++ show c ++ "]"+catToStr (CoercCat s i) = s ++ show i+ instance Show Cat where-  show InternalCat = "#"-  show (Cat s) = s-  show (ListCat c) = "[" ++ show c ++ "]"-  show (CoercCat s i) = s ++ show i+  show = catToStr  -- | Reads a string into a category. This should only needs to handle -- the case of simple categories (with or without coercion) since list@@ -277,20 +293,125 @@   where cat2cat (AbsBNF.IdCat (AbsBNF.Ident i)) =             case span isDigit (reverse i) of                 ([],c') -> Cat (reverse c')-	        (d,c') ->  CoercCat (reverse c') (read (reverse d))+                (d,c') ->  CoercCat (reverse c') (read (reverse d))         cat2cat (AbsBNF.ListCat c) = ListCat (cat2cat c)  -- Build-in categories contants catString, catInteger, catDouble, catChar, catIdent :: Cat-catString  = Cat "String"-catInteger = Cat "Integer"-catDouble  = Cat "Double"-catChar    = Cat "Char"-catIdent   = Cat "Ident"+catString  = TokenCat "String"+catInteger = TokenCat "Integer"+catDouble  = TokenCat "Double"+catChar    = TokenCat "Char"+catIdent   = TokenCat "Ident" +-- the parser needs these+specialCatsP :: [String]+specialCatsP = words "Ident Integer String Char Double"++-- | Does the category correspond to a data type?+isDataCat :: Cat -> Bool+isDataCat c = isDataOrListCat c && not (isList c)++isDataOrListCat :: Cat -> Bool+isDataOrListCat (CoercCat _ _)  = False+isDataOrListCat (Cat ('@':_))   = False+isDataOrListCat (ListCat c)     = isDataOrListCat c+isDataOrListCat _               = True++-- | Categories C1, C2,... (one digit in end) are variants of C. This function+-- returns true if two category are variants of the same abstract category.+-- E.g.+--+-- >>> eqCat (Cat "Abc") (Cat "Abc")+-- True+-- >>> eqCat (CoercCat "Abc" 3) (CoercCat "Abc" 5)+-- True+-- >>> eqCat (CoercCat "Acb" 4) (CoercCat "Abc" 4)+-- False+-- >>> eqCat (Cat "Abc") (CoercCat "Abc" 44)+-- True+eqCat :: Cat -> Cat -> Bool+eqCat (CoercCat c1 _) (CoercCat c2 _) = c1 == c2+eqCat (Cat c1 ) (CoercCat c2 _) = c1 == c2+eqCat (CoercCat c1 _) (Cat c2) = c1 == c2+eqCat c1 c2 = c1 == c2++++-- | Removes precendence information. C1 => C, [C2] => [C]+normCat :: Cat -> Cat+normCat (ListCat c) = ListCat (normCat c)+normCat (CoercCat c _) = Cat c+normCat c = c++normCatOfList :: Cat -> Cat+normCatOfList = normCat . catOfList++-- | When given a list Cat, i.e. '[C]', it removes the square+-- brackets, and adds the prefix List, i.e. 'ListC'.  (for Happy and+-- Latex)+-- >>> identCat (ListCat (Cat "C")) -- [C]+-- "ListC"+-- >>> identCat (CoercCat "C" 3)+-- "C3"+identCat :: Cat -> String+identCat (ListCat c) = "List" ++ identCat c+identCat c = show c++isList :: Cat -> Bool+isList (ListCat _) = True+isList _           = False++isTokenCat :: Cat -> Bool+isTokenCat (TokenCat _) = True+isTokenCat _            = False++-- | Unwraps the list constructor from the category name. Eg. [C1] => C1+-- E.g.+-- >>> catOfList (ListCat (Cat "A"))+-- A+-- >>> catOfList (Cat "B")+-- B+catOfList :: Cat -> Cat+catOfList (ListCat c) = c+catOfList c = c+------------------------------------------------------------------------------+-- Functions+------------------------------------------------------------------------------ -- | Fun is the function name of a rule. type Fun     = String -- | Either Cat or Fun+++-- | Is this function just a coercion? (Ie. the identity)+isCoercion :: Fun -> Bool+isCoercion = (== "_") -- perhaps this should be changed to "id"?++isDefinedRule :: Fun -> Bool+isDefinedRule (x:_) = isLower x+isDefinedRule [] = error "isDefinedRule: empty function name"++isProperLabel :: Fun -> Bool+isProperLabel f = not (isCoercion f || isDefinedRule f)+++-- | FIXME: This is a copy of the old normCat function that some backend use+-- on Fun. Now that the type of Cat has changed, this is no longer possible+-- so this is added for those odd cases. It should be verified if this is+-- really necessary.+normFun :: Fun -> Fun+normFun f = case f of+    '[':cs -> "[" ++ norm (init cs) ++ "]"+    _     -> norm f+  where norm = reverse . dropWhile isDigit . reverse++isNilFun, isOneFun, isConsFun, isNilCons,isConcatFun :: Fun -> Bool+isNilCons f = isNilFun f || isOneFun f || isConsFun f || isConcatFun f+isNilFun f  = f == "[]"+isOneFun f  = f == "(:[])"+isConsFun f = f == "(:)"+isConcatFun f = f == "(++)"+------------------------------------------------------------------------------ type Name = String  -- | Abstract syntax tree.@@ -305,8 +426,8 @@  firstEntry :: CF -> Cat firstEntry cf = case allEntryPoints cf of-		 (x:_) -> x-		 _     -> firstCat cf+                 (x:_) -> x+                 _     -> firstCat cf  rulesOfCF   :: CFG f -> [Rul f] rulesOfCFP  :: CFP -> [RuleP]@@ -341,6 +462,13 @@ rulesForCat :: CF -> Cat -> [Rule] rulesForCat cf cat = [r | r <- rulesOfCF cf, isParsable r, valCat r == cat] +-- | Like rulesForCat but for normalized value categories.+-- I.e., `rulesForCat (Cat "Exp")` will return rules for category Exp but also+-- Exp1, Exp2... in case of coercion+rulesForNormalizedCat :: CF -> Cat -> [Rule]+rulesForNormalizedCat cf cat =+    [r | r <- rulesOfCF cf, isParsable r, normCat (valCat r) == cat]+ -- | As rulesForCat, but this version doesn't exclude internal rules. rulesForCat' :: CF -> Cat -> [Rule] rulesForCat' cf cat = [r | r <- rulesOfCF cf, valCat r == cat]@@ -371,7 +499,7 @@  -- | Get all literals of a grammar. (e.g. String, Double) literals :: CFG f -> [Cat]-literals cf = lits ++ owns+literals cf = [TokenCat l | l <- lits] ++ owns  where    (lits,_,_,_) = infoOfCF cf    owns = map fst (tokenPragmas cf)@@ -400,8 +528,8 @@ -- | Comments can be defined by the 'comment' pragma comments :: CF -> ([(String,String)],[String]) comments cf = case commentPragmas (pragmasOfCF cf) of-	       xs -> ([p | CommentM p <- xs],-		      [s | CommentS s <- xs])+               xs -> ([p | CommentM p <- xs],+                      [s | CommentS s <- xs])  -- built-in categories (corresponds to lexer) @@ -415,11 +543,7 @@ -- | Categories corresponding to tokens. These end up in the -- AST. (unlike tokens returned by 'cfTokens') specialCats :: CF -> [Cat]-specialCats cf = (if hasIdent cf then (Cat "Ident":) else id) (map fst (tokenPragmas cf))---- the parser needs these-specialCatsP :: [Cat]-specialCatsP = map Cat $ words "Ident Integer String Char Double"+specialCats cf = (if hasIdent cf then (TokenCat "Ident":) else id) (map fst (tokenPragmas cf))  -- to print parse trees prTree :: Tree -> String@@ -427,13 +551,40 @@ prTree (Tree (fun,trees)) = fun +++ unwords (map pr2 trees) where   pr2 t@(Tree (_,ts)) = (if null ts then id else prParenth) (prTree t) --- abstract syntax trees: data type definitions +++-- * abstract syntax trees: data type definitions+--+-- The abstract syncax, instanciated by the Data type, is the type signatures+-- of all the constructors.++-- | Return the abstract syntax of the grammar.+-- All categories are normalized, so a rule like:+--     EAdd . Exp2 ::= Exp2 "+" Exp3 ;+-- Will give the following signature: EAdd : Exp -> Exp -> Exp+getAbstractSyntax :: CF -> [(Cat, [(Fun, [Cat])])]+getAbstractSyntax cf = [ ( c, nub (constructors c) ) | c <- allCatsNorm cf ]+  where+    constructors cat = do+        rule <- rulesOfCF cf+        let f = funRule rule+        guard $ not (isDefinedRule f)+        guard $ not (isCoercion f)+        guard $ normCat (valCat rule) == cat+        let cs = [normCat c | Left c <- rhsRule rule, c /= InternalCat]+        return (f, cs)+++-- All the function bellow are variation arround the idea of getting the+-- abstract syntax of the grammar with some variation but they seem to do a+-- poor job at handling corner cases involving coercions. Use getAbstractSyntax+-- instead if possible. cf2data' :: (Cat -> Bool) -> CF -> [Data] cf2data' predicate cf =   [(cat, nub (map mkData [r | r <- rulesOfCF cf,                               let f = funRule r,-			      not (isDefinedRule f),+                              not (isDefinedRule f),                               not (isCoercion f), eqCat cat (valCat r)]))       | cat <- filter predicate (allCats cf)]  where@@ -442,115 +593,26 @@ cf2data :: CF -> [Data] cf2data = cf2data' isDataCat --- | Does the category correspond to a data type?-isDataCat :: Cat -> Bool-isDataCat c = isDataOrListCat c && not (isList c) -isDataOrListCat :: Cat -> Bool-isDataOrListCat (CoercCat _ _)  = False-isDataOrListCat (Cat ('@':_))   = False-isDataOrListCat _               = True- cf2dataLists :: CF -> [Data] cf2dataLists = cf2data' isDataOrListCat  specialData :: CF -> [Data]-specialData cf = [(c,[(show c,[Cat "String"])]) | c <- specialCats cf] where-+specialData cf = [(c,[(show c,[TokenCat "String"])]) | c <- specialCats cf] where  -- to deal with coercions  -- the Haskell convention: the wildcard _ is not a constructor --- | Is this function just a coercion? (Ie. the identity)-isCoercion :: Fun -> Bool-isCoercion = (== "_") -- perhaps this should be changed to "id"? -isDefinedRule :: Fun -> Bool-isDefinedRule (x:_) = isLower x-isDefinedRule [] = error "isDefinedRule: empty function name" -isProperLabel :: Fun -> Bool-isProperLabel f = not (isCoercion f || isDefinedRule f)---- | Categories C1, C2,... (one digit in end) are variants of C. This function--- returns true if two category are variants of the same abstract category.--- E.g.------ >>> eqCat (Cat "Abc") (Cat "Abc")--- True--- >>> eqCat (CoercCat "Abc" 3) (CoercCat "Abc" 5)--- True--- >>> eqCat (CoercCat "Acb" 4) (CoercCat "Abc" 4)--- False--- >>> eqCat (Cat "Abc") (CoercCat "Abc" 44)--- True-eqCat :: Cat -> Cat -> Bool-eqCat (CoercCat c1 _) (CoercCat c2 _) = c1 == c2-eqCat (Cat c1 ) (CoercCat c2 _) = c1 == c2-eqCat (CoercCat c1 _) (Cat c2) = c1 == c2-eqCat c1 c2 = c1 == c2------ | Removes precendence information. C1 => C, [C2] => [C]-normCat :: Cat -> Cat-normCat (ListCat c) = ListCat (normCat c)-normCat (CoercCat c _) = Cat c-normCat c = c--normCatOfList :: Cat -> Cat-normCatOfList = normCat . catOfList---- | When given a list Cat, i.e. '[C]', it removes the square--- brackets, and adds the prefix List, i.e. 'ListC'.  (for Happy and--- Latex)--- >>> identCat (ListCat (Cat "C")) -- [C]--- "ListC"--- >>> identCat (CoercCat "C" 3)--- "C3"-identCat :: Cat -> String-identCat (ListCat c) = "List" ++ identCat c-identCat c = show c---- | FIXME: This is a copy of the old normCat function that some backend use--- on Fun. Now that the type of Cat has changed, this is no longer possible--- so this is added for those odd cases. It should be verified if this is--- really necessary.-normFun :: Fun -> Fun-normFun f = case f of-    '[':cs -> "[" ++ norm (init cs) ++ "]"-    _     -> norm f-  where norm = reverse . dropWhile isDigit . reverse-- -- | Checks if the rule is parsable. isParsable :: Rul f -> Bool isParsable (Rule _ _ (Left c:_)) = c /= InternalCat isParsable _ = True -isList :: Cat -> Bool-isList (ListCat _) = True-isList _ = False  --- | Unwraps the list constructor from the category name. Eg. [C1] => C1--- E.g.--- >>> catOfList (ListCat (Cat "A"))--- A--- >>> catOfList (Cat "B")--- B-catOfList :: Cat -> Cat-catOfList (ListCat c) = c-catOfList c = c--isNilFun, isOneFun, isConsFun, isNilCons,isConcatFun :: Fun -> Bool-isNilCons f = isNilFun f || isOneFun f || isConsFun f || isConcatFun f-isNilFun f  = f == "[]"-isOneFun f  = f == "(:[])"-isConsFun f = f == "(:)"-isConcatFun f = f == "(++)"- -- | Checks if the list has a non-empty rule. hasOneFunc :: [Rule] -> Bool hasOneFunc = any (isOneFun . funRule)@@ -566,6 +628,12 @@     seper (Right x:_) = x     seper (Left _:xs) = seper xs +-- | Helper function that gets the list separator by precedence level+getSeparatorByPrecedence :: [Rule] -> [(Integer,String)]+getSeparatorByPrecedence rules = [ (p, getCons (getRulesFor p)) | p <- precedences ]+  where+    precedences = sortBy (flip compare) $ nub $ map precRule rules+    getRulesFor p = [ r | r <- rules, precRule r == p ]  isEmptyListCat :: CF -> Cat -> Bool isEmptyListCat cf c = elem "[]" $ map funRule $ rulesForCat' cf c@@ -606,9 +674,10 @@ -- -- But! -- >>> precCat (ListCat (CoercCat "Abc" 2))--- 0+-- 2 precCat :: Cat -> Integer precCat (CoercCat _ i) = i+precCat (ListCat c) = precCat c precCat _ = 0  precRule :: Rule -> Integer@@ -623,8 +692,7 @@  -- | Does the category have a position stored in AST? isPositionCat :: CFG f -> Cat -> Bool-isPositionCat cf cat =  or [b | TokenReg name b _ <- pragmasOfCF cf, Cat name == cat]-+isPositionCat cf cat =  or [b | TokenReg name b _ <- pragmasOfCF cf, TokenCat name == cat]  -- | Grammar with permutation profile à la GF. AR 22/9/2004 type CFP   = CFG FunP -- (Exts,[RuleP])
src/BNFC/GetCF.hs view
@@ -27,50 +27,58 @@ import BNFC.TypeChecker import BNFC.Utils -import Control.Monad (liftM)+import Control.Arrow (left)+import Control.Monad.State import Data.Char import Data.Either (partitionEithers) import Data.List(nub,partition)-import Data.Maybe (catMaybes)+import Data.Maybe (mapMaybe) import ErrM +-- $setup+-- >>> import PrintBNF+ parseCF :: SharedOptions -> Target -> String -> IO CF parseCF opts t s = liftM cfp2cf (parseCFP opts t s)  parseCFP :: SharedOptions -> Target -> String -> IO CFP parseCFP opts target content = do-  let (cfp,msgs1) = getCFP (cnf opts) content-      cf = cfp2cf cfp-      msgs2 = case checkDefinitions cf of-        Bad err -> [err]-        Ok ()   -> []-      msgs3 = checkTokens cf-      msg = msgs1++msgs2 -- ++ msgs3 -- in a future version+  cfp <- runErr $ pGrammar (myLexer content)+                    >>= expandRules+                    >>= getCFP (cnf opts)+                    >>= markTokenCategories+  let cf = cfp2cf cfp+  runErr $ checkDefinitions cf+  let msgs3 = checkTokens cf    let reserved = [lang opts | target == TargetJava ] +  -- Warn of fail if the grammar use non unique names   case filter (not . isDefinedRule) $ notUniqueNames reserved cf of-    ns@(_:_)-      | not (target `elem` [TargetHaskell,TargetHaskellGadt,TargetOCaml]) -> do-        fail $ "ERROR: names not unique: " ++ unwords ns-    ns -> do-      case ns of-        _:_ -> do-          putStrLn $ "Warning: names not unique: " ++ unwords ns-          putStrLn "This can be an error in other back ends."-        _ -> return ()-      putStrLn $ unlines msgs3-      if not (null msg) then do-         fail $ unlines msg-       else do-         putStrLn $ show (length (rulesOfCF cf)) +++ "rules accepted\n"-         let c3s = [(b,e) | (b,e) <- fst (comments cf), length b > 2 || length e > 2]-         if null c3s then return () else do-           putStrLn-             "Warning: comment delimiters longer than 2 characters ignored in Haskell:"-           mapM_ putStrLn [b +++ "-" +++ e | (b,e) <- c3s]-         return cfp+    [] -> return ()+    ns| target `notElem` [TargetHaskell,TargetHaskellGadt,TargetOCaml]+      -> fail $ "ERROR: names not unique: " ++ unwords ns+      | otherwise+      -> do putStrLn $ "Warning: names not unique: " ++ unwords ns+            putStrLn "This can be an error in other back ends." +  -- Print msgs3+  putStrLn $ unlines msgs3++  -- Print the number of rules+  putStrLn $ show (length (rulesOfCF cf)) +++ "rules accepted\n"++  -- Print a warning if comment delimiter are bigger than 2 characters+  let c3s = [(b,e) | (b,e) <- fst (comments cf), length b > 2 || length e > 2]+  unless (null c3s) $do+      putStrLn "Warning: comment delimiters longer than 2 characters ignored in Haskell:"+      mapM_ putStrLn [b +++ "-" +++ e | (b,e) <- c3s]+  return cfp++  where+    runErr (Ok a) = return a+    runErr (Bad msg) = fail msg+ {-     case filter (not . isDefinedRule) $ notUniqueFuns cf of      [] -> case (badInheritence cf) of@@ -97,29 +105,53 @@           return (ret,True) -} -nilCFP :: CFP-nilCFP = CFG (([],([],[],[],[])),[])+getCFP :: Bool -> Abs.Grammar -> Err CFP+getCFP cnf (Abs.Grammar defs0) = do+    let rules = inlineDelims rules0+        cf0 = revs srt+        srt = let literals           = nub [lit | xs <- map rhsRule rules,+                                                     Left (Cat lit) <- xs,+                                                     lit `elem` specialCatsP]+                  (symbols,keywords) = partition notIdent reservedWords+                  notIdent s         = null s || not (isAlpha (head s)) || any (not . isIdentRest) s+                  isIdentRest c      = isAlphaNum c || c == '_' || c == '\''+                  reservedWords      = nub [t | r <- rules, Right t <- rhsRule r]+              in CFG((pragma,(literals,symbols,keywords,[])),rules)+        revs cf1@(CFG((pragma,(literals,symbols,keywords,_)),rules)) =+            CFG((pragma,(literals,symbols,keywords,findAllReversibleCats (cfp2cf cf1))),rules)+    case mapMaybe (checkRule (cfp2cf cf0)) (rulesOfCF cf0) of+      [] -> return ()+      msgs -> fail (unlines msgs)+    return cf0+  where+    (pragma,rules0) = partitionEithers $ concatMap transDef defs+    (defs,inlineDelims) = if cnf then (defs0,id) else removeDelims defs0 -getCFP :: Bool -> String -> (CFP,[String])-getCFP cnf s = case pGrammar . myLexer $ s of-  Bad s -> (nilCFP,[s])-  Ok (Abs.Grammar defs0) -> (cf0,msgs)-    where (pragma,rules0) = partitionEithers $ concatMap transDef $ defs-          (defs,inlineDelims) = if cnf then (defs0,id) else removeDelims defs0-          rules = inlineDelims rules0-          msgs = catMaybes $ map (checkRule (cfp2cf cf0)) (rulesOfCF cf0)-          cf0 = revs srt-          srt = let    literals           = nub [lit | xs <- map rhsRule rules,-               	         		         Left lit <- xs,-               	         		         elem lit specialCatsP]-                       (symbols,keywords) = partition notIdent reservedWords-                       notIdent s         = null s || not (isAlpha (head s)) || any (not . isIdentRest) s-                       isIdentRest c      = isAlphaNum c || c == '_' || c == '\''-                       reservedWords      = nub [t | r <- rules, Right t <- rhsRule r]-                   in CFG((pragma,(literals,symbols,keywords,[])),rules)-          revs cf1@(CFG((pragma,(literals,symbols,keywords,_)),rules)) =-              CFG((pragma,(literals,symbols,keywords,findAllReversibleCats (cfp2cf cf1))),rules)+-- | This function goes through each rule of a grammar and replace Cat "X" with+-- TokenCat "X" when "X" is a token type.+markTokenCategories :: CFP -> Err CFP+markTokenCategories (CFG (exts, rules)) = return $ CFG (exts, newRules)+  where+    newRules = [ Rule f (mark c) (map (left mark) rhs) | Rule f c rhs <- rules ]+    tokenCatNames = [ n | TokenReg n _ _ <- fst exts ] ++ specialCatsP+    mark = toTokenCat tokenCatNames ++-- | Change the constructor of categories with the given names from Cat to+-- TokenCat+-- >>> toTokenCat ["A"] (Cat "A") == TokenCat "A"+-- True+-- >>> toTokenCat ["A"] (ListCat (Cat "A")) == ListCat (TokenCat "A")+-- True+-- >>> toTokenCat ["A"] (Cat "B") == Cat "B"+-- True+toTokenCat :: [String] -> Cat -> Cat+toTokenCat ns (Cat a) | a `elem` ns = TokenCat a+toTokenCat ns (ListCat c) = ListCat (toTokenCat ns c)+toTokenCat _ c = c+++ removeDelims :: [Abs.Def] -> ([Abs.Def], [RuleP] -> [RuleP]) removeDelims xs = (ys ++ map delimToSep ds,                    foldr (.) id [map (inlineDelim' d) | d <- ds])@@ -142,7 +174,7 @@      delimToSep (Abs.Delimiters cat _ _ (Abs.SepTerm  s) sz) = Abs.Terminator sz cat s     delimToSep (Abs.Delimiters cat _ _ (Abs.SepSepar s) sz) = Abs.Separator  sz cat s-    delimToSep (Abs.Delimiters cat _ _ (Abs.SepNone   ) sz) = Abs.Terminator sz cat ""+    delimToSep (Abs.Delimiters cat _ _  Abs.SepNone     sz) = Abs.Terminator sz cat ""     delimToSep x = x      transDef :: Abs.Def -> [Either Pragma RuleP]@@ -155,7 +187,7 @@  Abs.PosToken ident reg        -> [Left $ TokenReg (transIdent ident) True reg]  Abs.Entryp idents             -> [Left $ EntryPoints (map (strToCat .transIdent) idents)]  Abs.Internal label cat items  ->-   [Right $ Rule (transLabel label) (transCat cat) (Left InternalCat:(map transItem items))]+   [Right $ Rule (transLabel label) (transCat cat) (Left InternalCat:map transItem items)]  Abs.Separator size ident str -> map  (Right . cf2cfpRule) $ separatorRules size ident str  Abs.Terminator size ident str -> map  (Right . cf2cfpRule) $ terminatorRules size ident str  Abs.Delimiters a b c d e -> map  (Right . cf2cfpRule) $ delimiterRules a b c d e@@ -163,7 +195,7 @@  Abs.Rules ident strs -> map (Right . cf2cfpRule) $ ebnfRules ident strs  Abs.Layout ss      -> [Left $ Layout ss]  Abs.LayoutStop ss  -> [Left $ LayoutStop ss]- Abs.LayoutTop      -> [Left $ LayoutTop]+ Abs.LayoutTop      -> [Left LayoutTop]  Abs.Function f xs e -> [Left $ FunDef (transIdent f) (map transArg xs) (transExp e)]  delimiterRules :: Abs.Cat -> String -> String -> Abs.Separation -> Abs.MinimumSize -> [Rule]@@ -218,7 +250,7 @@  where    c' = transCat c    cs = ListCat c'-   ifEmpty rs = if (size == Abs.MNonempty)+   ifEmpty rs = if size == Abs.MNonempty                 then rs                 else Rule "[]" cs [] : rs @@ -230,9 +262,9 @@  where    c' = transCat c    cs = ListCat c'-   s' its = if null s then its else (Right s : its)-   ifEmpty = if (size == Abs.MNonempty)-                then Rule "(:[])" cs ([Left c'] ++ if null s then [] else [Right s])+   s' its = if null s then its else Right s : its+   ifEmpty = if size == Abs.MNonempty+                then Rule "(:[])" cs (Left c' : if null s then [] else [Right s])                 else Rule "[]" cs []  coercionRules :: Abs.Ident -> Integer -> [Rule]@@ -251,7 +283,7 @@      [Abs.NTerminal n] -> c' ++ identCat (transCat n)      _ -> c' ++ "_" ++ show k    c' = c --- normCat c-   mkName k s = if all (\c -> isAlphaNum c || elem c "_'") s+   mkName k s = if all (\c -> isAlphaNum c || elem c ("_'" :: String)) s                    then s else show k  transItem :: Abs.Item -> Either Cat String@@ -290,16 +322,16 @@ transExp :: Abs.Exp -> Exp transExp e = case e of     Abs.App x es    -> App (transIdent x) (map transExp es)-    Abs.Var x	    -> App (transIdent x) []+    Abs.Var x       -> App (transIdent x) []     Abs.Cons e1 e2  -> cons e1 (transExp e2)-    Abs.List es	    -> foldr cons nil es+    Abs.List es     -> foldr cons nil es     Abs.LitInt x    -> LitInt x     Abs.LitDouble x -> LitDouble x     Abs.LitChar x   -> LitChar x     Abs.LitString x -> LitString x   where     cons e1 e2 = App "(:)" [transExp e1, e2]-    nil	       = App "[]" []+    nil        = App "[]" []  -------------------------------------------------------------------------------- @@ -351,31 +383,87 @@   | badTypeName    = Just $ "Bad type name" +++ unwords (map show badtypes) +++ "in" +++ s   | badFunName     = Just $ "Bad constructor name" +++ f +++ "in" +++ s   | badMissing     = Just $ "No production for" +++ unwords missing ++-                             ", appearing in rule" +++ s+                             ", appearing in rule" +++ s +++ ". Defined categories:" +++ unwords defineds   | otherwise      = Nothing  where    s  = f ++ "." +++ show cat +++ "::=" +++ unwords (map (either show show) rhs) -- Todo: consider using the show instance of Rule    c  = normCat cat    cs = [normCat c | Left c <- rhs]-   badCoercion = isCoercion f && not ([c] == cs) +   badCoercion = isCoercion f && [c] /= cs    badNil      = isNilFun f   && not (isList c && null cs)    badOne      = isOneFun f   && not (isList c && cs == [catOfList c])    badCons     = isConsFun f  && not (isList c && cs == [catOfList c, c])    badList     = isList c     &&                  not (isCoercion f || isNilCons f)-   badSpecial  = elem c specialCatsP && not (isCoercion f)+   badSpecial  = elem c [ Cat x | x <- specialCatsP] && not (isCoercion f)     badMissing  = not (null missing)    missing     = filter nodef [show c | Left c <- rhs]-   nodef t = notElem t defineds+   nodef t = t `notElem` defineds    defineds =-    show InternalCat : tokenNames cf ++ (map show specialCatsP) ++ map (show . valCat) (rulesOfCF cf)+    show InternalCat : tokenNames cf ++ specialCatsP ++ map (show . valCat) (rulesOfCF cf)    badTypeName = not (null badtypes)    badtypes = filter isBadType $ cat : [c | Left c <- rhs]    isBadType (ListCat c) = isBadType c    isBadType InternalCat = False    isBadType (CoercCat c _) = isBadCatName c    isBadType (Cat s) = isBadCatName s+   isBadType (TokenCat s) = isBadCatName s    isBadCatName s = not (isUpper (head s) || s == show InternalCat || (head s == '@'))    badFunName = not (all (\c -> isAlphaNum c || c == '_') f {-isUpper (head f)-}                        || isCoercion f || isNilCons f)+++-- | Pre-processor that converts the `rules` macros to regular rules+-- by creating unique function names for them.+-- >>> :{+-- let rules1 = Abs.Rules (Abs.Ident "Foo")+--         [ Abs.RHS [Abs.Terminal "abc"]+--         , Abs.RHS [Abs.NTerminal (Abs.IdCat (Abs.Ident "A"))]+--         , Abs.RHS [Abs.Terminal "foo", Abs.Terminal "bar"]+--         , Abs.RHS [Abs.Terminal "++"]+--         ]+-- in+-- let Ok tree = expandRules (Abs.Grammar [rules1])+-- in putStrLn (printTree tree)+-- :}+-- Foo_abc . Foo ::= "abc" ;+-- FooA . Foo ::= A ;+-- Foo1 . Foo ::= "foo" "bar" ;+-- Foo2 . Foo ::= "++"+--+-- Note that if there are two `rules` macro with the same category, the+-- generated names should be uniques:+-- >>> :{+-- let rules1 = Abs.Rules (Abs.Ident "Foo")+--         [ Abs.RHS [Abs.Terminal "foo", Abs.Terminal "bar"] ]+-- in+-- let rules2 = Abs.Rules (Abs.Ident "Foo")+--         [ Abs.RHS [Abs.Terminal "foo", Abs.Terminal "foo"] ]+-- in+-- let Ok tree = expandRules (Abs.Grammar [rules1, rules2])+-- in putStrLn (printTree tree)+-- :}+-- Foo1 . Foo ::= "foo" "bar" ;+-- Foo2 . Foo ::= "foo" "foo"+--+-- This is using a State monad to remember the last used index for a category.+expandRules :: Abs.Grammar -> Err Abs.Grammar+expandRules (Abs.Grammar defs) =+    return $ Abs.Grammar (concat (evalState (mapM expand defs) []))+  where+    expand (Abs.Rules ident rhss) = mapM (mkRule ident) rhss+    expand other = return [other]+    mkRule :: Abs.Ident -> Abs.RHS -> State [(String, Int)] Abs.Def+    mkRule ident (Abs.RHS rhs) = do+      fun <- liftM (Abs.LabNoP . Abs.Id . Abs.Ident) (mkName ident rhs)+      return (Abs.Rule fun (Abs.IdCat ident) rhs)+    mkName :: Abs.Ident -> [Abs.Item] -> State [(String, Int)] String+    mkName (Abs.Ident cat) [Abs.Terminal s]+      | all (\c -> isAlphaNum c || elem c ("_'" :: String)) s = return (cat ++ "_" ++ s)+    mkName (Abs.Ident cat) [Abs.NTerminal (Abs.IdCat (Abs.Ident s))] =+        return (cat ++ s)+    mkName (Abs.Ident cat) _ = do+        i <- liftM (maybe 1 (+1) . lookup cat) get+        modify ((cat, i):)+        return (cat ++ show i)
+ src/BNFC/Lexing.hs view
@@ -0,0 +1,108 @@+module BNFC.Lexing+    ( mkLexer, LexType(..) ) where++import Control.Arrow ((&&&))+import Data.List (inits)+import AbsBNF (Reg(..))+import PrintBNF+import BNFC.CF+++p :: Reg -> IO ()+p = putStrLn . concat . words . printTree++-- Abstract lexer++data LexType = LexComment | LexToken String | LexSymbols++mkLexer :: CF -> [(Reg, LexType)]+mkLexer cf =+    -- comments+    [ (mkRegSingleLineComment s, LexComment) | s <- snd (comments cf) ]+    +++    [ (mkRegMultilineComment b e, LexComment) | (b,e) <- fst (comments cf) ]+    +++    -- user tokens+    [ (reg, LexToken name) | (Cat name, reg) <- tokenPragmas cf]+    +++    -- predefined tokens+    [ ( regIdent, LexToken "Ident" ) ]+    +++    -- Symbols+    [ (foldl1 RAlt (map RSeqs (symbols cf)), LexSymbols ) ]+    +++    -- Built-ins+    [ ( regInteger, LexToken "Integer")+    , ( regDouble, LexToken "Double" )+    , ( regString, LexToken "String" )+    , ( regChar, LexToken "Char" ) ]+++(<>) = RSeq+(<|>) = RAlt++-- Bult-in tokens+-- the tests make sure that they correspond to what is in the LBNF reference++-- | Ident regex+-- >>> p regIdent+-- letter(letter|digit|'_'|'\'')*+regIdent :: Reg+regIdent = RLetter <> RStar (RLetter <|> RDigit <|> RChar '_' <|> RChar '\'')++-- | Integer regex+-- >>> p regInteger+-- digit++regInteger :: Reg+regInteger = RPlus RDigit++-- | String regex+-- >>> p regString+-- '"'(char-["\"\\"]|'\\'["\"\\nt"])*'"'+regString :: Reg+regString = RChar '"'+            <> RStar ( RMinus RAny (RAlts "\"\\")+                       <|> (RChar '\\' <> RAlts "\"\\nt"))+            <> RChar '"'++-- | Char regex+-- >>> p regChar+-- '\''(char-["'\\"]|'\\'["'\\nt"])'\''+regChar :: Reg+regChar = RChar '\''+          <> (RMinus RAny (RAlts "'\\") <|> (RChar '\\' <> RAlts "'\\nt"))+          <> RChar '\''++-- | Double regex+-- >>> p regDouble+-- digit+'.'digit+('e''-'?digit+)?+regDouble :: Reg+regDouble = RPlus RDigit <> RChar '.' <> RPlus RDigit+            <> ROpt (RChar 'e' <> ROpt (RChar '-') <> RPlus RDigit)++-- | Create regex for single line comments+-- >>> p $ mkRegSingleLineComment "--"+-- {"--"}(char*'\n')+mkRegSingleLineComment :: String -> Reg+mkRegSingleLineComment s = RSeq (RSeqs s) (RSeq (RStar RAny) (RChar '\n'))++-- | Create regex for multiline comments+-- >>> p $ mkRegMultilineComment "<" ">"+-- '<'((char|'\n')-'>')*'>'+-- >>> p $ mkRegMultilineComment "<!--" "-->"+-- {"<!--"}((char|'\n')-'-'|'-'((char|'\n')-'-')|{"--"}((char|'\n')-'>'))*'-'*{"-->"}+mkRegMultilineComment :: String -> String -> Reg+mkRegMultilineComment b e =+    rseq $ concat [+      lit b+      , [RStar (foldl1 RAlt subregex)]+      , [ RStar (RChar (head e)) | length e > 1 ]+      , lit e]+  where+    rseq = foldl1 RSeq+    lit :: String -> [Reg]+    lit "" = []+    lit [c] = [RChar c]+    lit s = [RSeqs s]+    prefixes = map (init &&& last) (drop 1 (inits e))+    subregex = [rseq (lit ss ++ [RMinus (RAlt RAny (RChar '\n')) (RChar s)]) | (ss,s) <- prefixes]
src/BNFC/Options.hs view
@@ -27,7 +27,7 @@ -- | Target languages data Target = TargetC | TargetCpp | TargetCppNoStl | TargetCSharp             | TargetHaskell | TargetHaskellGadt | TargetLatex-            | TargetJava | TargetOCaml | TargetProfile+            | TargetJava | TargetOCaml | TargetProfile | TargetPygments   deriving (Eq,Bounded, Enum,Ord)  -- Create a list of all target using the enum and bounded classes@@ -45,6 +45,7 @@   show TargetJava         = "Java"   show TargetOCaml        = "OCaml"   show TargetProfile      = "Haskell (with permutation profiles)"+  show TargetPygments     = "Pygments"  -- | Which version of Alex is targeted? data AlexVersion = Alex1 | Alex2 | Alex3@@ -66,6 +67,7 @@   , lang :: String   -- Haskell specific:   , alexMode :: AlexVersion+  , jflex :: Bool   , inDir :: Bool   , shareStrings :: Bool   , byteStrings :: Bool@@ -77,6 +79,8 @@   -- C# specific   , visualStudio :: Bool      -- ^ Generate Visual Studio solution/project files   , wcf :: Bool               -- ^ Windows Communication Foundation+  , functor :: Bool+  , outDir :: FilePath        -- ^ Target directory for generated files   } deriving (Eq,Show,Ord)  -- | We take this oportunity to define the type of the backend functions@@ -100,7 +104,11 @@   , lang = error "lang not set"   , linenumbers = False   , visualStudio = False-  , wcf = False }+  , wcf = False+  , functor = False+  , outDir  = "."+  , jflex = False+  }  -- ~~~ Option definition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- This defines bnfc's "global" options, like --help@@ -132,7 +140,10 @@   , Option "" ["ocaml"]         (NoArg (\o -> o {target = TargetOCaml}))     "Output OCaml code for use with ocamllex and ocamlyacc"   , Option "" ["profile"]       (NoArg (\o -> o {target = TargetProfile}))-    "Output Haskell code for rules with permutation profiles" ]+    "Output Haskell code for rules with permutation profiles"+  , Option "" ["pygments"]      (NoArg (\o -> o {target = TargetPygments}))+    "Output a Python lexer for Pygments"+  ]  -- | A list of the options and for each of them, the target language -- they apply to.@@ -145,6 +156,9 @@       (ReqArg (\n o -> o {inPackage = Just n}) "<namespace>")       "Prepend <namespace> to the package/module name"     , [TargetCpp, TargetCSharp, TargetHaskell, TargetHaskellGadt, TargetProfile, TargetJava] )+  , ( Option [] ["jflex"] (NoArg (\o -> o {jflex = True}))+          "Use JFlex instead of JLex for lexing"+    , [TargetJava] )   , ( Option [] ["vs"] (NoArg (\o -> o {visualStudio = True}))           "Generate Visual Studio solution/project files"     , [TargetCSharp] )@@ -184,17 +198,23 @@   , ( Option []    ["ghc"] (NoArg (\o -> o {ghcExtensions = True}))           "Use ghc-specific language extensions"     , [TargetHaskell, TargetHaskellGadt, TargetProfile] )+  , ( Option []    ["functor"] (NoArg (\o -> o {functor = True}))+          "Make the AST a functor and use it to store the position of the nodes"+    , [TargetHaskell] )   ]  -makefileOption :: [OptDescr (SharedOptions -> SharedOptions)]-makefileOption =+commonOption :: [OptDescr (SharedOptions -> SharedOptions)]+commonOption =   [ Option "m" ["makefile"] (OptArg (setMakefile . fromMaybe "Makefile") "MAKEFILE")-      "generate Makefile" ]+      "generate Makefile"+  , Option "o" ["outputdir"] (ReqArg (\n o -> o {outDir = n}) "DIR")+      "Redirects all generated files into DIR"+  ]   where setMakefile = \mf -> \o -> o { make = Just mf }  allOptions :: [OptDescr (SharedOptions -> SharedOptions)]-allOptions = targetOptions ++ makefileOption ++ map fst specificOptions+allOptions = targetOptions ++ commonOption ++ map fst specificOptions  -- ~~~ Help strings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title :: String@@ -215,7 +235,7 @@ help = unlines $     usage:""     :usageInfo "Global options"   globalOptions-    :usageInfo "Make option"      makefileOption+    :usageInfo "Common option"      commonOption     :usageInfo "Target languages" targetOptions     :map targetUsage helpTargets   where helpTargets = [TargetHaskell, TargetJava, TargetCpp, TargetCSharp ]
+ src/BNFC/PrettyPrint.hs view
@@ -0,0 +1,38 @@+-- Extends Text.PrettyPrint+module BNFC.PrettyPrint+  ( module Text.PrettyPrint+  , (<.>)+  , codeblock+  , vsep+  , (<=>)+  ) where++import Text.PrettyPrint++-- | Pretty print separator with a dot+-- >>> "abc" <.> "py"+-- abc.py+(<.>) :: Doc -> Doc -> Doc+a <.> b = a <> "." <> b++-- | Code block. A bloc of code, surrounded by {} and indented.+-- >>> codeblock 4 ["abc", "def"]+-- {+--     abc+--     def+-- }+codeblock :: Int -> [Doc] -> Doc+codeblock indent code = lbrace $+$ nest indent (vcat code) $+$ rbrace++-- | List version of prettyPrint $+$+-- >>> vsep [text "abc", nest 4 (text "def")]+-- abc+--     def+vsep :: [Doc] -> Doc+vsep = foldl ($+$) empty++-- | Pretty print separator with = (for assignments...)+-- >>> "a" <=> "123"+-- a = 123+(<=>) :: Doc -> Doc -> Doc+a <=> b = a <+> "=" <+> b
src/BNFC/TypeChecker.hs view
@@ -9,7 +9,7 @@ import ErrM  data Base = BaseT String-	  | ListT Base+          | ListT Base     deriving (Eq)  data Type = FunT [Base] Base@@ -23,8 +23,8 @@     show (FunT ts t) = unwords $ map show ts ++ ["->", show t]  data Context = Ctx  { ctxLabels :: [(String, Type)]-		    , ctxTokens :: [String]-		    }+                    , ctxTokens :: [String]+                    }  catchErr :: Err a -> (String -> Err a) -> Err a catchErr (Bad s) f = f s@@ -35,16 +35,16 @@     Ctx     [ (f, mkType cat args) | Rule f cat args <- rules                            , not (isCoercion f)-			   , not (isNilCons f)+                           , not (isNilCons f)     ]     ("Ident" : tokenNames cf)   where      mkType cat args = FunT [ mkBase t | Left t <- args, t /= InternalCat ]-			   (mkBase cat)+                           (mkBase cat)     mkBase t-	| isList t  = ListT $ mkBase $ normCatOfList t-	| otherwise = BaseT $ show $ normCat t+        | isList t  = ListT $ mkBase $ normCatOfList t+        | otherwise = BaseT $ show $ normCat t  isToken :: String -> Context -> Bool isToken x ctx = elem x $ ctxTokens ctx@@ -55,91 +55,91 @@ lookupCtx :: String -> Context -> Err Type lookupCtx x ctx     | isToken x ctx = return $ FunT [BaseT "String"] (BaseT x)-    | otherwise	    =+    | otherwise     =     case lookup x $ ctxLabels ctx of-	Nothing	-> fail $ "Undefined symbol '" ++ x ++ "'."-	Just t	-> return t+        Nothing -> fail $ "Undefined symbol '" ++ x ++ "'."+        Just t  -> return t  checkDefinitions :: CF -> Err () checkDefinitions cf =-    do	checkContext ctx-	sequence_ [checkDefinition ctx f xs e | FunDef f xs e <- pragmasOfCF cf]+    do  checkContext ctx+        sequence_ [checkDefinition ctx f xs e | FunDef f xs e <- pragmasOfCF cf]     where-	ctx = buildContext cf+        ctx = buildContext cf  checkContext :: Context -> Err () checkContext ctx =     mapM_ checkEntry $ groupSnd $ ctxLabels ctx     where-	-- This is a very handy function which transforms a lookup table-	-- with duplicate keys to a list valued lookup table with no duplicate-	-- keys.-	groupSnd :: Ord a => [(a,b)] -> [(a,[b])]-	groupSnd =-	    map ((fst . head) /\ map snd)-	    . groupBy ((==) **.* fst)-	    . sortBy (compare **.* fst)+        -- This is a very handy function which transforms a lookup table+        -- with duplicate keys to a list valued lookup table with no duplicate+        -- keys.+        groupSnd :: Ord a => [(a,b)] -> [(a,[b])]+        groupSnd =+            map ((fst . head) /\ map snd)+            . groupBy ((==) **.* fst)+            . sortBy (compare **.* fst) -	(f /\ g) x     = (f x, g x)-	(f **.* g) x y = f (g x) (g y)+        (f /\ g) x     = (f x, g x)+        (f **.* g) x y = f (g x) (g y) -	checkEntry (f,ts) =-	    case nub ts of-		[_] -> return ()-		ts' ->-		    fail $ "The symbol '" ++ f ++ "' is used at conflicting types:\n" ++-			    unlines (map (("  " ++) . show) ts')+        checkEntry (f,ts) =+            case nub ts of+                [_] -> return ()+                ts' ->+                    fail $ "The symbol '" ++ f ++ "' is used at conflicting types:\n" +++                            unlines (map (("  " ++) . show) ts')  checkDefinition :: Context -> String -> [String] -> Exp -> Err () checkDefinition ctx f xs e =     void $ checkDefinition' dummyConstructors ctx f xs e  data ListConstructors = LC-	{ nil	:: Base -> String-	, cons	:: Base -> String-	}+        { nil   :: Base -> String+        , cons  :: Base -> String+        }  dummyConstructors :: ListConstructors dummyConstructors = LC (const "[]") (const "(:)")  checkDefinition' :: ListConstructors -> Context -> String -> [String] -> Exp -> Err ([(String,Base)],(Exp,Base)) checkDefinition' list ctx f xs e =-    do	unless (isLower $ head f) $ fail "Defined functions must start with a lowercase letter."-	t@(FunT ts t') <- lookupCtx f ctx `catchErr` \_ ->-				fail $ "'" ++ f ++ "' must be used in a rule."-	let expect = length ts-	    given  = length xs-	unless (expect == given) $ fail $ "'" ++ f ++ "' is used with type " ++ show t ++ " but defined with " ++ show given ++ " argument" ++ plural given ++ "."-	e' <- checkExp list (extendContext ctx $ zip xs (map (FunT []) ts)) e t'-	return (zip xs ts, (e', t'))+    do  unless (isLower $ head f) $ fail "Defined functions must start with a lowercase letter."+        t@(FunT ts t') <- lookupCtx f ctx `catchErr` \_ ->+                                fail $ "'" ++ f ++ "' must be used in a rule."+        let expect = length ts+            given  = length xs+        unless (expect == given) $ fail $ "'" ++ f ++ "' is used with type " ++ show t ++ " but defined with " ++ show given ++ " argument" ++ plural given ++ "."+        e' <- checkExp list (extendContext ctx $ zip xs (map (FunT []) ts)) e t'+        return (zip xs ts, (e', t'))     `catchErr` \err -> fail $ "In the definition " ++ unwords (f : xs ++ ["=",show e,";"]) ++ "\n  " ++ err     where-	plural 1 = ""-	plural _ = "s"+        plural 1 = ""+        plural _ = "s"  checkExp :: ListConstructors -> Context -> Exp -> Base -> Err Exp checkExp list _   (App "[]" []) (ListT t) = return (App (nil list t) [])-checkExp _ _      (App "[]" _) _  = fail $ "[] is applied to too many arguments."+checkExp _ _      (App "[]" _) _  = fail "[] is applied to too many arguments." checkExp list ctx (App "(:)" [e,es]) (ListT t) =-    do	e'  <- checkExp list ctx e t-	es' <- checkExp list ctx es (ListT t)-	return $ App (cons list t) [e',es']-checkExp _ _ (App "(:)" es) _	= fail $ "(:) takes 2 arguments, but has been given " ++ show (length es) ++ "."+    do  e'  <- checkExp list ctx e t+        es' <- checkExp list ctx es (ListT t)+        return $ App (cons list t) [e',es']+checkExp _ _ (App "(:)" es) _   = fail $ "(:) takes 2 arguments, but has been given " ++ show (length es) ++ "." checkExp list ctx e@(App x es) t =-    do	FunT ts t' <- lookupCtx x ctx-	es' <- matchArgs ts-	unless (t == t') $ fail $ show e ++ " has type " ++ show t' ++ ", but something of type " ++ show t ++ " was expected."-	return $ App x es'+    do  FunT ts t' <- lookupCtx x ctx+        es' <- matchArgs ts+        unless (t == t') $ fail $ show e ++ " has type " ++ show t' ++ ", but something of type " ++ show t ++ " was expected."+        return $ App x es'     where-	matchArgs ts-	    | expect /= given	= fail $ "'" ++ x ++ "' takes " ++ show expect ++ " arguments, but has been given " ++ show given ++ "."-	    | otherwise		= zipWithM (checkExp list ctx) es ts-	    where-		expect = length ts-		given  = length es-checkExp _ _ e@(LitInt _) (BaseT "Integer")	= return e-checkExp _ _ e@(LitDouble _) (BaseT "Double")	= return e-checkExp _ _ e@(LitChar _) (BaseT "Char")	= return e-checkExp _ _ e@(LitString _) (BaseT "String")	= return e+        matchArgs ts+            | expect /= given   = fail $ "'" ++ x ++ "' takes " ++ show expect ++ " arguments, but has been given " ++ show given ++ "."+            | otherwise         = zipWithM (checkExp list ctx) es ts+            where+                expect = length ts+                given  = length es+checkExp _ _ e@(LitInt _) (BaseT "Integer")     = return e+checkExp _ _ e@(LitDouble _) (BaseT "Double")   = return e+checkExp _ _ e@(LitChar _) (BaseT "Char")       = return e+checkExp _ _ e@(LitString _) (BaseT "String")   = return e checkExp _ _ e t = fail $ show e ++ " does not have type " ++ show t ++ "." 
src/BNFC/Utils.hs view
@@ -17,29 +17,32 @@     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA -} -module BNFC.Utils where+module BNFC.Utils+    ( (+++), (++++)+    , mkName, mkNames, NameStyle(..)+    , lowerCase, upperCase, mixedCase, camelCase, snakeCase+    , replace, prParenth+    , writeFileRep+    ) where +import Control.Arrow ((&&&)) import Control.DeepSeq (rnf)-import Control.Monad (unless)-import Data.Function (on)-import Data.List (groupBy, sort)+import Data.Char+import Data.List (intercalate) import System.IO (IOMode(ReadMode),hClose,hGetContents,openFile) import System.IO.Error (tryIOError) import System.Directory (createDirectory, doesDirectoryExist, renameFile,-                         removeFile, doesFileExist)-import System.FilePath (pathSeparator)-import Text.PrettyPrint+                         removeFile)+import BNFC.PrettyPrint  infixr 5 +++ infixr 5 ++++-infixr 5 +++++  -- printing operations -(+++), (++++), (+++++) :: String -> String -> String+(+++), (++++) :: String -> String -> String a +++ b   = a ++ " "    ++ b a ++++ b  = a ++ "\n"   ++ b-a +++++ b = a ++ "\n\n" ++ b  prParenth :: String -> String prParenth s = if s == "" then "" else "(" ++ s ++ ")"@@ -48,79 +51,19 @@  -- | Replace all occurences of a value by another value replace :: Eq a =>-	   a -- ^ Value to replace-	-> a -- ^ Value to replace it with-	-> [a] -> [a]+           a -- ^ Value to replace+        -> a -- ^ Value to replace it with+        -> [a] -> [a] replace x y xs = [ if z == x then y else z | z <- xs] --- | Split a list on the first occurence of a value.---   Does not include the value that was split on in either---   of the returned lists.-split :: Eq a => a -> [a] -> ([a],[a])-split x xs = let (ys, zs) = break (==x) xs-		 in (ys, drop 1 zs)---- | Split a list on every occurence of a value.---   If the value does not occur in the list,---   the result is the singleton list containing the input list.---   Thus the returned list is never the empty list.-splitAll :: Eq a => a -> [a] -> [[a]]-splitAll _ [] = [[]]-splitAll x xs = let (ys, zs) = break (==x) xs-		    in ys : case zs of-				    [] -> []-				    _:zs' -> splitAll x zs'- -- * File utilities --- | Ensure that a directory exists.-prepareDir :: FilePath -> IO ()-prepareDir = mapM_ createDirectoryIfNotExists . pathInits---- | Ensure that a directory exists. All parent directories---   must already exist.-createDirectoryIfNotExists :: FilePath -> IO ()-createDirectoryIfNotExists d = do-      exists <- doesDirectoryExist d-      unless exists (createDirectory d)---- | Like the prelude function 'inits' but for path names.---   For example:--- > pathInits "foo/bar" = ["foo","foo/bar"]--- > pathInits "foo/bar/baz.hs" = ["foo","foo/bar","foo/bar/baz.hs"]-pathInits :: String -> [String]-pathInits "" = []-pathInits xs = let (ys,zs) = split pathSeparator xs-		   in ys : map ((ys ++ [pathSeparator]) ++) (pathInits zs)---- | Like basename(1), remove all leading directories from a path name.--- basename :: String -> String--- basename = last . splitAll pathSeparator-- -- | Write a file, after making a backup of an existing file with the same name.-writeFileRep :: FilePath -> String -> IO ()-writeFileRep = writeFileRep2---- peteg: FIXME this is racey.--- want to be a bit smarter about whether we actually generate the file--- or save it... e.g. ErrM.hs need not be regenerated if it exists.-writeFileRep1 :: FilePath -> String -> IO ()-writeFileRep1 f s =-    do exists <- doesFileExist f-       backedUp <- if exists-		     then do let fbak = f ++ ".bak"-		             renameFile f fbak-			     return $ " (saving old file as " ++ fbak ++ ")"-		     else return ""-       putStrLn $ "writing file " ++ f ++ backedUp-       writeFile f s---- New version by TH, 2010-09-23 -- If an old version of the file exist and the new version is the same, -- keep the old file and don't create a .bak file.-writeFileRep2 :: FilePath -> String -> IO ()-writeFileRep2 path s =+-- / New version by TH, 2010-09-23+writeFileRep :: FilePath -> String -> IO ()+writeFileRep path s =     either newFile updateFile =<< tryIOError (readFile' path)   where     newFile _ =@@ -150,19 +93,147 @@         do inFile <- openFile path' ReadMode            contents <- hGetContents inFile            rnf contents `seq` hClose inFile-	   return contents+           return contents --- | Partition a list of pairs--- >>> partitionByKey [("a",1), ("b",2), ("a",3), ("b", 4)]--- [("a",[1,3]),("b",[2,4])]-partitionByKey :: (Ord a, Eq a, Ord b) => [(a,b)] -> [(a,[b])]-partitionByKey = map foo . groupBy ((==) `on` fst) . sort-  where foo l = (fst (head l), map snd l)+-- *** Naming ***+-- Because naming is hard (http://blog.codinghorror.com/i-shall-call-it-somethingmanager/) +-- | Different case style+data NameStyle = LowerCase  -- ^ e.g. @lowercase@+               | UpperCase  -- ^ e.g. @UPPERCASE@+               | SnakeCase  -- ^ e.g. @snake_case@+               | CamelCase  -- ^ e.g. @CamelCase@+               | MixedCase  -- ^ e.g. @mixedCase@+  deriving (Show, Eq) --- | List version of prettyPrint $+$--- >>> vsep [text "abc", nest 4 (text "def")]--- abc---     def-vsep :: [Doc] -> Doc-vsep = foldl ($+$) empty+-- | Generate a name in the given case style taking into account the reserved+-- word of the language. Note that despite the fact that those name are mainly+-- to be used in code rendering (type Doc), we return a String here to allow+-- further manipulation of the name (like disambiguation) which is not possible+-- in the Doc type.+-- Examples:+-- >>> mkName [] LowerCase "FooBAR"+-- "foobar"+-- >>> mkName [] UpperCase "FooBAR"+-- "FOOBAR"+-- >>> mkName [] SnakeCase "FooBAR"+-- "foo_bar"+-- >>> mkName [] CamelCase "FooBAR"+-- "FooBAR"+-- >>> mkName [] CamelCase "Foo_bar"+-- "FooBar"+-- >>> mkName [] MixedCase "FooBAR"+-- "fooBAR"+-- >>> mkName ["foobar"] LowerCase "FooBAR"+-- "foobar_"+-- >>> mkName ["foobar", "foobar_"] LowerCase "FooBAR"+-- "foobar__"+mkName :: [String] -> NameStyle -> String -> String+mkName reserved style s = notReserved name'+  where+    notReserved s+      | s `elem` reserved = notReserved (s ++ "_")+      | otherwise = s+    tokens = parseIdent s+    name' = case style of+        LowerCase -> map toLower (concat tokens)+        UpperCase -> map toUpper (concat tokens)+        CamelCase -> concatMap capitalize tokens+        MixedCase -> case concatMap capitalize tokens of+                         "" -> ""+                         c:cs -> toLower c:cs+        SnakeCase -> map toLower (intercalate "_" tokens)+    capitalize [] = []+    capitalize (c:cs) = toUpper c:cs++-- | Same as above but accept a list as argument and make sure that the+-- names generated are uniques.+-- >>> mkNames ["c"] LowerCase ["A", "b_", "a_", "c"]+-- ["a1","b","a2","c_"]+mkNames :: [String] -> NameStyle -> [String] -> [String]+mkNames reserved style = disambiguateNames . map (mkName reserved style)++-- | This one takes a list of names and makes sure each is unique, appending+-- numerical suffix if needed+-- >>> disambiguateNames ["a", "b", "a", "c"]+-- ["a1","b","a2","c"]+disambiguateNames :: [String] -> [String]+disambiguateNames = disamb []+  where+    disamb ns1 (n:ns2)+      | n `elem` (ns1 ++ ns2) = let i = length (filter (==n) ns1) + 1+                                in (n ++ show i) : disamb (n:ns1) ns2+      | otherwise = n : disamb (n:ns1) ns2+    disamb _ [] = []++-- | Heuristic to "parse" an identifier into separate componennts+--+-- >>> parseIdent "abc"+-- ["abc"]+--+-- >>> parseIdent "Abc"+-- ["Abc"]+--+-- >>> parseIdent "WhySoSerious"+-- ["Why","So","Serious"]+--+-- >>> parseIdent "why_so_serious"+-- ["why","so","serious"]+--+-- >>> parseIdent "why-so-serious"+-- ["why","so","serious"]+--+-- Some corner cases+-- >>> parseIdent "LBNFParser"+-- ["LBNF","Parser"]+--+-- >>> parseIdent "ILoveNY"+-- ["I","Love","NY"]+parseIdent :: String -> [String]+parseIdent = p [] . map (classify &&& id)+  where+    classify c+        | isUpper c = U+        | isLower c = L+        | otherwise = O+    p [] [] = []+    p acc [] = reverse acc: p [] []+    p [] ((L,c):cs) = p [c] cs+    p [] ((U,c):cs) = p [c] cs+    p [] ((O,_):cs) = p [] cs+    p acc ((L,c1):cs@((L,_):_)) = p (c1:acc) cs+    p acc ((U,c1):cs@((L,_):_)) = reverse acc:p [c1] cs+    p acc ((U,c1):cs@((U,_):_)) = p (c1:acc) cs+    p acc ((L,c1):cs@((U,_):_)) = reverse (c1:acc) : p [] cs+    p acc ((U,c1):(O,_):cs) = reverse (c1:acc) : p [] cs+    p acc ((L,c1):(O,_):cs) = reverse (c1:acc) : p [] cs+    p acc ((O,_):cs) = reverse acc : p [] cs+    p acc [(_,c)] = p (c:acc) []++data CharClass = U | L | O++-- | Ident to lower case+-- >>> lowerCase "MyIdent"+-- myident+lowerCase :: String -> Doc+lowerCase = text . mkName [] LowerCase+-- | Ident to upper case+-- >>> upperCase "MyIdent"+-- MYIDENT+upperCase :: String -> Doc+upperCase = text . mkName [] UpperCase+-- | Ident to camel case+-- >>> camelCase "my_ident"+-- MyIdent+camelCase :: String -> Doc+camelCase = text . mkName [] CamelCase+-- | To mixed case+-- >>> mixedCase "my_ident"+-- myIdent+mixedCase :: String -> Doc+mixedCase = text . mkName [] MixedCase+-- | To snake case+-- >>> snakeCase "MyIdent"+-- my_ident+snakeCase :: String -> Doc+snakeCase = text . mkName [] SnakeCase
src/LexBNF.x view
@@ -84,6 +84,7 @@   PT _ (TV s)   -> s   PT _ (TD s)   -> s   PT _ (TC s)   -> s+  Err _ -> "#Error"   data BTree = N | B String Tok BTree BTree deriving (Show)
src/Main.hs view
@@ -39,6 +39,7 @@ import BNFC.Backend.Java import BNFC.Backend.Latex import BNFC.Backend.OCaml+import BNFC.Backend.Pygments import BNFC.GetCF import BNFC.Options hiding (make) @@ -64,16 +65,22 @@     Help    -> putStrLn help >> exitSuccess     Version ->  putStrLn (showVersion version) >> exitSuccess     Target options file | target options == TargetProfile ->-      readFile file >>= parseCFP options TargetProfile >>= makeHaskellProfile options+      readFile file >>= parseCFP options TargetProfile+                    >>= writeFiles (outDir options) . makeHaskellProfile options     Target options file ->       readFile file >>= parseCF options (target options) >>= make (target options) options-  where make TargetC            opts cf = writeFiles "." $ makeC opts cf-        make TargetCpp          opts cf = writeFiles "." $ makeCppStl opts cf-        make TargetCppNoStl     opts cf = writeFiles "." $ makeCppNoStl opts cf-        make TargetCSharp       opts cf = writeFiles "." $ makeCSharp opts cf-        make TargetHaskell      opts cf = writeFiles "." $ makeHaskell opts cf-        make TargetHaskellGadt  opts cf = writeFiles "." $ makeHaskellGadt opts cf-        make TargetLatex        opts cf = writeFiles "." $ makeLatex opts cf-        make TargetJava         opts cf = writeFiles "." $ makeJava opts cf-        make TargetOCaml        opts cf = writeFiles "." $ makeOCaml opts cf-        make TargetProfile      opts cf = fail "" opts cf+  where+    make t opts cf = writeFiles (outDir opts) $ (maketarget t) opts cf++maketarget t = case t of+    TargetC            -> makeC+    TargetCpp          -> makeCppStl+    TargetCppNoStl     -> makeCppNoStl+    TargetCSharp       -> makeCSharp+    TargetHaskell      -> makeHaskell+    TargetHaskellGadt  -> makeHaskellGadt+    TargetLatex        -> makeLatex+    TargetJava         -> makeJava+    TargetOCaml        -> makeOCaml+    TargetProfile      -> error "Not implemented"+    TargetPygments     -> makePygments
test/BNFC/Backend/Common/MakefileSpec.hs view
@@ -10,13 +10,18 @@ spec = do   describe "mkRule" $ do -    it "prduce makefile rules correctly" $+    it "produces makefile rules correctly" $       mkRule "main" ["file1","file2"] ["do something"] ""         `shouldBe` "main: file1 file2\n\tdo something\n\n"      it "produce mafefile rules without receipes" $       mkRule "main" ["program.exe"] [] ""        `shouldBe` "main: program.exe\n\n"++  describe "mkVar" $+    it "writes variables" $+      mkVar "FOO" "bar" "" `shouldBe` "FOO=bar\n"+    describe "mkMakefile" $ do     it "uses the names in the options dictionary" $
+ test/BNFC/Backend/Haskell/CFtoHappySpec.hs view
@@ -0,0 +1,16 @@+module BNFC.Backend.Haskell.CFtoHappySpec where++import Test.Hspec+import Text.PrettyPrint (render)++import BNFC.Backend.Haskell.CFtoHappy++rendersTo a b = render a `shouldBe` b++spec = do+  describe "convert" $ do+    it "quotes backslashes" $+      convert "\\" `rendersTo` "'\\\\'"++    it "quotes backslashes as part of a longer string" $+      convert "/\\" `rendersTo` "'/\\\\'"
+ test/BNFC/Backend/HaskellGADTSpec.hs view
@@ -0,0 +1,26 @@+module BNFC.Backend.HaskellGADTSpec where++import BNFC.Options+import BNFC.GetCF++import Test.Hspec+import BNFC.Hspec++import BNFC.Backend.HaskellGADT -- SUT++calcOptions = defaultOptions { lang = "Calc" }+getCalc = parseCF  calcOptions TargetHaskellGadt $+  unlines [ "EAdd. Exp ::= Exp \"+\" Exp1  ;"+          , "ESub. Exp ::= Exp \"-\" Exp1  ;"+          , "EMul. Exp1  ::= Exp1  \"*\" Exp2  ;"+          , "EDiv. Exp1  ::= Exp1  \"/\" Exp2  ;"+          , "EInt. Exp2  ::= Integer ;"+          , "coercions Exp 2 ;" ]++spec =+  describe "C backend" $+    it "respect the makefile option" $ do+      calc <- getCalc+      let opts = calcOptions { make = Just "MyMakefile" }+      makeHaskellGadt opts calc `shouldGenerate` "MyMakefile"+
+ test/BNFC/Backend/HaskellSpec.hs view
@@ -0,0 +1,58 @@+module BNFC.Backend.HaskellSpec where++import Test.Hspec+import BNFC.GetCF+import BNFC.Hspec+import BNFC.Options hiding (Backend)+import BNFC.Backend.Base+import Text.Printf (printf)++import BNFC.Backend.Haskell -- SUT++calcOptions = defaultOptions { lang = "Calc" }+getCalc = parseCF  calcOptions TargetHaskell $+  unlines [ "EAdd. Exp ::= Exp \"+\" Exp1  ;"+          , "ESub. Exp ::= Exp \"-\" Exp1  ;"+          , "EMul. Exp1  ::= Exp1  \"*\" Exp2  ;"+          , "EDiv. Exp1  ::= Exp1  \"/\" Exp2  ;"+          , "EInt. Exp2  ::= Integer ;"+          , "coercions Exp 2 ;" ]++spec = do++  context "with default option and the Calc grammar" $ do+    it "generates a file called AbsCalc.hs" $ do+      calc <- getCalc+      files <- execBackend (makeHaskell calcOptions calc)+      map fst files `shouldSatisfy` elem "AbsCalc.hs"++    it "generates a file called LexCalc.x" $ do+      calc <- getCalc+      files <- execBackend (makeHaskell calcOptions calc)+      map fst files `shouldSatisfy` elem "LexCalc.x"++    it "generates a file called ParCalc.y" $ do+      calc <- getCalc+      makeHaskell calcOptions calc `shouldGenerate` "ParCalc.y"++    it "generates a squeleton file" $ do+      calc <- getCalc+      makeHaskell calcOptions calc `shouldGenerate` "SkelCalc.hs"++    it "generates a pretty printer file" $ do+      calc <- getCalc+      makeHaskell calcOptions calc `shouldGenerate` "PrintCalc.hs"++    it "generates a test program file" $ do+      calc <- getCalc+      makeHaskell calcOptions calc `shouldGenerate` "TestCalc.hs"++    it "generates a error module file" $ do+      calc <- getCalc+      makeHaskell calcOptions calc `shouldGenerate` "ErrM.hs"++  context "with option -mMyMakefile and the Calc grammar" $ do+    it "generates a Makefile" $ do+      calc <- getCalc+      let options = calcOptions { make = Just "MyMakefile" }+      makeHaskell options calc `shouldGenerate` "MyMakefile"
test/doctests.hs view
@@ -4,4 +4,5 @@     , "-idist/build/autogen/"     , "-idist/build/bnfc/bnfc-tmp"     , "-XOverloadedStrings"+    , "-XRecordWildCards"     , "src/Main.hs" ]