3

を使用して、大文字と小文字を区別せずに非記号演算子 (例: , ) を解析することは可能ANDですか?OROperatorPrecedenceParser

4

2 に答える 2

3

OperatorPrecedenceParser には、大文字と小文字を区別しない非記号演算子の一致に対する組み込みサポートはありません。

ただし、非シンボリック演算子が短い場合、またはいくつかのスペル バリアントのみをサポートする必要がある場合 (たとえば、すべて小文字、すべて大文字、最初の文字のみ大文字など) は、必要な演算子のすべてのバリアントを追加するだけで済みます。サポートする。(もちろん、手動ではなく、小さなヘルパー関数を使用してバリアントを追加します。)

于 2012-02-10T00:23:10.753 に答える
2

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.

于 2012-02-09T23:58:34.220 に答える