2
{-# LINE 13 "Scan.x" #-}
3
module Scan(lexer, AlexPosn(..), Token(..), Tkn(..), tokPosn) where
9
#if __GLASGOW_HASKELL__ >= 503
11
import Data.Char (ord)
12
import Data.Array.Base (unsafeAt)
17
alex_base :: Array Int Int
18
alex_base = listArray (0,76) [-8,110,137,119,124,-4,-3,-37,-36,0,128,129,0,114,-35,115,-34,251,365,256,116,117,-33,0,138,0,423,0,-106,-100,-82,-96,-95,-83,-94,222,331,515,594,617,341,649,0,0,655,770,884,644,968,1052,1113,1227,1341,1455,1453,1537,1598,0,135,396,167,168,-26,0,169,801,170,281,-24,0,0,1682,1766,0,0,0,736]
20
alex_table :: Array Int Int
21
alex_table = listArray (0,2021) [0,4,4,4,4,4,-1,-1,5,5,12,12,20,29,30,31,32,33,34,60,27,66,0,0,4,43,10,25,26,28,43,43,25,25,25,25,25,8,25,25,43,43,43,43,43,43,43,43,43,43,16,25,69,43,43,25,44,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,25,37,25,25,43,43,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,24,25,25,25,4,4,4,4,4,-1,-1,-1,-1,4,4,4,4,4,4,4,4,4,4,-1,-1,0,0,4,0,0,-1,4,4,4,4,4,4,0,0,0,7,4,0,0,0,13,0,9,9,7,0,0,0,0,4,0,0,15,15,15,15,0,-1,-1,-1,-1,73,7,0,0,70,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,58,0,0,74,0,0,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,58,58,64,64,0,76,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,19,19,19,19,19,19,19,19,19,19,35,35,35,35,35,35,35,35,35,35,0,0,0,19,0,0,0,0,19,0,18,-1,0,0,0,0,22,0,0,18,18,18,18,18,18,18,18,18,18,14,0,0,0,0,14,0,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,64,0,0,0,18,0,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,35,35,35,35,35,35,35,35,35,35,40,40,40,40,40,40,40,40,19,0,0,0,0,0,0,18,59,59,59,59,59,22,0,0,18,18,18,18,18,18,18,18,18,18,14,0,0,0,0,59,0,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,0,57,0,0,18,0,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,0,0,0,0,0,0,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,50,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,36,36,36,36,36,36,36,36,36,36,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,41,42,42,42,42,42,42,42,42,39,42,42,42,42,42,42,38,38,38,38,38,38,38,38,38,38,0,59,59,59,59,59,0,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,0,59,0,0,0,0,0,38,38,38,38,38,38,0,62,0,38,38,38,38,38,38,40,40,40,40,40,40,40,40,57,0,0,0,0,0,0,0,0,38,38,38,38,38,38,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,0,0,0,0,0,0,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,56,59,59,59,59,59,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,59,0,0,0,0,0,0,46,65,65,65,65,65,62,0,0,46,46,46,46,46,46,46,46,46,46,0,0,0,57,0,65,0,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,0,63,0,0,46,0,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,59,59,59,59,59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,0,0,0,0,0,0,46,0,0,0,0,0,62,0,0,46,46,46,46,46,46,46,46,46,46,0,0,0,57,0,0,0,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,0,0,0,0,46,0,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,49,0,0,0,0,0,0,0,0,49,49,49,49,49,49,49,49,49,49,0,0,0,0,0,0,0,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,0,0,0,0,49,0,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,0,47,0,0,0,0,0,0,49,49,49,49,49,49,49,49,49,49,0,0,0,0,0,0,0,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,0,0,0,0,49,0,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,0,0,47,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,0,0,0,0,0,0,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,65,65,65,65,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,0,0,0,0,0,0,52,0,0,0,0,0,68,0,0,52,52,52,52,52,52,52,52,52,52,0,0,0,63,0,0,0,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,0,0,0,0,52,0,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,65,65,65,65,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,0,0,0,0,0,0,52,0,0,0,0,0,68,0,0,52,52,52,52,52,52,52,52,52,52,0,0,0,63,0,0,0,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,0,0,0,0,52,0,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,65,65,65,65,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,0,0,0,0,55,0,0,0,0,0,0,0,68,55,55,55,55,55,55,55,55,55,55,0,0,0,0,0,63,0,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,0,0,0,0,55,0,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,0,53,0,0,0,0,0,0,55,55,55,55,55,55,55,55,55,55,0,0,0,0,0,0,0,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,0,0,0,0,55,0,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,0,0,53,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,0,0,0,0,0,0,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,72,0,0,0,0,0,0,0,0,72,72,72,72,72,72,72,72,72,72,0,0,0,0,0,0,0,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,0,0,0,0,72,0,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,0,0,0,0,0,0,0,0,72,72,72,72,72,72,72,72,72,72,0,0,0,0,0,0,0,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,0,0,0,0,72,0,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,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,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]
23
alex_check :: Array Int Int
24
alex_check = listArray (0,2021) [-1,9,10,11,12,13,10,10,45,45,45,45,45,119,114,97,112,112,101,45,114,45,-1,-1,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,9,10,11,12,13,10,10,10,10,9,10,11,12,13,9,10,11,12,13,10,10,-1,-1,32,-1,-1,10,9,10,11,12,13,32,-1,-1,-1,45,32,-1,-1,-1,45,-1,34,34,45,-1,-1,-1,-1,32,-1,-1,58,58,58,58,-1,10,10,10,10,44,45,-1,-1,48,48,49,50,51,52,53,54,55,56,57,61,-1,-1,62,-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,61,61,61,61,-1,123,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,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,39,10,-1,-1,-1,-1,45,-1,-1,48,49,50,51,52,53,54,55,56,57,58,-1,-1,-1,-1,58,-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,61,-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,9,10,11,12,13,48,49,50,51,52,53,54,55,56,57,48,49,50,51,52,53,54,55,32,-1,-1,-1,-1,-1,-1,39,9,10,11,12,13,45,-1,-1,48,49,50,51,52,53,54,55,56,57,58,-1,-1,-1,-1,32,-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,61,-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,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,-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,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,48,49,50,51,52,53,54,55,56,57,-1,9,10,11,12,13,-1,65,66,67,68,69,70,48,49,50,51,52,53,54,55,56,57,-1,32,-1,-1,-1,-1,-1,65,66,67,68,69,70,-1,45,-1,97,98,99,100,101,102,48,49,50,51,52,53,54,55,61,-1,-1,-1,-1,-1,-1,-1,-1,97,98,99,100,101,102,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,-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,9,10,11,12,13,48,49,50,51,52,53,54,55,56,57,-1,-1,-1,-1,-1,-1,-1,-1,32,-1,-1,-1,-1,-1,-1,39,9,10,11,12,13,45,-1,-1,48,49,50,51,52,53,54,55,56,57,-1,-1,-1,61,-1,32,-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,61,-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,9,10,11,12,13,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,-1,-1,-1,-1,-1,-1,39,-1,-1,-1,-1,-1,45,-1,-1,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,-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,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,-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,39,-1,125,-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,-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,125,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,-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,9,10,11,12,13,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,-1,-1,-1,-1,-1,-1,39,-1,-1,-1,-1,-1,45,-1,-1,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,-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,9,10,11,12,13,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,-1,-1,-1,-1,-1,-1,39,-1,-1,-1,-1,-1,45,-1,-1,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,-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,9,10,11,12,13,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,-1,-1,-1,-1,39,-1,-1,-1,-1,-1,-1,-1,45,48,49,50,51,52,53,54,55,56,57,-1,-1,-1,-1,-1,61,-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,39,-1,125,-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,-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,125,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,-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,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,-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,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,-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,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-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
alex_deflt :: Array Int Int
27
alex_deflt = listArray (0,76) [-1,-1,-1,-1,-1,6,6,-1,-1,-1,11,11,-1,21,-1,21,-1,-1,-1,-1,21,21,-1,-1,23,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,61,-1,61,61,-1,-1,67,-1,67,67,-1,-1,-1,-1,-1,-1,-1,-1,75]
29
alex_accept = listArray (0::Int,76) [[],[(AlexAcc (alex_action_21))],[],[],[(AlexAcc (alex_action_0))],[(AlexAcc (alex_action_0))],[(AlexAcc (alex_action_0))],[],[(AlexAcc (alex_action_4))],[(AlexAcc (alex_action_1))],[(AlexAcc (alex_action_10))],[],[(AlexAcc (alex_action_2))],[(AlexAcc (alex_action_2))],[],[],[(AlexAcc (alex_action_10))],[(AlexAcc (alex_action_10))],[],[],[],[],[],[(AlexAcc (alex_action_3))],[(AlexAcc (alex_action_4))],[(AlexAcc (alex_action_4))],[(AlexAcc (alex_action_4))],[(AlexAcc (alex_action_5))],[],[],[],[],[],[],[],[(AlexAcc (alex_action_6))],[(AlexAcc (alex_action_6))],[(AlexAcc (alex_action_10))],[(AlexAcc (alex_action_7))],[(AlexAcc (alex_action_9))],[(AlexAcc (alex_action_8))],[(AlexAcc (alex_action_9))],[(AlexAcc (alex_action_9))],[(AlexAcc (alex_action_10))],[(AlexAcc (alex_action_10))],[(AlexAcc (alex_action_11))],[(AlexAcc (alex_action_11))],[(AlexAcc (alex_action_11))],[],[],[],[(AlexAcc (alex_action_12))],[(AlexAcc (alex_action_12))],[(AlexAcc (alex_action_12))],[],[],[],[(AlexAcc (alex_action_13))],[(AlexAcc (alex_action_13))],[],[],[],[],[(AlexAcc (alex_action_14))],[(AlexAcc (alex_action_14))],[],[],[],[],[(AlexAcc (alex_action_15))],[(AlexAcc (alex_action_16))],[(AlexAcc (alex_action_17))],[(AlexAcc (alex_action_17))],[(AlexAcc (alex_action_18))],[(AlexAcc (alex_action_19))],[(AlexAcc (alex_action_20))],[]]
30
{-# LINE 73 "Scan.x" #-}
32
-- -----------------------------------------------------------------------------
35
data Token = T AlexPosn Tkn
57
-- -----------------------------------------------------------------------------
60
special (p,_,str) ln = return $ T p (SpecialT (head str))
61
zero (p,_,str) ln = return $ T p ZeroT
62
string (p,_,str) ln = return $ T p (StringT (extract ln str))
63
bind (p,_,str) ln = return $ T p (BindT (takeWhile isIdChar str))
64
escape (p,_,str) ln = return $ T p (CharT (esc str))
65
decch (p,_,str) ln = return $ T p (CharT (do_ech 10 ln (take (ln-1) (tail str))))
66
hexch (p,_,str) ln = return $ T p (CharT (do_ech 16 ln (take (ln-2) (drop 2 str))))
67
octch (p,_,str) ln = return $ T p (CharT (do_ech 8 ln (take (ln-2) (drop 2 str))))
68
char (p,_,str) ln = return $ T p (CharT (head str))
69
smac (p,_,str) ln = return $ T p (SMacT (mac ln str))
70
rmac (p,_,str) ln = return $ T p (RMacT (mac ln str))
71
smacdef (p,_,str) ln = return $ T p (SMacDefT (macdef ln str))
72
rmacdef (p,_,str) ln = return $ T p (RMacDefT (macdef ln str))
73
startcode (p,_,str) ln = return $ T p (IdT (take ln str))
74
wrapper (p,_,str) ln = return $ T p WrapperT
76
isIdChar c = isAlphaNum c || c `elem` "_'"
78
extract ln str = take (ln-2) (tail str)
80
do_ech radix ln str = chr (parseInt radix str)
82
mac ln (_ : str) = take (ln-1) str
84
macdef ln (_ : str) = takeWhile (not.isSpace) str
97
parseInt :: Int -> String -> Int
98
parseInt radix ds = foldl1 (\n d -> n * radix + d) (map digitToInt ds)
100
-- In brace-delimited code, we have to be careful to match braces
101
-- within the code, but ignore braces inside strings and character
102
-- literals. We do an approximate job (doing it properly requires
103
-- implementing a large chunk of the Haskell lexical syntax).
105
code (p,_,inp) len = do
111
return (T p (CodeT (reverse (tail cs))))
113
case alexGetChar inp of
117
'{' -> go inp (n+1) (c:cs)
118
'}' -> go inp (n-1) (c:cs)
119
'\'' -> go_char inp n (c:cs)
120
'\"' -> go_str inp n (c:cs) '\"'
123
-- try to catch occurrences of ' within an identifier
124
go_char inp n (c1:c2:cs) | isAlphaNum c2 = go inp n (c1:c2:cs)
125
go_char inp n cs = go_str inp n cs '\''
127
go_str inp n cs end = do
128
case alexGetChar inp of
131
| c == end -> go inp n (c:cs)
134
'\\' -> case alexGetChar inp of
136
Just (d,inp) -> go_str inp n (d:c:cs) end
137
c -> go_str inp n (c:cs) end
139
err inp = do setInput inp; lexError "lexical error in code fragment"
144
(p,_,input) <- getInput
145
failP (s ++ (if (not (null input))
146
then " at " ++ show (head input)
147
else " at end of file"))
149
lexer :: (Token -> P a) -> P a
150
lexer cont = lexToken >>= cont
154
inp@(p,_,_) <- getInput
156
case alexScan inp sc of
157
AlexEOF -> return (T p EOFT)
158
AlexError _ -> lexError "lexical error"
159
AlexSkip inp1 len -> do
162
AlexToken inp1 len t -> do
166
type Action = AlexInput -> Int -> P Token
171
andBegin :: Action -> StartCode -> Action
172
andBegin act sc inp len = setStartCode sc >> act inp len
175
afterstartcodes,startcodes :: Int
179
alex_action_1 = string
182
alex_action_4 = special
183
alex_action_5 = wrapper
184
alex_action_6 = decch
185
alex_action_7 = hexch
186
alex_action_8 = octch
187
alex_action_9 = escape
188
alex_action_10 = char
189
alex_action_11 = smac
190
alex_action_12 = rmac
191
alex_action_13 = smacdef
192
alex_action_14 = rmacdef
193
alex_action_15 = special `andBegin` startcodes
194
alex_action_16 = zero
195
alex_action_17 = startcode
196
alex_action_18 = special
197
alex_action_19 = special `andBegin` afterstartcodes
198
alex_action_20 = special `andBegin` 0
199
alex_action_21 = skip `andBegin` 0
200
{-# LINE 1 "GenericTemplate.hs" #-}
201
-- -----------------------------------------------------------------------------
204
-- This code is in the PUBLIC DOMAIN; you may copy it freely and use
205
-- it for any purpose whatsoever.
207
-- -----------------------------------------------------------------------------
208
-- INTERNALS and main scanner engine
210
{-# LINE 22 "GenericTemplate.hs" #-}
234
{-# LINE 66 "GenericTemplate.hs" #-}
236
alexIndexShortOffAddr arr off = arr ! off
239
-- -----------------------------------------------------------------------------
240
-- Main lexing routines
244
| AlexError !AlexInput
245
| AlexSkip !AlexInput !Int
246
| AlexToken !AlexInput !Int a
248
-- alexScan :: AlexInput -> StartCode -> Maybe (AlexInput,Int,act)
250
= alexScanUser undefined input (sc)
252
alexScanUser user input (sc)
253
= case alex_scan_tkn user input (0) input sc AlexNone of
254
(AlexNone, input') ->
255
case alexGetChar input of
267
(AlexLastSkip input len, _) ->
273
(AlexLastAcc k input len, _) ->
277
AlexToken input len k
280
-- Push the input through the DFA, remembering the most recent accepting
281
-- state it encountered.
283
alex_scan_tkn user orig_input len input s last_acc =
284
input `seq` -- strict in the input
286
(-1) -> (last_acc, input)
287
_ -> alex_scan_tkn' user orig_input len input s last_acc
289
alex_scan_tkn' user orig_input len input s last_acc =
291
new_acc = check_accs (alex_accept `unsafeAt` (s))
294
case alexGetChar input of
295
Nothing -> (new_acc, input)
296
Just (c, new_input) ->
301
base = alexIndexShortOffAddr alex_base s
303
offset = (base + ord_c)
304
check = alexIndexShortOffAddr alex_check offset
306
new_s = if (offset >= (0)) && (check == ord_c)
307
then alexIndexShortOffAddr alex_table offset
308
else alexIndexShortOffAddr alex_deflt s
310
alex_scan_tkn user orig_input (len + (1)) new_input new_s new_acc
313
check_accs [] = last_acc
314
check_accs (AlexAcc a : _) = AlexLastAcc a input (len)
315
check_accs (AlexAccSkip : _) = AlexLastSkip input (len)
316
check_accs (AlexAccPred a pred : rest)
317
| pred user orig_input (len) input
318
= AlexLastAcc a input (len)
319
check_accs (AlexAccSkipPred pred : rest)
320
| pred user orig_input (len) input
321
= AlexLastSkip input (len)
322
check_accs (_ : rest) = check_accs rest
326
| AlexLastAcc a !AlexInput !Int
327
| AlexLastSkip !AlexInput !Int
332
| AlexAccPred a (AlexAccPred user)
333
| AlexAccSkipPred (AlexAccPred user)
335
type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool
337
-- -----------------------------------------------------------------------------
338
-- Predicates on a rule
340
alexAndPred p1 p2 user in1 len in2
341
= p1 user in1 len in2 && p2 user in1 len in2
343
--alexPrevCharIsPred :: Char -> AlexAccPred _
344
alexPrevCharIs c _ input _ _ = c == alexInputPrevChar input
346
--alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _
347
alexPrevCharIsOneOf arr _ input _ _ = arr ! alexInputPrevChar input
349
--alexRightContext :: Int -> AlexAccPred _
350
alexRightContext (sc) user _ _ input =
351
case alex_scan_tkn user input (0) input sc AlexNone of
352
(AlexNone, _) -> False
354
-- TODO: there's no need to find the longest
355
-- match when checking the right context, just
356
-- the first match will do.