-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore case new syntax #1002
Comments
Don't create all to fragment rule just override LA in the input stream and always return toLower. On Mon, Sep 21, 2015 at 4:04 AM -0700, "Ivan Kochurkin" notifications@github.com wrote: What do you think about new lexer command for case ignoring? Procedure: 'procedure' -> ignoreCase; Or to use regex-like syntax (which gives more flexibility, for example ignore part of word): Procedure: '\iprocedure-i'; Now I have to use the following syntax: Procedure: P R O C E D U R E; This feature especially important for case-insensivity languages, such as Pascal, PHP, etc. — |
@jimidle. Firstly, your solution runtime-dependent. Secondly, parsed language can be case-insensivity not for all parts (php). There is such solution: https://github.com/developeron29/PLSQLParser/blob/master/PLSQL.g4#L534 For example, the following tokens have an equal beginning, so it can be optimized. DO
: D O
;
DOWNTO
: D O W N T O
; |
It is faster than our fragment rules and as you specify only lower case letters in the lever rules it is better optimizes. I came up with original method and did the performance test. Regular expressions won't be implemented. So stick with your current method if you feel that overriding a single method is too much trouble.
|
@jimidle , could you please show the grammar sample with your view of case insensitive tokens? |
I believe I have already put this in the public domain but of course your own needs may be different. On Fri, Sep 25, 2015 at 3:30 PM -0700, "Ivan Kochurkin" notifications@github.com wrote: @jimidle , could you please show the grammar sample with your view of case insensitive tokens? — |
Actually
Or even easier:
Here is described that "there is no ANTLR option that enables case insensitivity, as this is hard or impossible to do completely correctly, taking into account all possible internationalization issues", but in most cases not english chars are rarely used. Moreover it is possible to use warning "Lexer rule with not english chars and ignoreCase option may produce incorrect output". And for most cases performance with fragment rules is good. So, I think this option have the right to existence. |
I like |
Yes, the option is useful. But this issue a bit outdated. It's not possible to use option for a single token, but possible to use it for |
It seems that none of these options are available in the 4.4.6 release :( |
I'm agree, it's a sad news because this feature can be usefull in the grammar to test immediatly with the tools without to create a program with a spacial input stream. |
What do you think about new lexer command for case ignoring?
Or to use regex-like syntax (which gives more flexibility, for example ignore part of word):
Now I have to use the following not pretty syntax:
This feature especially important for case-insensivity languages, such as Pascal, PHP, etc.
The text was updated successfully, but these errors were encountered: