vsajip I can't say anything based on a personal need for this feature, but it seems not an unreasonable thing. I would just ask, if you do implement it, it's easy enough to do in all generation languages ...
Well, once the ability to inject code in other languages is squared away, the implementation (the one that occurred to me anyway) would be about as easy in non-Java languages as in Java. Basically, we need to be able to specify some kind of accept
method for the various TokenType
s -- the default one being just maybe:
boolean accept(String input) {return true;}
But if that is overridden for a given TokenType
, and the method (based on whatever user-defined logic) returns false, then you wind back to where the token started, deactivate that token type and re-tokenize. (And then you turn the token type back on.)
But then, I was thinking about this further and I find myself wondering whether there are really very many (or any) use cases where you couldn't handle whatever it is equally well using the TOKEN_HOOK
mechanism anyway.
So, this does kind of lead into the question of whether one is going to implement things willy-nilly just because they can be done. But I sort of throw the question out there just to see if anybody out there pops up and says "oh, wow, that's exactly what I need"....
And then there is this other more general question about people -- I guess, even people who are not even currently using the tool -- requesting something... I'm thinking in particular about this whole Maven Central question... There is somebody (I'm not even going to say his name) who was saying somewhere that I had adamantly refused to put JavaCC 21 on Maven Central.
I don't feel that is really an accurate characterization of what is going on with that. In fact, I earlier intended to put up some versions on Maven Central, but only because this was so important to certain people -- according to them! But then I ran into the problem that their system (I mean Sonatype) was so baroque and user unfriendly that I always had better things to do than to figure out, basically.
In other matters (though similar, I guess) recently, on the command-line in Ubuntu, I idly typed:
sudo apt install javacc
And, yep, it installed it. So then I saw that there was now a javacc script in my /usr/bin that looks like:
#!/bin/sh
JAR=/usr/share/java/javacc.jar
java -classpath "$JAR" javacc "$@"
(There is also a jjtree
script that looks like the above one, except with jjtree
insteas of javacc
.
So it drops the javacc.jar into /usr/share/java (a place where a lot of jarfiles get dropped, it seems.) But here is an interesting thing. The ubuntu package manager installs JavaCC 5.0, which was released in September of 2009, about 13 years ago. I mean, it would be nice if you could type:
sudo apt install javacc21
in Ubuntu (and all its offspring) and it would just install the thing, but then that does, in principle, leave one with the obligation of keeping it up to date. (Though JavaCC 21 actually has a separate solution to that, that it actually checks the server for a newer version, unless you ask it not to... so maybe that's not even a big deal...)
But getting back to the Maven Central question, I guess I can say that if a high-profile project that uses the legacy JavaCC were to approach us and say: "Well, look, it's very important for us that the thing be on Maven Central. That prevents us from using it.", well, I guess I would finally go through the steps and put it up there. However, what I anticipate is that they are perfectly capable of saying how important this is to them, you put it up there, and then they still don't use it!
And that would be a bit of a crisis for me because I would find that VERY VERY irritating.