Skip to content

Is there a way to modify the default lexical error message from within an .x file. #276

@jamiloBBKing

Description

@jamiloBBKing

The lexical error message comes from this function in the generated .hs file:

#ifdef ALEX_MONAD_BYTESTRING
alexMonadScan = do
  inp__@(_,_,_,n) <- alexGetInput
  sc <- alexGetStartCode
  case alexScan inp__ sc of
    AlexEOF -> alexEOF
    AlexError ((AlexPn _ line column),_,_,_) -> alexError $ "lexical error at line " ++ (show line) ++ ", column " ++ (show column)
    AlexSkip  inp__' _len -> do
        alexSetInput inp__'
        alexMonadScan
    AlexToken inp__'@(_,_,_,n') _ action -> let len = n'-n in do
        alexSetInput inp__'
        action (ignorePendingBytes inp__) len
#endif

I can alter the line alexError $ "lexical error at line " ++ (show line) ++ ", column " ++ (show column) to get what I want but, this is going to require manual changes every time I regenerate the lexer. Is there some simple workaround or can this be added as a feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions