-
Notifications
You must be signed in to change notification settings - Fork 228
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
Parsing recovery #624
Parsing recovery #624
Conversation
Pretty tough to review as-is. Expect to see unit tests of the code in various new classes involved in recovery (not end-to-end, unit tests of the functions themselves). Reviewed 41 of 64 files at r1. projects/pom.xml, line 200 at r1 (raw file):
Drop space? projects/pom.xml, line 200 at r1 (raw file):
We should version the plugin in the top-level module, but only add projects/suppressions.xml, line 7 at r1 (raw file):
Explicitly listing the projects/batfish/pom.xml, line 113 at r1 (raw file):
Add projects/batfish-common-protocol/src/main/java/org/batfish/common/CompositeBatfishException.java, line 58 at r1 (raw file):
Note to self: understand why this is here. Add javadoc? projects/batfish-common-protocol/src/main/java/org/batfish/common/util/CommonUtil.java, line 336 at r1 (raw file):
Any reason not to use Guava projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 1 at r1 (raw file):
I'm not precisely sure of the "mode" in which to review this. Clearly I am missing a lot of ANTLR background. Should I expect implementation comments in this file to give me an overview of the necessary context? Should I expect the reader to be an expert on ANTLR? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 23 at r1 (raw file):
Top-level javadoc would be helpful as to what this class does from the public API context. What types of errors can it recover and how does it do so? Also a (non-javadoc) block comment as to how it does it would be useful for those reading the code. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 29 at r1 (raw file):
Javadoc - what are these parameters for? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 30 at r1 (raw file):
Inferring from the code, it looks like the first two parameters are specific to the strategy and the third is the actual text being parsed? I'd probably separate these into two different classes / functions for clarity and reusability. F = new BatfishErrorStrategy(separatorToken, minimumRequiredSeparatorText);
E = F.forText(text); projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 32 at r1 (raw file):
ImmutableList.copyOf? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 53 at r1 (raw file):
Comment seems wrong -- copy and paste of the one 5 lines up? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 59 at r1 (raw file):
? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 91 at r1 (raw file):
what does this do? Expected pre-post conditions? etc. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 127 at r1 (raw file):
javadoc on all public functions (Without looking elsewhere to see how it's used:) does this need to be public? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishCombinedParser.java, line 73 at r1 (raw file):
? - don't get this. comment? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishGrammarErrorListener.java, line 36 at r1 (raw file):
also delete blank line? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexer.java, line 15 at r1 (raw file):
projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexer.java, line 25 at r1 (raw file):
projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexer.java, line 62 at r1 (raw file):
is this projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexerRecoveryStrategy.java, line 12 at r1 (raw file):
javadoc projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexerRecoveryStrategy.java, line 29 at r1 (raw file):
projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishParserATNSimulator.java, line 8 at r1 (raw file):
Javadoc. What does this do that's different than the default? projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishRecognitionException.java, line 8 at r1 (raw file):
Looks like this adds nothing. Why?
Javadoc? projects/batfish/src/main/antlr4/org/batfish/grammar/cisco/Cisco_bgp.g4, line 858 at r1 (raw file):
we now support all lines here? or? projects/batfish/src/main/antlr4/org/batfish/grammar/flatjuniper/FlatJuniperParser.g4, line 120 at r1 (raw file):
I expected to see more changes to Juniper parsers to go with this change. What am I missing? test_rigs/parsing-errors-tests/recovery-no-verbose.ref, line 13 at r1 (raw file):
"are unlikely to" vs "may not be"? Comments from Reviewable |
Fair complaint. After adding javadocs I will be in a better position to address and add more granular tests. Review status: 41 of 64 files reviewed at latest revision, 27 unresolved discussions. projects/pom.xml, line 200 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Will address. projects/pom.xml, line 200 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Sure OK. Yes. Will address. projects/suppressions.xml, line 7 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
I tried something similar but it didn't work. There is a slight difference at your link, though, so I can try that and get back to you. projects/batfish/pom.xml, line 113 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Makes sense. Will address. projects/batfish-common-protocol/src/main/java/org/batfish/common/CompositeBatfishException.java, line 58 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Actually not sure if I ended using this. But it is still a useful helpful function. I will add javadoc, and that should become clear. projects/batfish-common-protocol/src/main/java/org/batfish/common/util/CommonUtil.java, line 336 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
My version allows you to specify the underlying set implementation. If there is a way to do that with Guava library functions, I'm happy to switch. I will investigate. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 1 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
I'll see what I can come up with in terms of documentation, but I hope not to explain the whole ANTLR recognition process in docs in this file. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 23 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
I'll see what I can do here. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 29 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Will add. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 30 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
The text is used by the strategy to create projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 32 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Why copy it? No one else has a reference to it, so it seems like wasted work. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 53 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
You are correct. Will address. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 59 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Are you asking for a comment? If so I will provide. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 91 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Will document. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 127 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
It is used elsewhere. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishCombinedParser.java, line 73 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
If we are not doing recovery, none of the recovery infrastructure needs to be supplied (it creates overhead). projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishGrammarErrorListener.java, line 36 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
What blank line? I'll take a look in code in case the review system is hiding for me. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexer.java, line 15 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Will do. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexer.java, line 25 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Will do. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexer.java, line 62 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
That's a philosophical question. If you set it, presumably you want it to do something. But since the field is not required to be non-null, I don't suppose there is any specific harm for calling it projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexerRecoveryStrategy.java, line 12 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Will do. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishLexerRecoveryStrategy.java, line 29 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Will address contingent on decision for my earlier comment about Guava set functions. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishParserATNSimulator.java, line 8 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Will add projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishRecognitionException.java, line 8 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
It's just meant to be a general Recognition exception to be caught by the projects/batfish/src/main/antlr4/org/batfish/grammar/cisco/Cisco_bgp.g4, line 858 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
No special handling of unrecognized lines needed, as this whole PR generalizes it for all parsers of this kind. projects/batfish/src/main/antlr4/org/batfish/grammar/flatjuniper/FlatJuniperParser.g4, line 120 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
The intentional blank was supposed to go after the test_rigs/parsing-errors-tests/recovery-no-verbose.ref, line 13 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
After this PR should be "may not be". I wil change. Comments from Reviewable |
Review status: 41 of 64 files reviewed at latest revision, 4 unresolved discussions. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 1 at r1 (raw file):
Class name has ANTRL instead of ANTLR. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 119 at r1 (raw file):
These if statements are opaque to me. Would definitely help to have a block comment outlining the three cases and what we want to do with the parse tree in each case. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 197 at r1 (raw file):
I don't understand why this block in the switch is necessary, since the block after Comments from Reviewable |
Review status: 41 of 64 files reviewed at latest revision, 4 unresolved discussions. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 1 at r1 (raw file): Previously, corinaminer (Corina Miner) wrote…
Good catch. Will fix. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 119 at r1 (raw file): Previously, corinaminer (Corina Miner) wrote…
Will document and add tests for each case. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTRLErrorStrategy.java, line 197 at r1 (raw file): Previously, corinaminer (Corina Miner) wrote…
Until the very last change, these had different content. But now that they are the same, they can be merged. Good catch. Comments from Reviewable |
Review status: 41 of 64 files reviewed at latest revision, 3 unresolved discussions. projects/batfish/pom.xml, line 113 at r1 (raw file): Previously, arifogel (Ari Fogel) wrote…
So I tried it. While I think it does bind it to the Comments from Reviewable |
Review status: 41 of 64 files reviewed at latest revision, 3 unresolved discussions. projects/batfish-common-protocol/src/main/java/org/batfish/common/util/CommonUtil.java, line 336 at r1 (raw file): Previously, arifogel (Ari Fogel) wrote…
I think there is a case for at least removing references to all these utility functions. I will defer to a future PR, and remove references and modifications to utility functions in this PR. Comments from Reviewable |
- compile test grammars - update eclipse metadata to use generated test grammars - add suppressions to checkstyle to force it not to analyze generated test grammars
- enabled when disableUnrecognized is false (this is DEFAULT) - requires specification of separator token, minimal string always present in separator token (e.g. NEWLINE, "\n")
ec35a4e
to
114aa79
Compare
projects/pom.xml, line 200 at r1 (raw file): Previously, arifogel (Ari Fogel) wrote…
Did not address. Comments from Reviewable |
Review status: 24 of 63 files reviewed at latest revision, 2 unresolved discussions. projects/pom.xml, line 200 at r1 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Whoops got it now. Comments from Reviewable |
Reviewed 5 of 71 files at r1, 42 of 48 files at r2, 2 of 2 files at r3. projects/batfish/pom.xml, line 113 at r1 (raw file): Previously, arifogel (Ari Fogel) wrote…
Yep, that's expected. There's a difference between not running tests ( projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTLRErrorStrategy.java, line 28 at r3 (raw file):
typo: projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTLRErrorStrategy.java, line 36 at r3 (raw file):
these should be typo in projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTLRErrorStrategy.java, line 99 at r3 (raw file):
I'm having a hard time connecting this function's doc to its name. Is the intent to turn something like
into
|
Reviewed 1 of 1 files at r4. Comments from Reviewable |
Review status: 59 of 63 files reviewed at latest revision, 13 unresolved discussions. projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTLRErrorStrategy.java, line 28 at r3 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Fixed projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTLRErrorStrategy.java, line 36 at r3 (raw file): Previously, dhalperi (Dan Halperin) wrote…
Fixed projects/batfish-common-protocol/src/main/java/org/batfish/grammar/BatfishANTLRErrorStrategy.java, line 99 at r3 (raw file): Previously, dhalperi (Dan Halperin) wrote…
|
Reviewed 2 of 49 files at r2, 1 of 1 files at r4, 5 of 5 files at r5. Comments from Reviewable |
At this point only unresolved comment is your own as to whether you're going to add a test to catch the potential NPE issue with recovery at the top level. Review status: all files reviewed at latest revision, 1 unresolved discussion. Comments from Reviewable |
-disableunrecognized
flag, yielding legacy-ish behavior-urf false
flag, which has no effect when-disableunrecognized
is set.This change is