content: -- Notices:
  --
  -- Copyright 2020 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All Rights Reserved.
   
  -- Disclaimers
  -- No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.  FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."
   
  -- Waiver and Indemnity:  RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT.  IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW.  RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
    
  
  {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-}
  {-# LANGUAGE CPP #-}
  {-# LINE 3 "LexDecisionPaths.x" #-}
  
  {-# OPTIONS -fno-warn-incomplete-patterns #-}
  {-# OPTIONS_GHC -w #-}
  
  module Parser.LexDecisionPaths where
  
  import qualified Data.Bits
  import Data.Word (Word8)
  import Data.Char (ord)
  
  #if __GLASGOW_HASKELL__ >= 603
  #include "ghcconfig.h"
  #elif defined(__GLASGOW_HASKELL__)
  #include "config.h"
  #endif
  #if __GLASGOW_HASKELL__ >= 503
  import Data.Array
  import Data.Array.Base (unsafeAt)
  #else
  import Array
  #endif
  alex_tab_size :: Int
  alex_tab_size = 8
  alex_base :: Array Int Int
  alex_base = listArray (0 :: Int, 9)
    [ -8
    , -13
    , 60
    , 124
    , -3
    , 0
    , 268
    , 367
    , 466
    , -37
    ]
  
  alex_table :: Array Int Int
  alex_table = listArray (0 :: Int, 721)
    [ 0
    , 4
    , 4
    , 4
    , 4
    , 4
    , 4
    , 4
    , 4
    , 4
    , 4
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 0
    , 0
    , 0
    , 4
    , 0
    , 0
    , 0
    , 0
    , 4
    , 0
    , 0
    , 5
    , 5
    , 0
    , 0
    , 5
    , 0
    , 0
    , 0
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 9
    , 5
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 5
    , 0
    , 5
    , 0
    , 0
    , 0
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 0
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 0
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 2
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 0
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 0
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 0
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 8
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 0
    , 0
    , 0
    , 0
    , 0
    , 7
    , 0
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 0
    , 0
    , 0
    , 0
    , 6
    , 0
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 6
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 0
    , 0
    , 0
    , 0
    , 0
    , 7
    , 0
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 0
    , 0
    , 0
    , 0
    , 7
    , 2
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 7
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 8
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 0
    , 0
    , 0
    , 0
    , 8
    , 3
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 8
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 1
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 0
    , 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, 721)
    [ -1
    , 9
    , 10
    , 11
    , 12
    , 13
    , 9
    , 10
    , 11
    , 12
    , 13
    , 48
    , 49
    , 50
    , 51
    , 52
    , 53
    , 54
    , 55
    , 56
    , 57
    , -1
    , -1
    , -1
    , 32
    , -1
    , -1
    , -1
    , -1
    , 32
    , -1
    , -1
    , 40
    , 41
    , -1
    , -1
    , 44
    , -1
    , -1
    , -1
    , 48
    , 49
    , 50
    , 51
    , 52
    , 53
    , 54
    , 55
    , 56
    , 57
    , 58
    , -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
    , 91
    , -1
    , 93
    , -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
    , 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
    , 195
    , 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
    , 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
    , 39
    , 184
    , 185
    , 186
    , 187
    , 188
    , 189
    , 190
    , 191
    , 48
    , 49
    , 50
    , 51
    , 52
    , 53
    , 54
    , 55
    , 56
    , 57
    , -1
    , -1
    , -1
    , -1
    , -1
    , 63
    , -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
    , -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
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , 48
    , 49
    , 50
    , 51
    , 52
    , 53
    , 54
    , 55
    , 56
    , 57
    , -1
    , -1
    , -1
    , -1
    , -1
    , 63
    , -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
    , -1
    , -1
    , -1
    , 95
    , 195
    , 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
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , 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
    , -1
    , -1
    , -1
    , -1
    , 95
    , 195
    , 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
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , 195
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -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, 9)
    [ -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    , -1
    ]
  
  alex_accept = listArray (0 :: Int, 9)
    [ AlexAccNone
    , AlexAccNone
    , AlexAccNone
    , AlexAccNone
    , AlexAccSkip
    , AlexAcc 4
    , AlexAcc 3
    , AlexAcc 2
    , AlexAcc 1
    , AlexAcc 0
    ]
  
  alex_actions = array (0 :: Int, 5)
    [ (4,alex_action_1)
    , (3,alex_action_2)
    , (2,alex_action_2)
    , (1,alex_action_3)
    , (0,alex_action_4)
    ]
  
  {-# LINE 42 "LexDecisionPaths.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
   | T_Id !String
  
   deriving (Eq,Show,Ord)
  
  data Token =
     PT  Posn Tok
   | Err Posn
    deriving (Eq,Show,Ord)
  
  printPosn :: Posn -> String
  printPosn (Pn _ l c) = "line " ++ show l ++ ", column " ++ show c
  
  tokenPos :: [Token] -> String
  tokenPos (t:_) = printPosn (tokenPosn t)
  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)   -> show s
    PT _ (TI s)   -> s
    PT _ (TV s)   -> s
    PT _ (TD s)   -> s
    PT _ (TC s)   -> s
    Err _         -> "#error"
    PT _ (T_Id 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 "All" 5 (b "," 3 (b ")" 2 (b "(" 1 N N) N) (b ":" 4 N N)) (b "[" 7 (b "None" 6 N N) (b "]" 8 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
      '\\':'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_1 =  tok (\p s -> PT p (eitherResIdent (TV . share) s)) 
  alex_action_2 =  tok (\p s -> PT p (eitherResIdent (T_Id . share) s)) 
  alex_action_3 =  tok (\p s -> PT p (eitherResIdent (TV . share) s)) 
  alex_action_4 =  tok (\p s -> PT p (TI $ share s))    
  {-# 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
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  alexIndexInt16OffAddr arr off = arr ! off
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  alexIndexInt32OffAddr arr off = arr ! off
  
  
  
  
  
  
  
  
  
  
  
  quickIndex arr i = arr ! i
  
  
  -- -----------------------------------------------------------------------------
  -- Main lexing routines
  
  data AlexReturn a
    = AlexEOF
    | AlexError  !AlexInput
    | AlexSkip   !AlexInput !Int
    | AlexToken  !AlexInput !Int a
  
  -- alexScan :: AlexInput -> StartCode -> AlexReturn a
  alexScan input__ (sc)
    = alexScanUser undefined input__ (sc)
  
  alexScanUser user__ input__ (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 (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` (s)))
    in
    new_acc `seq`
    case alexGetByte input__ of
       Nothing -> (new_acc, input__)
       Just (c, new_input) ->
  
  
  
        case fromIntegral c of { (ord_c) ->
          let
                  base   = alexIndexInt32OffAddr alex_base s
                  offset = (base + ord_c)
                  check  = alexIndexInt16OffAddr alex_check offset
  
                  new_s = if (offset >= (0)) && (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__ (len)
          check_accs (AlexAccSkip) = AlexLastSkip  input__ (len)
  
          check_accs (AlexAccPred a predx rest)
             | predx user__ orig_input (len) input__
             = AlexLastAcc a input__ (len)
             | otherwise
             = check_accs rest
          check_accs (AlexAccSkipPred predx rest)
             | predx user__ orig_input (len) input__
             = AlexLastSkip input__ (len)
             | otherwise
             = check_accs rest
  
  
  data AlexLastAcc
    = AlexNone
    | AlexLastAcc !Int !AlexInput !Int
    | AlexLastSkip     !AlexInput !Int
  
  data AlexAcc user
    = AlexAccNone
    | AlexAcc Int
    | AlexAccSkip
  
    | 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 (sc) user__ _ _ input__ =
       case alex_scan_tkn user__ input__ (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.
  
  