@@ -166,14 +166,13 @@ data AlexState = AlexState {
166
166
alex_pos :: ! AlexPosn , -- position at current input location
167
167
# ifndef ALEX_MONAD_BYTESTRING
168
168
alex_inp :: String , -- the current input
169
+ alex_chr :: ! Char , -- the character before the input
170
+ alex_bytes :: [Byte ],
169
171
# else /* ALEX_MONAD_BYTESTRING */
170
172
alex_bpos :: ! Int64 , -- bytes consumed so far
171
173
alex_inp :: ByteString. ByteString , -- the current input
172
- # endif /* ALEX_MONAD_BYTESTRING */
173
174
alex_chr :: ! Char , -- the character before the input
174
- # ifndef ALEX_MONAD_BYTESTRING
175
- alex_bytes :: [Byte ],
176
- # endif /* ! ALEX_MONAD_BYTESTRING */
175
+ # endif /* ALEX_MONAD_BYTESTRING */
177
176
alex_scd :: ! Int -- the current startcode
178
177
# ifdef ALEX_MONAD_USER_STATE
179
178
, alex_ust :: AlexUserState -- AlexUserState will be defined in the user program
@@ -184,19 +183,16 @@ data AlexState = AlexState {
184
183
185
184
#ifndef ALEX_MONAD_BYTESTRING
186
185
runAlex :: String -> Alex a -> Either String a
186
+ runAlex input__ (Alex f)
187
+ = case f (AlexState {alex_bytes = [] ,
187
188
#else /* ALEX_MONAD_BYTESTRING */
188
189
runAlex :: ByteString. ByteString -> Alex a -> Either String a
189
- #endif /* ALEX_MONAD_BYTESTRING */
190
190
runAlex input__ (Alex f)
191
- = case f (AlexState {alex_pos = alexStartPos,
192
- #ifdef ALEX_MONAD_BYTESTRING
193
- alex_bpos = 0 ,
191
+ = case f (AlexState {alex_bpos = 0 ,
194
192
#endif /* ALEX_MONAD_BYTESTRING */
193
+ alex_pos = alexStartPos,
195
194
alex_inp = input__,
196
195
alex_chr = ' \n ' ,
197
- #ifndef ALEX_MONAD_BYTESTRING
198
- alex_bytes = [] ,
199
- #endif /* ! ALEX_MONAD_BYTESTRING */
200
196
#ifdef ALEX_MONAD_USER_STATE
201
197
alex_ust = alexInitUserState,
202
198
#endif
@@ -256,16 +252,14 @@ alexGetStartCode = Alex $ \s@AlexState{alex_scd=sc} -> Right (s, sc)
256
252
alexSetStartCode :: Int -> Alex ()
257
253
alexSetStartCode sc = Alex $ \ s -> Right (s{alex_scd= sc}, () )
258
254
259
- #ifndef ALEX_MONAD_BYTESTRING
260
- #ifdef ALEX_MONAD_USER_STATE
255
+ #if !defined(ALEX_MONAD_BYTESTRING) && defined(ALEX_MONAD_USER_STATE)
261
256
alexGetUserState :: Alex AlexUserState
262
257
alexGetUserState = Alex $ \ s@ AlexState {alex_ust= ust} -> Right (s,ust)
263
258
264
259
alexSetUserState :: AlexUserState -> Alex ()
265
260
alexSetUserState ss = Alex $ \ s -> Right (s{alex_ust= ss}, () )
266
- #endif
261
+ #endif /* !defined(ALEX_MONAD_BYTESTRING) && defined(ALEX_MONAD_USER_STATE) */
267
262
268
- #endif /* ! ALEX_MONAD_BYTESTRING */
269
263
alexMonadScan = do
270
264
#ifndef ALEX_MONAD_BYTESTRING
271
265
inp__ <- alexGetInput
0 commit comments