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 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
|
-- Generated by re2hs
{-# LANGUAGE RecordWildCards #-}
-- re2hs $INPUT -o $OUTPUT -i
{-# OPTIONS_GHC -Wno-unused-record-wildcards #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad (when)
import Data.ByteString (ByteString, index)
data Number = INum | FNum | NNaN deriving (Eq)
data State = State {
_yyinput :: ByteString,
_yycursor :: Int,
_yymarker :: Int,
_yyaccept :: Int
}
yy0 :: State -> Number
yy0 State{..} =
let yych = index _yyinput _yycursor in
let __ = _yycursor + 1 in let _yycursor = __ in
case yych of
_c | 0x2E == _c ->
yy3 State{..}
_c | 0x30 == _c ->
yy4 State{..}
_c | 0x31 <= _c && _c <= 0x39 ->
yy5 State{..}
_c | True ->
yy1 State{..}
yy1 :: State -> Number
yy1 State{..} =
yy2 State{..}
yy2 :: State -> Number
yy2 State{..} =
NNaN
yy3 :: State -> Number
yy3 State{..} =
let yych = index _yyinput _yycursor in
case yych of
_c | 0x30 <= _c && _c <= 0x39 ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy7 State{..}
_c | True ->
yy2 State{..}
yy4 :: State -> Number
yy4 State{..} =
let _yyaccept = 0 in
let _yymarker = _yycursor in
let yych = index _yyinput _yycursor in
case yych of
_c | 0x2E == _c ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy7 State{..}
_c | 0x30 <= _c && _c <= 0x39 ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy9 State{..}
_c | 0x45 == _c || 0x65 == _c ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy11 State{..}
_c | True ->
yy2 State{..}
yy5 :: State -> Number
yy5 State{..} =
let _yyaccept = 1 in
let _yymarker = _yycursor in
let yych = index _yyinput _yycursor in
case yych of
_c | 0x2E == _c ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy7 State{..}
_c | 0x30 <= _c && _c <= 0x39 ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy5 State{..}
_c | 0x45 == _c || 0x65 == _c ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy11 State{..}
_c | True ->
yy6 State{..}
yy6 :: State -> Number
yy6 State{..} =
INum
yy7 :: State -> Number
yy7 State{..} =
let _yyaccept = 2 in
let _yymarker = _yycursor in
let yych = index _yyinput _yycursor in
case yych of
_c | 0x30 <= _c && _c <= 0x39 ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy7 State{..}
_c | 0x45 == _c || 0x65 == _c ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy11 State{..}
_c | True ->
yy8 State{..}
yy8 :: State -> Number
yy8 State{..} =
FNum
yy9 :: State -> Number
yy9 State{..} =
let yych = index _yyinput _yycursor in
case yych of
_c | 0x2E == _c ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy7 State{..}
_c | 0x30 <= _c && _c <= 0x39 ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy9 State{..}
_c | 0x45 == _c || 0x65 == _c ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy11 State{..}
_c | True ->
yy10 State{..}
yy10 :: State -> Number
yy10 State{..} =
let _yycursor = _yymarker in
case _yyaccept of
_c | 0 == _c ->
yy2 State{..}
_c | 1 == _c ->
yy6 State{..}
_c | True ->
yy8 State{..}
yy11 :: State -> Number
yy11 State{..} =
let yych = index _yyinput _yycursor in
case yych of
_c | 0x2B == _c || 0x2D == _c ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy12 State{..}
_c | 0x30 <= _c && _c <= 0x39 ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy13 State{..}
_c | True ->
yy10 State{..}
yy12 :: State -> Number
yy12 State{..} =
let yych = index _yyinput _yycursor in
case yych of
_c | 0x30 <= _c && _c <= 0x39 ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy13 State{..}
_c | True ->
yy10 State{..}
yy13 :: State -> Number
yy13 State{..} =
let yych = index _yyinput _yycursor in
case yych of
_c | 0x30 <= _c && _c <= 0x39 ->
let __ = _yycursor + 1 in let _yycursor = __ in
yy13 State{..}
_c | True ->
yy8 State{..}
lexer :: State -> Number
lexer State{..} =
yy0 State{..}
main :: IO ()
main = do
let test s n = do
let st = State {
_yyinput = s,
_yycursor = 0,
_yymarker = 0,
_yyaccept = 0}
when (lexer st /= n) $ error "failed"
test "123\0" INum
test "123.4567\0" FNum
|