-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix keyword loading to use any whitespace as separator #6693
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
Conversation
Instead of forcing keywords.txt to use tabs, let library developers use spaces too.
So is this finally going to be fixed after years of neglect? |
This PR was merged in beta-1.9 branch as 13824d7 , if no user will report any problem we are going to proceed merging it into master soon. |
merged in eed9e70 |
@bhagman @bperrybap Some examples are:
this is the IDE before the patch: and this is after the patch: as you can see the color coding is not taken but instead is interpreted as a reference-link (3rd position instead of 4th) this is confirmed if I right-click on the this failure is also reported by the PdeKeywordsTest test:
I'm going to revert this patch, until we find a different solution. At this point I don't know if a backward-compatible solution may be find, maybe the best way forward is to keep the current format and provide a better documentation? |
@cmaglie
Regardless of how the current code is parsing it, shouldn't a line like that actually mean two fields "A" and "B" ? So are you saying that the keywords file format intentionally supports the ability to skip fields or just that the current parsing code to parse it is broken? Off topic but, but your comments seem to suggest that there are fields that I'm not familiar with. Regardless of the number of fields in the keywords file, When using whitespace as a field seperator, you won't have empty fields anymore since whitespace means 1 or more of either or It appears that the patch used didn't use whitespace as a separator but rather simply used a single space or a single tab which is not the same as whitespace. |
Yes, there is the ability to skip a field using two tabs as in my We can argue if this is nice or bad, but this is not something we can change now because hundreds of Anyway let's continue the discussion in #7245 that looks more promising. |
What is most important is the intended file format not the way the code may be parsing it. |
The only documentation I know of is here: Note they both do mention a tab separator. After looking at hundreds of keywords.txt files I can tell you that the use of spaces instead of tabs is very common (~15% of libraries). Of the rest, the great majority use multiple tabs as a separator (even though the documentation doesn't specify that being supported) and disturbingly high number have a random mixture of tabs and spaces. I don't understand the purpose of the multiple identifiers per keyword used in the IDE's global keywords.txt. If relevant to libraries, it would be nice if that usage was documented on the library specification page. I'm happy to do the writing but can't without understanding how it works. |
It is really messy since depending on the version of the IDE the parsers were changed/modified which alters the expected format and what is supported. |
Thanks to @per1234 to point me to this issue. I didn't realize about the fact that is completely mandatory, inside keywords file, to use tabulator as member separator. First by the fact that the IDE provides a poor variety of code editors capabilities, and as I'm used to Sublime Text, it add 0 work to see a function as a function, or a variable as a variable. Being a tabulator a (extremely old) type of CSV file, and giving tons of headaches along lot and lot of years because it's a width-variable and non-visible character. Why is still in use, and moreover as a unique and a mandatory way to create keywords in Arduino? As a CSV-like file (which means positional members with the error-prone that it directly inferes), Why is not at least selectable which character to use for fields separators? If keywords does not allow spaces, what is the sense of use a non-space character for that? There is a lot of ways to define keywords, in use in top editors:
Not a single one use positional fields for that. And just offtopic (as we're not talking about indentation), but nice to read:
Come on Arduino! Great devices, great software, great libraries ... but this as the unique way for syntax highlight of custom keywords? My support to @per1234, hard work he does! |
In a bit over 35 years of using s/w on many operating systems. The only tool and files that I have ever seen that have used such a rigid format for separators is make. makefiles are stupidly rigid and use a single tab field as separator for rules. The format of the keyword file is even worse, in that not only is it using an invisible field separator, but the format of the file is not formally defined and its format has changed over the years making it impossible to create something that is fully compatible with all possible file formats from the past. IMO, it is time to move to a new/extended format. My suggestion would be to put a version #, key, or identifier on the first line so that the new format could be detected and then used. The new format should be VERY liberal, and allow whitespace or a comma as field separators and NOT allow blank/missing/skipped fields. That way, nearly everybody should be able to get something they like and get things to look "pretty" in the file.
would be a single field separator. If you want/need to skip a field or have a null field, use commas and put nothing between the two commas for that field. The point is to be very liberal in the format to support a few different styles of field separation all while keeping the parsing very simple. |
Oh and once there is a version identifier in the file, it would be easy to change formats in the future and or add support for additional formats. |
Instead of forcing keywords.txt to use tabs, let library developers use spaces too.