Search code examples
f#fparsec

Parse case-insensitive operators using OperatorPrecedenceParser


Is it possible to parse a non-symbolic operator (e.g., AND, OR) case-insensitively using OperatorPrecedenceParser?


Solution

  • The OperatorPrecedenceParser has no built-in support for case insensitive matching of non-symbolic operators.

    However, if your non-symbolic operators are short or you only have to support a few spelling variants (e.g. all lowercase, all uppercase, only first char uppercase, ...) then you can simply add all variants of the operator that you need to support. (Of course, you'd add the variants with a little helper function, not manually.)