initialization of AlexUserState

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

initialization of AlexUserState

Kees Bleijenberg

Hi All,

 

I have a Alex lexer with wrapper "monadUserState-bytestring". The AlexUserState = AlexUserState {sheetNames:: {String], currSheet:: Int}.  The lexer should check whether a found sheetname is in sheetNames. The sheetNames from AlexUserState come from outside. I want to invoke the lexer many times with different AlexUserStates.  Therefore the alexInitUserState function is not what I want. I’de like to initialize the AlexUserState while starting the lexer, i.e. as a parameter to runAlex. Can that be done?

 

Kees


Virusvrij. www.avast.com

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: initialization of AlexUserState

Vanessa McHale

I would just add a function

setAlexUserState :: AlexUserState -> Alex ()
setAlexUserState = ...

and then write another

run :: AlexUserState -> Alex ()
run st = do
    setAlexUserState st
    alexMonadScan

or what have you

On 3/15/19 6:16 AM, Kees Bleijenberg wrote:

Hi All,

 

I have a Alex lexer with wrapper "monadUserState-bytestring". The AlexUserState = AlexUserState {sheetNames:: {String], currSheet:: Int}.  The lexer should check whether a found sheetname is in sheetNames. The sheetNames from AlexUserState come from outside. I want to invoke the lexer many times with different AlexUserStates.  Therefore the alexInitUserState function is not what I want. I’de like to initialize the AlexUserState while starting the lexer, i.e. as a parameter to runAlex. Can that be done?

 

Kees


Virusvrij. www.avast.com

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

signature.asc (499 bytes) Download Attachment