You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It has all been relatively painless, except in the PklLexer.g4 java grammar there is the following @members entry:
class StringInterpolationScope {
int parenLevel = 0;
int poundLength = 0;
}
java.util.Deque<StringInterpolationScope> interpolationScopes = new java.util.ArrayDeque<>();
StringInterpolationScope interpolationScope;
{ pushInterpolationScope(); }
void pushInterpolationScope() {
interpolationScope = new StringInterpolationScope();
interpolationScopes.push(interpolationScope);
}
Swift doesn't allow (as far as I know) something like:
{ pushInterpolationScope(); }
And it won't allow the generated init(_ input: CharInputStream) initializer because it hasn't initialised "interpolationScope" by the time super.init() is called. So to get it to work I have to manually move the two code lines in pushInterpolationScope down to the init initializer.
Once I do that everything works, well. But of course now I have a manual intervention in my lexer generation. In all likelihood I won't be running the generation that often so I can live with the work around.
But I was wondering if there was a way to override what the Target generator is producing for init(_ input: CharInputStream)?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've converted the grammars used by the PKL Lang project (https://github.com/apple/pkl/blob/0.26.1/pkl-core/src/main/antlr/PklLexer.g4) from Java to Swift targets.
It has all been relatively painless, except in the PklLexer.g4 java grammar there is the following @members entry:
Swift doesn't allow (as far as I know) something like:
{ pushInterpolationScope(); }
And it won't allow the generated
init(_ input: CharInputStream)
initializer because it hasn't initialised "interpolationScope" by the time super.init() is called. So to get it to work I have to manually move the two code lines inpushInterpolationScope
down to the init initializer.Once I do that everything works, well. But of course now I have a manual intervention in my lexer generation. In all likelihood I won't be running the generation that often so I can live with the work around.
But I was wondering if there was a way to override what the Target generator is producing for
init(_ input: CharInputStream)
?Beta Was this translation helpful? Give feedback.
All reactions