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
{{ message }}
Repository navigation
'native' import statements in @parser:header are dropped #3868
@parser:header {
// import X from './X';
import X from './X';
class Y extends X {}
}
a: 'a' EOF;
The generated code will look as follows:
.../...
// import X from './X';
class Y extends X {}
class GParser extends Parser { .../... }
notice that the native statement "import X from './X';" has been dropped.
it doesn't happen with preceding comment or the succeeding declaration.
I suspect it is because the tool sees the 'import...' line as an antlr import statement...
The issue title is misleading.
It happened in TypeScript testing only, as a side effect of having the @parser::header text inserted in not only the parser but also the listener and the visitor, which makes no sense.
As a result, because some of the inserted code would not resolve in the listener/visitor), tsc (the Typescript compiler) would mess up silently and drop the imports in the transpired js files (not in the ts files). @parrt this is fixed by removing the named action "header" after generating the parser, which needs your blessing.
I'm afraid I can't bless such a fix. It's unclear why CodeGenPipilne removes name action and method removeParserHeader in Grammar looks irrelevant. Is it possible just not to add header named action?
@Kvantt, thanks for your comments, some of them are useful, but at mentioned originally, this is not a time for review yet. Blessing is only required from Ter.
Le 7 sept. 2022 à 13:40, Ivan Kochurkin ***@***.***> a écrit :
I'm afraid I can't bless such a fix. It's unclear why CodeGenPipilne removes name action and method removeParserHeader in Grammar looks irrelevant. Is it possible just not to add header named action?
—
Reply to this email directly, view it on GitHub <#3868 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAZNQJCGTC6LAOTTDOZRNPTV5B5MDANCNFSM6AAAAAAQFXAEGI>.
You are receiving this because you authored the thread.
Activity
all tests pass except 7 caused by antlr#3868
ericvergnaud commentedon Sep 6, 2022
mmm... this only happens during testing, so I should be able to fix it without side effects
all tests pass except 7 caused by antlr#3868
fix antlr#3868
ericvergnaud commentedon Sep 7, 2022
The issue title is misleading.
It happened in TypeScript testing only, as a side effect of having the @parser::header text inserted in not only the parser but also the listener and the visitor, which makes no sense.
As a result, because some of the inserted code would not resolve in the listener/visitor), tsc (the Typescript compiler) would mess up silently and drop the imports in the transpired js files (not in the ts files).
@parrt this is fixed by removing the named action "header" after generating the parser, which needs your blessing.
KvanTTT commentedon Sep 7, 2022
I'm afraid I can't bless such a fix. It's unclear why
CodeGenPipilneremoves name action and methodremoveParserHeaderinGrammarlooks irrelevant. Is it possible just not to addheadernamed action?ericvergnaud commentedon Sep 7, 2022
ericvergnaud commentedon Sep 8, 2022
Closed in favor of #3877
all tests pass except 7 caused by antlr#3868
all tests pass except 7 caused by antlr#3868
fix antlr#3868
Typescript target (#4027)