hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

Case Insensitive Lexer

Last post 07-08-2008, 23:47 by macmariman. 4 replies.
Sort Posts: Previous Next
  •  06-25-2008, 23:33 6200

    Case Insensitive Lexer

    Hello all,

    Can anybody tell me what is the best way to make my lexer case-insensitive?
    Maybe there is a command line argument or something like that in fslex.
    Thanks in advance,

    Martin
  •  06-26-2008, 3:48 6204 in reply to 6200

    Re: Case Insensitive Lexer

    How about converting your input to all lowercase (or uppercase) before feeding it into the lexer?

    Stephan

  •  07-07-2008, 20:24 6326 in reply to 6204

    Re: Case Insensitive Lexer

    Stephan, thanks for your suggestion it seems that my alerts are not working...
    That is how I have it implemented rigth now, however that means that if I have a string "Hello" it will be treated the same as "hello". I want the lexer to recognize the tokens independently of the casing without having to normalize the whole input. No magic swithces available?
    Thanks,

    Martín
  •  07-08-2008, 4:43 6328 in reply to 6326

    Re: Case Insensitive Lexer

    None of the email notifications work, which is a pitty.

    I don't think there's command line switch, but you could just use a pattern like "[kK][eE][yY][wW][oO][rR][dD]" instead of "keyword" in the lexer. That's a bit cumbersome to type but should do the trick.

    Stephan
  •  07-08-2008, 23:47 6331 in reply to 6328

    Re: Case Insensitive Lexer

    Thanks for the suggestion it seems that flex has a -i switch that solves that. Too bad it wasn't implemented in fslex. Also .Net regular expressions have the (?i) flag to ignore case but this isn't working either. In the end I will implement what you said. Thanks a lot for your help.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems