diff --git a/src/Grammar/Lex.hs b/src/Grammar/Lex.hs new file mode 100644 index 0000000..fa5df83 --- /dev/null +++ b/src/Grammar/Lex.hs @@ -0,0 +1,4542 @@ +{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-} +{-# LANGUAGE CPP #-} +{-# LINE 4 "LexGrammar.x" #-} +{-# OPTIONS -fno-warn-incomplete-patterns #-} +{-# OPTIONS_GHC -w #-} + +{-# LANGUAGE PatternSynonyms #-} + +module Grammar.Lex where + +import Prelude + +import qualified Data.Bits +import Data.Char (ord) +import Data.Function (on) +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 +#else +import Array +#endif +alex_tab_size :: Int +alex_tab_size = 8 +alex_base :: Array Int Int +alex_base = listArray (0 :: Int, 29) + [ -8 + , 60 + , 188 + , -39 + , -76 + , 399 + , 0 + , -2 + , 0 + , 317 + , 616 + , -36 + , -23 + , 0 + , 697 + , 953 + , 954 + , 1082 + , 547 + , 1147 + , 1260 + , 0 + , 0 + , 0 + , 1471 + , 1727 + , 1326 + , 0 + , 0 + , 1712 + ] + +alex_table :: Array Int Int +alex_table = listArray (0 :: Int, 1982) + [ 0 + , 7 + , 7 + , 7 + , 7 + , 7 + , 5 + , 7 + , 7 + , 7 + , 7 + , 7 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 14 + , 0 + , 7 + , 0 + , 0 + , 0 + , 0 + , 0 + , 7 + , 0 + , 8 + , 8 + , 0 + , 8 + , 0 + , 12 + , 0 + , 8 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 11 + , 0 + , 0 + , 0 + , 8 + , 0 + , 0 + , 0 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 0 + , 8 + , 0 + , 0 + , 0 + , 0 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 3 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 9 + , 25 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 1 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 24 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 0 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 0 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 25 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 4 + , 1 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 26 + , 2 + , 28 + , 28 + , 28 + , 29 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 10 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , -1 + , 0 + , 0 + , 0 + , 10 + , 0 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , 10 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 9 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 15 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 18 + , 16 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 19 + , 17 + , 23 + , 23 + , 23 + , 20 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 15 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 21 + , 16 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 22 + , 18 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 19 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 24 + , 4 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 6 + , 0 + , 0 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 25 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 13 + , 4 + , 1 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 27 + , 26 + , 2 + , 28 + , 28 + , 28 + , 29 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 26 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + , 0 + ] + +alex_check :: Array Int Int +alex_check = listArray (0 :: Int, 1982) + [ -1 + , 9 + , 10 + , 11 + , 12 + , 13 + , 45 + , 9 + , 10 + , 11 + , 12 + , 13 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , 45 + , -1 + , 32 + , -1 + , -1 + , -1 + , -1 + , -1 + , 32 + , -1 + , 40 + , 41 + , -1 + , 43 + , -1 + , 45 + , -1 + , 62 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , -1 + , 61 + , -1 + , -1 + , -1 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , -1 + , 92 + , -1 + , -1 + , -1 + , -1 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , 123 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 195 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 45 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , -1 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , -1 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 39 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , 10 + , -1 + , -1 + , -1 + , 95 + , -1 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 195 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 0 + , 1 + , 2 + , 3 + , 4 + , 5 + , 6 + , 7 + , 8 + , 9 + , 10 + , 11 + , 12 + , 13 + , 14 + , 15 + , 16 + , 17 + , 18 + , 19 + , 20 + , 21 + , 22 + , 23 + , 24 + , 25 + , 26 + , 27 + , 28 + , 29 + , 30 + , 31 + , 32 + , 33 + , 34 + , 35 + , 36 + , 37 + , 38 + , 39 + , 40 + , 41 + , 42 + , 43 + , 44 + , 45 + , 46 + , 47 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , 58 + , 59 + , 60 + , 61 + , 62 + , 63 + , 64 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , 91 + , 92 + , 93 + , 94 + , 95 + , 96 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , 123 + , 124 + , 125 + , 126 + , 127 + , -1 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 45 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 125 + , -1 + , -1 + , 128 + , 129 + , 130 + , 131 + , 132 + , 133 + , 134 + , 135 + , 136 + , 137 + , 138 + , 139 + , 140 + , 141 + , 142 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , 0 + , 1 + , 2 + , 3 + , 4 + , 5 + , 6 + , 7 + , 8 + , 9 + , 10 + , 11 + , 12 + , 13 + , 14 + , 15 + , 16 + , 17 + , 18 + , 19 + , 20 + , 21 + , 22 + , 23 + , 24 + , 25 + , 26 + , 27 + , 28 + , 29 + , 30 + , 31 + , 32 + , 33 + , 34 + , 35 + , 36 + , 37 + , 38 + , 39 + , 40 + , 41 + , 42 + , 43 + , 44 + , 45 + , 46 + , 47 + , 48 + , 49 + , 50 + , 51 + , 52 + , 53 + , 54 + , 55 + , 56 + , 57 + , 58 + , 59 + , 60 + , 61 + , 62 + , 63 + , 64 + , 65 + , 66 + , 67 + , 68 + , 69 + , 70 + , 71 + , 72 + , 73 + , 74 + , 75 + , 76 + , 77 + , 78 + , 79 + , 80 + , 81 + , 82 + , 83 + , 84 + , 85 + , 86 + , 87 + , 88 + , 89 + , 90 + , 91 + , 92 + , 93 + , 94 + , 95 + , 96 + , 97 + , 98 + , 99 + , 100 + , 101 + , 102 + , 103 + , 104 + , 105 + , 106 + , 107 + , 108 + , 109 + , 110 + , 111 + , 112 + , 113 + , 114 + , 115 + , 116 + , 117 + , 118 + , 119 + , 120 + , 121 + , 122 + , 123 + , 124 + , 125 + , 126 + , 127 + , 143 + , 144 + , 145 + , 146 + , 147 + , 148 + , 149 + , 150 + , 151 + , 152 + , 153 + , 154 + , 155 + , 156 + , 157 + , 158 + , 159 + , 160 + , 161 + , 162 + , 163 + , 164 + , 165 + , 166 + , 167 + , 168 + , 169 + , 170 + , 171 + , 172 + , 173 + , 174 + , 175 + , 176 + , 177 + , 178 + , 179 + , 180 + , 181 + , 182 + , 183 + , 184 + , 185 + , 186 + , 187 + , 188 + , 189 + , 190 + , 191 + , 192 + , 193 + , 194 + , 195 + , 196 + , 197 + , 198 + , 199 + , 200 + , 201 + , 202 + , 203 + , 204 + , 205 + , 206 + , 207 + , 208 + , 209 + , 210 + , 211 + , 212 + , 213 + , 214 + , 215 + , 216 + , 217 + , 218 + , 219 + , 220 + , 221 + , 222 + , 223 + , 224 + , 225 + , 226 + , 227 + , 228 + , 229 + , 230 + , 231 + , 232 + , 233 + , 234 + , 235 + , 236 + , 237 + , 238 + , 239 + , 240 + , 241 + , 242 + , 243 + , 244 + , 245 + , 246 + , 247 + , 248 + , 249 + , 250 + , 251 + , 252 + , 253 + , 254 + , 255 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + ] + +alex_deflt :: Array Int Int +alex_deflt = listArray (0 :: Int, 29) + [ -1 + , -1 + , -1 + , -1 + , 5 + , 5 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , -1 + , 5 + , 14 + , 14 + , -1 + , -1 + , 14 + , 21 + , 22 + , 14 + , 21 + , 22 + , 5 + , 5 + , 13 + , 13 + , 27 + , 27 + ] + +alex_accept = listArray (0 :: Int, 29) + [ AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccSkip + , AlexAccSkip + , AlexAcc 2 + , AlexAccNone + , AlexAcc 1 + , AlexAcc 0 + , AlexAccNone + , AlexAccNone + , AlexAccSkip + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + , AlexAccNone + ] + +alex_actions = array (0 :: Int, 3) + [ (2,alex_action_3) + , (1,alex_action_4) + , (0,alex_action_5) + ] + +{-# LINE 56 "LexGrammar.x" #-} +-- | Create a token with position. +tok :: (String -> Tok) -> (Posn -> String -> Token) +tok f p = PT p . f + +-- | Token without position. +data Tok + = TK {-# UNPACK #-} !TokSymbol -- ^ Reserved word or symbol. + | TL !String -- ^ String literal. + | TI !String -- ^ Integer literal. + | TV !String -- ^ Identifier. + | TD !String -- ^ Float literal. + | TC !String -- ^ Character literal. + deriving (Eq, Show, Ord) + +-- | Smart constructor for 'Tok' for the sake of backwards compatibility. +pattern TS :: String -> Int -> Tok +pattern TS t i = TK (TokSymbol t i) + +-- | Keyword or symbol tokens have a unique ID. +data TokSymbol = TokSymbol + { tsText :: String + -- ^ Keyword or symbol text. + , tsID :: !Int + -- ^ Unique ID. + } deriving (Show) + +-- | Keyword/symbol equality is determined by the unique ID. +instance Eq TokSymbol where (==) = (==) `on` tsID + +-- | Keyword/symbol ordering is determined by the unique ID. +instance Ord TokSymbol where compare = compare `on` tsID + +-- | Token with position. +data Token + = PT Posn Tok + | Err Posn + deriving (Eq, Show, Ord) + +-- | Pretty print a position. +printPosn :: Posn -> String +printPosn (Pn _ l c) = "line " ++ show l ++ ", column " ++ show c + +-- | Pretty print the position of the first token in the list. +tokenPos :: [Token] -> String +tokenPos (t:_) = printPosn (tokenPosn t) +tokenPos [] = "end of file" + +-- | Get the position of a token. +tokenPosn :: Token -> Posn +tokenPosn (PT p _) = p +tokenPosn (Err p) = p + +-- | Get line and column of a token. +tokenLineCol :: Token -> (Int, Int) +tokenLineCol = posLineCol . tokenPosn + +-- | Get line and column of a position. +posLineCol :: Posn -> (Int, Int) +posLineCol (Pn _ l c) = (l,c) + +-- | Convert a token into "position token" form. +mkPosToken :: Token -> ((Int, Int), String) +mkPosToken t = (tokenLineCol t, tokenText t) + +-- | Convert a token to its text. +tokenText :: Token -> String +tokenText t = case t of + PT _ (TS s _) -> s + PT _ (TL s) -> show s + PT _ (TI s) -> s + PT _ (TV s) -> s + PT _ (TD s) -> s + PT _ (TC s) -> s + Err _ -> "#error" + +-- | Convert a token to a string. +prToken :: Token -> String +prToken t = tokenText t + +-- | Finite map from text to token organized as binary search tree. +data BTree + = N -- ^ Nil (leaf). + | B String Tok BTree BTree + -- ^ Binary node. + deriving (Show) + +-- | Convert potential keyword into token or use fallback conversion. +eitherResIdent :: (String -> Tok) -> String -> Tok +eitherResIdent tv s = treeFind resWords + where + treeFind N = tv s + treeFind (B a t left right) = + case compare s a of + LT -> treeFind left + GT -> treeFind right + EQ -> t + +-- | The keywords and symbols of the language organized as binary search tree. +resWords :: BTree +resWords = + b "->" 4 + (b ")" 2 (b "(" 1 N N) (b "+" 3 N N)) + (b "\\" 6 (b "=" 5 N N) (b "main" 7 N N)) + where + b s n = B bs (TS bs n) + where + bs = s + +-- | Unquote string literal. +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 + '\\':'r':cs -> '\r' : unesc cs + '\\':'f':cs -> '\f' : 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 (eitherResIdent TV) +alex_action_4 = tok (eitherResIdent TV) +alex_action_5 = tok TI + +#define ALEX_NOPRED 1 +-- ----------------------------------------------------------------------------- +-- 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 + +#ifdef ALEX_GHC +# define ILIT(n) n# +# define IBOX(n) (I# (n)) +# define FAST_INT Int# +-- 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 +# define PLUS(n,m) (n +# m) +# define MINUS(n,m) (n -# m) +# define TIMES(n,m) (n *# m) +# define NEGATE(n) (negateInt# (n)) +# define IF_GHC(x) (x) +#else +# define ILIT(n) (n) +# define IBOX(n) (n) +# define FAST_INT Int +# define GTE(n,m) (n >= m) +# define EQ(n,m) (n == m) +# define PLUS(n,m) (n + m) +# define MINUS(n,m) (n - m) +# define TIMES(n,m) (n * m) +# define NEGATE(n) (negate (n)) +# define IF_GHC(x) +#endif + +#ifdef ALEX_GHC +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 :: AlexAddr -> Int# -> Int# +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 +#if __GLASGOW_HASKELL__ >= 901 + int16ToInt# +#endif + (indexInt16OffAddr# arr off) +#endif +#else +alexIndexInt16OffAddr arr off = arr ! off +#endif + +#ifdef ALEX_GHC +{-# INLINE alexIndexInt32OffAddr #-} +alexIndexInt32OffAddr :: AlexAddr -> Int# -> Int# +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 +#if __GLASGOW_HASKELL__ >= 901 + int32ToInt# +#endif + (indexInt32OffAddr# arr off) +#endif +#else +alexIndexInt32OffAddr arr off = arr ! off +#endif + +#ifdef ALEX_GHC + +#if __GLASGOW_HASKELL__ < 503 +quickIndex arr i = arr ! i +#else +-- GHC >= 503, unsafeAt is available from Data.Array.Base. +quickIndex = unsafeAt +#endif +#else +quickIndex arr i = arr ! i +#endif + +-- ----------------------------------------------------------------------------- +-- Main lexing routines + +data AlexReturn a + = AlexEOF + | AlexError !AlexInput + | AlexSkip !AlexInput !Int + | AlexToken !AlexInput !Int a + +-- alexScan :: AlexInput -> StartCode -> AlexReturn a +alexScan input__ IBOX(sc) + = alexScanUser undefined input__ IBOX(sc) + +alexScanUser user__ input__ IBOX(sc) + = case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of + (AlexNone, input__') -> + case alexGetByte input__ of + Nothing -> +#ifdef ALEX_DEBUG + trace ("End of input.") $ +#endif + AlexEOF + Just _ -> +#ifdef ALEX_DEBUG + trace ("Error.") $ +#endif + AlexError input__' + + (AlexLastSkip input__'' len, _) -> +#ifdef ALEX_DEBUG + trace ("Skipping.") $ +#endif + AlexSkip input__'' len + + (AlexLastAcc k input__''' len, _) -> +#ifdef ALEX_DEBUG + trace ("Accept.") $ +#endif + AlexToken input__''' len (alex_actions ! 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` IBOX(s))) + in + new_acc `seq` + case alexGetByte input__ of + Nothing -> (new_acc, input__) + Just (c, new_input) -> +#ifdef ALEX_DEBUG + trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c) $ +#endif + case fromIntegral c of { IBOX(ord_c) -> + let + base = alexIndexInt32OffAddr alex_base s + offset = PLUS(base,ord_c) + check = alexIndexInt16OffAddr alex_check offset + + new_s = if GTE(offset,ILIT(0)) && EQ(check,ord_c) + then alexIndexInt16OffAddr alex_table offset + else alexIndexInt16OffAddr alex_deflt s + in + case new_s of + ILIT(-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 +#ifdef ALEX_LATIN1 + PLUS(len,ILIT(1)) + -- issue 119: in the latin1 encoding, *each* byte is one character +#else + (if c < 0x80 || c >= 0xC0 then PLUS(len,ILIT(1)) else len) + -- note that the length is increased ONLY if this is the 1st byte in a char encoding) +#endif + new_input new_s new_acc + } + where + check_accs (AlexAccNone) = last_acc + check_accs (AlexAcc a ) = AlexLastAcc a input__ IBOX(len) + check_accs (AlexAccSkip) = AlexLastSkip input__ IBOX(len) +#ifndef ALEX_NOPRED + check_accs (AlexAccPred a predx rest) + | predx user__ orig_input IBOX(len) input__ + = AlexLastAcc a input__ IBOX(len) + | otherwise + = check_accs rest + check_accs (AlexAccSkipPred predx rest) + | predx user__ orig_input IBOX(len) input__ + = AlexLastSkip input__ IBOX(len) + | otherwise + = check_accs rest +#endif + +data AlexLastAcc + = AlexNone + | AlexLastAcc !Int !AlexInput !Int + | AlexLastSkip !AlexInput !Int + +data AlexAcc user + = AlexAccNone + | AlexAcc Int + | AlexAccSkip +#ifndef ALEX_NOPRED + | AlexAccPred Int (AlexAccPred user) (AlexAcc user) + | AlexAccSkipPred (AlexAccPred user) (AlexAcc user) + +type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool + +-- ----------------------------------------------------------------------------- +-- Predicates on a rule + +alexAndPred p1 p2 user__ in1 len in2 + = p1 user__ in1 len in2 && p2 user__ in1 len in2 + +--alexPrevCharIsPred :: Char -> AlexAccPred _ +alexPrevCharIs c _ input__ _ _ = c == alexInputPrevChar input__ + +alexPrevCharMatches f _ input__ _ _ = f (alexInputPrevChar input__) + +--alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _ +alexPrevCharIsOneOf arr _ input__ _ _ = arr ! alexInputPrevChar input__ + +--alexRightContext :: Int -> AlexAccPred _ +alexRightContext IBOX(sc) user__ _ _ input__ = + case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of + (AlexNone, _) -> False + _ -> True + -- TODO: there's no need to find the longest + -- match when checking the right context, just + -- the first match will do. +#endif diff --git a/src/Grammar/Par.hs b/src/Grammar/Par.hs new file mode 100644 index 0000000..cd85a46 --- /dev/null +++ b/src/Grammar/Par.hs @@ -0,0 +1,784 @@ +{-# OPTIONS_GHC -w #-} +{-# OPTIONS_GHC -fno-warn-incomplete-patterns -fno-warn-overlapping-patterns #-} +{-# LANGUAGE PatternSynonyms #-} + +module Grammar.Par + ( happyError + , myLexer + , pProgram + , pExp3 + , pExp2 + , pExp1 + , pExp + ) where + +import Prelude + +import qualified Grammar.Abs as Abs +--import qualified Grammar.Lex as Lex +import Grammar.Lex ( pattern TS, prToken, tokenPos, tokens, Tok(TI, TV), Token(..) ) +import qualified Data.Array as Happy_Data_Array +import qualified Data.Bits as Bits +import Control.Applicative(Applicative(..)) +import Control.Monad (ap) + +-- parser produced by Happy Version 1.20.0 + +data HappyAbsSyn + = HappyTerminal (Token) + | HappyErrorToken Prelude.Int + | HappyAbsSyn8 (Abs.Ident) + | HappyAbsSyn9 (Integer) + | HappyAbsSyn10 (Abs.Program) + | HappyAbsSyn11 (Abs.Exp) + +{- to allow type-synonyms as our monads (likely + - with explicitly-specified bind and return) + - in Haskell98, it seems that with + - /type M a = .../, then /(HappyReduction M)/ + - is not allowed. But Happy is a + - code-generator that can just substitute it. +type HappyReduction m = + Prelude.Int + -> (Token) + -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn) + -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> m HappyAbsSyn)] + -> HappyStk HappyAbsSyn + -> [(Token)] -> m HappyAbsSyn +-} + +action_0, + action_1, + action_2, + action_3, + action_4, + action_5, + action_6, + action_7, + action_8, + action_9, + action_10, + action_11, + action_12, + action_13, + action_14, + action_15, + action_16, + action_17, + action_18, + action_19, + action_20, + action_21, + action_22, + action_23, + action_24, + action_25, + action_26, + action_27, + action_28, + action_29, + action_30 :: () => Prelude.Int -> ({-HappyReduction (Err) = -} + Prelude.Int + -> (Token) + -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn) + -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)] + -> HappyStk HappyAbsSyn + -> [(Token)] -> (Err) HappyAbsSyn) + +happyReduce_5, + happyReduce_6, + happyReduce_7, + happyReduce_8, + happyReduce_9, + happyReduce_10, + happyReduce_11, + happyReduce_12, + happyReduce_13, + happyReduce_14, + happyReduce_15, + happyReduce_16 :: () => ({-HappyReduction (Err) = -} + Prelude.Int + -> (Token) + -> HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn) + -> [HappyState (Token) (HappyStk HappyAbsSyn -> [(Token)] -> (Err) HappyAbsSyn)] + -> HappyStk HappyAbsSyn + -> [(Token)] -> (Err) HappyAbsSyn) + +happyExpList :: Happy_Data_Array.Array Prelude.Int Prelude.Int +happyExpList = Happy_Data_Array.listArray (0,76) ([0,16,24640,16384,96,24640,16384,104,8192,0,0,0,0,0,0,16384,96,256,0,0,26688,0,32,0,0,1,24640,0,0,0,0,4,26688,0,0,24640,0,2,128,0,0,26688,16384,96,0,0,0,0 + ]) + +{-# NOINLINE happyExpListPerState #-} +happyExpListPerState st = + token_strs_expected + where token_strs = ["error","%dummy","%start_pProgram","%start_pExp3","%start_pExp2","%start_pExp1","%start_pExp","Ident","Integer","Program","Exp3","Exp2","Exp1","Exp","'('","')'","'+'","'->'","'='","'\\\\'","'main'","L_Ident","L_integ","%eof"] + bit_start = st Prelude.* 24 + bit_end = (st Prelude.+ 1) Prelude.* 24 + read_bit = readArrayBit happyExpList + bits = Prelude.map read_bit [bit_start..bit_end Prelude.- 1] + bits_indexed = Prelude.zip bits [0..23] + token_strs_expected = Prelude.concatMap f bits_indexed + f (Prelude.False, _) = [] + f (Prelude.True, nr) = [token_strs Prelude.!! nr] + +action_0 (21) = happyShift action_20 +action_0 (10) = happyGoto action_19 +action_0 _ = happyFail (happyExpListPerState 0) + +action_1 (15) = happyShift action_13 +action_1 (22) = happyShift action_6 +action_1 (23) = happyShift action_15 +action_1 (8) = happyGoto action_7 +action_1 (9) = happyGoto action_8 +action_1 (11) = happyGoto action_18 +action_1 _ = happyFail (happyExpListPerState 1) + +action_2 (15) = happyShift action_13 +action_2 (22) = happyShift action_6 +action_2 (23) = happyShift action_15 +action_2 (8) = happyGoto action_7 +action_2 (9) = happyGoto action_8 +action_2 (11) = happyGoto action_9 +action_2 (12) = happyGoto action_17 +action_2 _ = happyFail (happyExpListPerState 2) + +action_3 (15) = happyShift action_13 +action_3 (22) = happyShift action_6 +action_3 (23) = happyShift action_15 +action_3 (8) = happyGoto action_7 +action_3 (9) = happyGoto action_8 +action_3 (11) = happyGoto action_9 +action_3 (12) = happyGoto action_10 +action_3 (13) = happyGoto action_16 +action_3 _ = happyFail (happyExpListPerState 3) + +action_4 (15) = happyShift action_13 +action_4 (20) = happyShift action_14 +action_4 (22) = happyShift action_6 +action_4 (23) = happyShift action_15 +action_4 (8) = happyGoto action_7 +action_4 (9) = happyGoto action_8 +action_4 (11) = happyGoto action_9 +action_4 (12) = happyGoto action_10 +action_4 (13) = happyGoto action_11 +action_4 (14) = happyGoto action_12 +action_4 _ = happyFail (happyExpListPerState 4) + +action_5 (22) = happyShift action_6 +action_5 _ = happyFail (happyExpListPerState 5) + +action_6 _ = happyReduce_5 + +action_7 _ = happyReduce_8 + +action_8 _ = happyReduce_9 + +action_9 _ = happyReduce_12 + +action_10 (15) = happyShift action_13 +action_10 (22) = happyShift action_6 +action_10 (23) = happyShift action_15 +action_10 (8) = happyGoto action_7 +action_10 (9) = happyGoto action_8 +action_10 (11) = happyGoto action_22 +action_10 _ = happyReduce_14 + +action_11 (17) = happyShift action_23 +action_11 _ = happyReduce_16 + +action_12 (24) = happyAccept +action_12 _ = happyFail (happyExpListPerState 12) + +action_13 (15) = happyShift action_13 +action_13 (20) = happyShift action_14 +action_13 (22) = happyShift action_6 +action_13 (23) = happyShift action_15 +action_13 (8) = happyGoto action_7 +action_13 (9) = happyGoto action_8 +action_13 (11) = happyGoto action_9 +action_13 (12) = happyGoto action_10 +action_13 (13) = happyGoto action_11 +action_13 (14) = happyGoto action_25 +action_13 _ = happyFail (happyExpListPerState 13) + +action_14 (22) = happyShift action_6 +action_14 (8) = happyGoto action_24 +action_14 _ = happyFail (happyExpListPerState 14) + +action_15 _ = happyReduce_6 + +action_16 (17) = happyShift action_23 +action_16 (24) = happyAccept +action_16 _ = happyFail (happyExpListPerState 16) + +action_17 (15) = happyShift action_13 +action_17 (22) = happyShift action_6 +action_17 (23) = happyShift action_15 +action_17 (24) = happyAccept +action_17 (8) = happyGoto action_7 +action_17 (9) = happyGoto action_8 +action_17 (11) = happyGoto action_22 +action_17 _ = happyFail (happyExpListPerState 17) + +action_18 (24) = happyAccept +action_18 _ = happyFail (happyExpListPerState 18) + +action_19 (24) = happyAccept +action_19 _ = happyFail (happyExpListPerState 19) + +action_20 (19) = happyShift action_21 +action_20 _ = happyFail (happyExpListPerState 20) + +action_21 (15) = happyShift action_13 +action_21 (20) = happyShift action_14 +action_21 (22) = happyShift action_6 +action_21 (23) = happyShift action_15 +action_21 (8) = happyGoto action_7 +action_21 (9) = happyGoto action_8 +action_21 (11) = happyGoto action_9 +action_21 (12) = happyGoto action_10 +action_21 (13) = happyGoto action_11 +action_21 (14) = happyGoto action_29 +action_21 _ = happyFail (happyExpListPerState 21) + +action_22 _ = happyReduce_11 + +action_23 (15) = happyShift action_13 +action_23 (22) = happyShift action_6 +action_23 (23) = happyShift action_15 +action_23 (8) = happyGoto action_7 +action_23 (9) = happyGoto action_8 +action_23 (11) = happyGoto action_9 +action_23 (12) = happyGoto action_28 +action_23 _ = happyFail (happyExpListPerState 23) + +action_24 (18) = happyShift action_27 +action_24 _ = happyFail (happyExpListPerState 24) + +action_25 (16) = happyShift action_26 +action_25 _ = happyFail (happyExpListPerState 25) + +action_26 _ = happyReduce_10 + +action_27 (15) = happyShift action_13 +action_27 (20) = happyShift action_14 +action_27 (22) = happyShift action_6 +action_27 (23) = happyShift action_15 +action_27 (8) = happyGoto action_7 +action_27 (9) = happyGoto action_8 +action_27 (11) = happyGoto action_9 +action_27 (12) = happyGoto action_10 +action_27 (13) = happyGoto action_11 +action_27 (14) = happyGoto action_30 +action_27 _ = happyFail (happyExpListPerState 27) + +action_28 (15) = happyShift action_13 +action_28 (22) = happyShift action_6 +action_28 (23) = happyShift action_15 +action_28 (8) = happyGoto action_7 +action_28 (9) = happyGoto action_8 +action_28 (11) = happyGoto action_22 +action_28 _ = happyReduce_13 + +action_29 _ = happyReduce_7 + +action_30 _ = happyReduce_15 + +happyReduce_5 = happySpecReduce_1 8 happyReduction_5 +happyReduction_5 (HappyTerminal (PT _ (TV happy_var_1))) + = HappyAbsSyn8 + (Abs.Ident happy_var_1 + ) +happyReduction_5 _ = notHappyAtAll + +happyReduce_6 = happySpecReduce_1 9 happyReduction_6 +happyReduction_6 (HappyTerminal (PT _ (TI happy_var_1))) + = HappyAbsSyn9 + ((read happy_var_1) :: Integer + ) +happyReduction_6 _ = notHappyAtAll + +happyReduce_7 = happySpecReduce_3 10 happyReduction_7 +happyReduction_7 (HappyAbsSyn11 happy_var_3) + _ + _ + = HappyAbsSyn10 + (Abs.Program happy_var_3 + ) +happyReduction_7 _ _ _ = notHappyAtAll + +happyReduce_8 = happySpecReduce_1 11 happyReduction_8 +happyReduction_8 (HappyAbsSyn8 happy_var_1) + = HappyAbsSyn11 + (Abs.EId happy_var_1 + ) +happyReduction_8 _ = notHappyAtAll + +happyReduce_9 = happySpecReduce_1 11 happyReduction_9 +happyReduction_9 (HappyAbsSyn9 happy_var_1) + = HappyAbsSyn11 + (Abs.EInt happy_var_1 + ) +happyReduction_9 _ = notHappyAtAll + +happyReduce_10 = happySpecReduce_3 11 happyReduction_10 +happyReduction_10 _ + (HappyAbsSyn11 happy_var_2) + _ + = HappyAbsSyn11 + (happy_var_2 + ) +happyReduction_10 _ _ _ = notHappyAtAll + +happyReduce_11 = happySpecReduce_2 12 happyReduction_11 +happyReduction_11 (HappyAbsSyn11 happy_var_2) + (HappyAbsSyn11 happy_var_1) + = HappyAbsSyn11 + (Abs.EApp happy_var_1 happy_var_2 + ) +happyReduction_11 _ _ = notHappyAtAll + +happyReduce_12 = happySpecReduce_1 12 happyReduction_12 +happyReduction_12 (HappyAbsSyn11 happy_var_1) + = HappyAbsSyn11 + (happy_var_1 + ) +happyReduction_12 _ = notHappyAtAll + +happyReduce_13 = happySpecReduce_3 13 happyReduction_13 +happyReduction_13 (HappyAbsSyn11 happy_var_3) + _ + (HappyAbsSyn11 happy_var_1) + = HappyAbsSyn11 + (Abs.EAdd happy_var_1 happy_var_3 + ) +happyReduction_13 _ _ _ = notHappyAtAll + +happyReduce_14 = happySpecReduce_1 13 happyReduction_14 +happyReduction_14 (HappyAbsSyn11 happy_var_1) + = HappyAbsSyn11 + (happy_var_1 + ) +happyReduction_14 _ = notHappyAtAll + +happyReduce_15 = happyReduce 4 14 happyReduction_15 +happyReduction_15 ((HappyAbsSyn11 happy_var_4) `HappyStk` + _ `HappyStk` + (HappyAbsSyn8 happy_var_2) `HappyStk` + _ `HappyStk` + happyRest) + = HappyAbsSyn11 + (Abs.EAbs happy_var_2 happy_var_4 + ) `HappyStk` happyRest + +happyReduce_16 = happySpecReduce_1 14 happyReduction_16 +happyReduction_16 (HappyAbsSyn11 happy_var_1) + = HappyAbsSyn11 + (happy_var_1 + ) +happyReduction_16 _ = notHappyAtAll + +happyNewToken action sts stk [] = + action 24 24 notHappyAtAll (HappyState action) sts stk [] + +happyNewToken action sts stk (tk:tks) = + let cont i = action i i tk (HappyState action) sts stk tks in + case tk of { + PT _ (TS _ 1) -> cont 15; + PT _ (TS _ 2) -> cont 16; + PT _ (TS _ 3) -> cont 17; + PT _ (TS _ 4) -> cont 18; + PT _ (TS _ 5) -> cont 19; + PT _ (TS _ 6) -> cont 20; + PT _ (TS _ 7) -> cont 21; + PT _ (TV happy_dollar_dollar) -> cont 22; + PT _ (TI happy_dollar_dollar) -> cont 23; + _ -> happyError' ((tk:tks), []) + } + +happyError_ explist 24 tk tks = happyError' (tks, explist) +happyError_ explist _ tk tks = happyError' ((tk:tks), explist) + +happyThen :: () => Err a -> (a -> Err b) -> Err b +happyThen = ((>>=)) +happyReturn :: () => a -> Err a +happyReturn = (return) +happyThen1 m k tks = ((>>=)) m (\a -> k a tks) +happyReturn1 :: () => a -> b -> Err a +happyReturn1 = \a tks -> (return) a +happyError' :: () => ([(Token)], [Prelude.String]) -> Err a +happyError' = (\(tokens, _) -> happyError tokens) +pProgram tks = happySomeParser where + happySomeParser = happyThen (happyParse action_0 tks) (\x -> case x of {HappyAbsSyn10 z -> happyReturn z; _other -> notHappyAtAll }) + +pExp3 tks = happySomeParser where + happySomeParser = happyThen (happyParse action_1 tks) (\x -> case x of {HappyAbsSyn11 z -> happyReturn z; _other -> notHappyAtAll }) + +pExp2 tks = happySomeParser where + happySomeParser = happyThen (happyParse action_2 tks) (\x -> case x of {HappyAbsSyn11 z -> happyReturn z; _other -> notHappyAtAll }) + +pExp1 tks = happySomeParser where + happySomeParser = happyThen (happyParse action_3 tks) (\x -> case x of {HappyAbsSyn11 z -> happyReturn z; _other -> notHappyAtAll }) + +pExp tks = happySomeParser where + happySomeParser = happyThen (happyParse action_4 tks) (\x -> case x of {HappyAbsSyn11 z -> happyReturn z; _other -> notHappyAtAll }) + +happySeq = happyDontSeq + + +type Err = Either String + +happyError :: [Token] -> Err a +happyError ts = Left $ + "syntax error at " ++ tokenPos ts ++ + case ts of + [] -> [] + [Err _] -> " due to lexer error" + t:_ -> " before `" ++ (prToken t) ++ "'" + +myLexer :: String -> [Token] +myLexer = tokens +{-# LINE 1 "templates/GenericTemplate.hs" #-} +-- $Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +data Happy_IntList = HappyCons Prelude.Int Happy_IntList + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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 ERROR_TOK, 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 (1) tk st sts (_ `HappyStk` ans `HappyStk` _) = + happyReturn1 ans +happyAccept j tk st sts (HappyStk ans _) = + (happyReturn1 ans) + +----------------------------------------------------------------------------- +-- Arrays only: do the next action + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +indexShortOffAddr arr off = arr Happy_Data_Array.! off + + +{-# INLINE happyLt #-} +happyLt x y = (x Prelude.< y) + + + + + + +readArrayBit arr bit = + Bits.testBit (indexShortOffAddr arr (bit `Prelude.div` 16)) (bit `Prelude.mod` 16) + + + + + + +----------------------------------------------------------------------------- +-- HappyState data type (not arrays) + + + +newtype HappyState b c = HappyState + (Prelude.Int -> -- token number + Prelude.Int -> -- token number (yes, again) + b -> -- token semantic value + HappyState b c -> -- current state + [HappyState b c] -> -- state stack + c) + + + +----------------------------------------------------------------------------- +-- Shifting a token + +happyShift new_state (1) tk st sts stk@(x `HappyStk` _) = + let i = (case x of { HappyErrorToken (i) -> i }) in +-- trace "shifting the error token" $ + new_state i i tk (HappyState (new_state)) ((st):(sts)) (stk) + +happyShift new_state i tk st sts stk = + happyNewToken new_state ((st):(sts)) ((HappyTerminal (tk))`HappyStk`stk) + +-- happyReduce is specialised for the common cases. + +happySpecReduce_0 i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happySpecReduce_0 nt fn j tk st@((HappyState (action))) sts stk + = action nt j tk st ((st):(sts)) (fn `HappyStk` stk) + +happySpecReduce_1 i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happySpecReduce_1 nt fn j tk _ sts@(((st@(HappyState (action))):(_))) (v1`HappyStk`stk') + = let r = fn v1 in + happySeq r (action nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_2 i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happySpecReduce_2 nt fn j tk _ ((_):(sts@(((st@(HappyState (action))):(_))))) (v1`HappyStk`v2`HappyStk`stk') + = let r = fn v1 v2 in + happySeq r (action nt j tk st sts (r `HappyStk` stk')) + +happySpecReduce_3 i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happySpecReduce_3 nt fn j tk _ ((_):(((_):(sts@(((st@(HappyState (action))):(_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') + = let r = fn v1 v2 v3 in + happySeq r (action nt j tk st sts (r `HappyStk` stk')) + +happyReduce k i fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happyReduce k nt fn j tk st sts stk + = case happyDrop (k Prelude.- ((1) :: Prelude.Int)) sts of + sts1@(((st1@(HappyState (action))):(_))) -> + let r = fn stk in -- it doesn't hurt to always seq here... + happyDoSeq r (action nt j tk st1 sts1 r) + +happyMonadReduce k nt fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happyMonadReduce k nt fn j tk st sts stk = + case happyDrop k ((st):(sts)) of + sts1@(((st1@(HappyState (action))):(_))) -> + let drop_stk = happyDropStk k stk in + happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk)) + +happyMonad2Reduce k nt fn (1) tk st sts stk + = happyFail [] (1) tk st sts stk +happyMonad2Reduce k nt fn j tk st sts stk = + case happyDrop k ((st):(sts)) of + sts1@(((st1@(HappyState (action))):(_))) -> + let drop_stk = happyDropStk k stk + + + + + + _ = nt :: Prelude.Int + new_state = action + + in + happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk)) + +happyDrop (0) l = l +happyDrop n ((_):(t)) = happyDrop (n Prelude.- ((1) :: Prelude.Int)) t + +happyDropStk (0) l = l +happyDropStk n (x `HappyStk` xs) = happyDropStk (n Prelude.- ((1)::Prelude.Int)) xs + +----------------------------------------------------------------------------- +-- Moving to a new state after a reduction + + + + + + + + + +happyGoto action j tk st = action j j tk (HappyState action) + + +----------------------------------------------------------------------------- +-- Error recovery (ERROR_TOK is the error token) + +-- parse error if we are in recovery and we fail again +happyFail explist (1) tk old_st _ stk@(x `HappyStk` _) = + let i = (case x of { HappyErrorToken (i) -> i }) in +-- trace "failing" $ + happyError_ explist 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 ERROR_TOK tk old_st CONS(HAPPYSTATE(action),sts) + (saved_tok `HappyStk` _ `HappyStk` stk) = +-- trace ("discarding state, depth " ++ show (length stk)) $ + DO_ACTION(action,ERROR_TOK,tk,sts,(saved_tok`HappyStk`stk)) +-} + +-- Enter error recovery: generate an error token, +-- save the old token and carry on. +happyFail explist i tk (HappyState (action)) sts stk = +-- trace "entering error recovery" $ + action (1) (1) tk (HappyState (action)) sts ((HappyErrorToken (i)) `HappyStk` stk) + +-- Internal happy errors: + +notHappyAtAll :: a +notHappyAtAll = Prelude.error "Internal Happy error\n" + +----------------------------------------------------------------------------- +-- Hack to get the typechecker to accept our action functions + + + + + + + +----------------------------------------------------------------------------- +-- 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 `Prelude.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 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.