Closed spironato closed 3 years ago
AFAIK, the Reference
class is package private and was never exposed externally: https://dart-lang.github.io/linter/lints/implementation_imports.html
That said, it has moved to petitparser/src/definition/reference.dart
.
Thanks for the message @renggli. Yep checked in 2.4.0 and just realised that was not exposed.
thanks a lot for the suggestion! i can proceed now.
Are you sure you have the correct import statement? I can import it, I get an appropriate linter warning that I should not import package private files, but it works for me.
Yes, I would prefer not to expose it externally. It is an internal implementation detail. At some point, we might be able to get rid of it with code generation.
I do not understand why you needed to create your own Reference
implementation. Maybe you can elaborate a bit and post a minimal example?
Sorry i cross checked and i had a wrong import now is working.
In our implementation we use RefVersion
instead of Ref
and with RefVersion
we add extra parameters versionFrom and depreactedVersion; otherwise RefVersion
behave as the Ref
.
When we parse a source code we know the version that the source code is assigned. If the source code has some unexpected Statement for that version we throw and exception of invalid code.
Thanks again for the prompt answer @renggli and the support!
Anyway thanks to your input @renggli this make clear a missing lint rule in our side and we need to change our implementation we can't use private implementation.
The built in Reference
parser can be parametrized:
Parser start() => ref(other, Version.v1);
Parser other(Version version) {
switch (version) {
case v1:
return ...;
case v2:
return ...;
}
}
Not sure if this is what you are trying to do, or something else?
Thanks for the suggestion, i will think about it in the next weeks since at this point we must get rid of the use of Reference
. We need before upgrade to latest version.
We are building a Domain-Specific Language(let call for simplicity xDSL) for our product. We needed to handle different xDSL versions so in a new xDSL version can be added new grammar or existing grammar can be deprecated. We need to be able to parse different versions of our xDSL and provide errors if f.ex new grammar has been added parsing a source code meant for a older version. We implemented this with dart-petitparser 2.4.0. Not sure if is the best approach but we solve the xDSL versioning extending GrammarDefinition adding a new RefVersion on top of the existing Ref. RefVersion return as the Ref a Reference. Now after updating to the version 3.1.0 (we are preparing to move to the null safety version) the Reference class is not accessible anymore as was with 2.4.0:
import 'package:petitparser/src/core/definition/reference.dart';
Any advice hint best approach how this could be solved with the 3.1.0?
Thanks in advance for the help!