-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Issue 2693 #3057
Issue 2693 #3057
Conversation
Tightening up the grammar rules. Still Java9.
Update ProfileDescriptor to now parse and output profile. The grammar is asm8080 from grammars-v4, tightened up. The input is the example provided there, truncated to included fewer lines as that causes a null-ptr crash with the older runtime. I verified by modifying the .csproj in /tmp.
Hi, thanks for this. I think we will stick to junit for grammar tests, because the ability to ensure the exact same test (grammar, generation, input output and error) runs in all target languages is paramount, and very convenient to action from IntelliJ. This only applies to tests that involve code generation. The runtime target toolkit tests do not need to sit with the Java code base, and you are welcome to move the profiler test out, and into the C# code base. Other runtime targets already do this (Swift and Python I think). |
I don't understand how the profile interpreter does not depend on the code generation of the tool. The profile test requires the Parser, Lexer data structures generated by the Antlr Java Tool for a .g4 example that did crash prior to the fix (asm8080.g4 or Java9.g4). I can't magically create this source code out of thin air. Please explain. What you are suggesting, I guess, is to reorganize the code in antlr4/runtime/CSharp/. The proposal is to create two new directories: antlr4/runtime/CSharp/src/ (to contains the current source code in antlr4/runtime/CSharp/) and antlr4/runtime/CSharp/test/ sub-directory to contain sub-projects (.csproj) for tests that "do not depend on code generation". I.e.,
In other words, how every other runtime is currently organized. Why wasn't CSharp/ set up this way to begin with?? |
The grammar tests serve a very different purpose from the profiler test:
Since I did not write the original code, I can't comment on why the CSharp structure is different from other targets. If you are willing to invest the effort, I am supportive of aligning it. |
Also suggest you rebase against latest master, such that circle-ci tests can be executed. |
Thanks Eric. That seems to be a reasonable demarcation between tests that belong in runtime-testsuite/ vs runtime/. I will reorganize the CSharp/ files as per my description, and move the profile test there. Obviously, that will require any references to Antlr4.csproj to also be modified ( The code for Dart and Swift should be reorganized similarly. After all, I modeled my changes to runtime-testsuite/ after these two runtimes. Note, I won't change the Dart or Swift code because I can't get "mvn install" to work from runtime-testsuite/. I don't know what build environment is required. Even after I will be creating an entirely new branch and PR for the changes because you merged it with "master", and I have other changes. (On second thought, I'll just merge from master and continue the changes.) I don't understand why isn't Circle-CI working.
I guess I have to sign up with Circleci.com and try a "Hello World" before submitting the new PR for Antlr4. |
circle-ci isn't working because your branch was created before it was enabled |
--Removing all the test code for Profile = true. See comment here: #3057 (comment)
…other runtimes, a source directory (now antlr4/runtime/CSharp/src), and a test directory (antlr4/runtime/CSharp). In the test area, I added a test for profiling in issue-2593. This test requires the Antlr tool and Antlr C# tool to be build. The path is assumed in a relative path to the test, ../../../../tool/target/antlr4-*-SNAPSHOT-complete.jar, with globbing performed. The test simply checks the return result, output not important. There are no changes to the runtime C# source files other than placing them under src/. Several other build files were changed to reflect the new location of the Antlr C# runtime. I updated the instructions for users on how to build the runtime, including information on checking the environment--now explicitly specified here so people know what to install!
This is a fix for #2693. This is a new PR, replacing #2936 (coincidence that it's similarly named to the issue).
This change adds in code that I ported from the Java runtime for profiling. The problem was that sometimes setting
parser.Profile = true;
before a parse would cause a null-pointer exception in the C# runtime. This change alters a number of the method signatures in the runtime. Note that in the Java runtime the constructor LookaheadEventInfo() contains parameterpredictedAlt
that is undocumented in the comments. I added a stub to avoid complaints from Docfx.The test for this change was not easy to add because the parser constructed from template did not have code to set
parser.Profile = true;
. To minimize changes, I added method BaseCSharpTest.execParser() to take an additional prarmeter, and subclassed BaseProfileCSharpTest from BaseCSharpTest to generate code for profiling. The code is generated to "BaseProfile....." in /tmp. I noticed the indentation off in the template, so I fixed that. There is now a new test "descriptor", ProfileDescriptors.java, which contains code to try two different cases for profiling, currently only for C#. The "FatProfile" is an example that I experimentally determined by going through all the grammars and examples in antlr/grammars-v4, choosing asm/asm8080 because it was small (the Java9 grammar is large and also requires a split grammar to make it portable to C#). I created a descriptor with the inlined asm8080 grammar, tightened up considerably--people love too much spacing, a separate line per alt, yuck! The output from the driver program is experimentally determined. The runtime no longer crashes, and the output looks fine.I would like, however, to note that the runtime test suite code tries to do too much under Java. Testing should be under Bash, and a separate program constructed to generate the driver programs from templates. This can then be used outside of Java, outside of the antlr4/ repo. I've already started writing said program, Antlr4BuildTasks/dotnet-antlr, which is platform-independent, and outputs drivers for Java and C# (both Antlr4.Runtime.Standard and Harwell's Antlr4, any runtime version).