を使用して、大文字と小文字を区別せずに非記号演算子 (例: , ) を解析することは可能AND
ですか?OR
OperatorPrecedenceParser
2 に答える
OperatorPrecedenceParser には、大文字と小文字を区別しない非記号演算子の一致に対する組み込みサポートはありません。
ただし、非シンボリック演算子が短い場合、またはいくつかのスペル バリアントのみをサポートする必要がある場合 (たとえば、すべて小文字、すべて大文字、最初の文字のみ大文字など) は、必要な演算子のすべてのバリアントを追加するだけで済みます。サポートする。(もちろん、手動ではなく、小さなヘルパー関数を使用してバリアントを追加します。)
It looks like PeekOp
is the method that handles determining whether there is an operator or not. It has no mention or method to handle case-insensitivity, since it relies on straight equality of characters (and CharStream.Match
).
You could always add the various possible versions of the operator manually. e.g.
Add("or");
Add("oR");
Add("Or");
Add("OR");
Finally another option would be to create a helper method to do this.