Antlr generates broken C# code, missing variable name in declaration - antlr

I have an grammar for a template language.
I created this for Antlr 3.2 and CSharp2 target and have it working.
Now I try to change to antlr 3.4 and CSharp3 target (have tried CSharp2 also) and I get a strange error in the Parser in a synpred function.
Several variable declarations are missing the variable name:
IToken = default(IToken)
Some also have th wrong type
void = default(void);
should be
AstParserRuleReturnScope<CommonTree, IToken> = default(AstParserRuleReturnScope<CommonTree, IToken>);
Have any one seen this before and what could be causing this.
The grammar is the same that was working before.
Unfortunately I cannot share the grammar and I have not had time to create a test grammar that causes the same error.
I can of course fix the errors manually and the code works but it's a bit tiresome to have to go through the code after generation fixing them.

I was able to resolve this problem by using the native .NET version of the ANTLR code generation tool (Antlr3.exe) instead of the Java version. Specifically, antlr-dotnet-tool-3.4.1.9004.7z worked for me, whereas antlr-3.4-complete-no-antlrv2.jar did not.

Related

Parser grammar recognized by ANTLR 4.4 produces lexer syntax errors with ANTLR 4.6 and newer ANTLR versions

I have a scannerless security markings conversion grammar that generates code correctly and runs fine using antlr-4.4-complete.jar. But when I upgrade to antlr4-4.6-complete.jar or newer, code generation fails with "error(50): <.g4 file path>::: syntax error: mismatched character ':' expecting '{'" and other errors.
What changed in ANTLR v4.6 (or possibly v4.5 as I haven't tried that version) that would cause its lexer to err on grammars recognized by v4.4?
Sorry I can't provide a grammar snippit here, but access to the code is restricted.
Turns out newer versions of ANTLR (v4.5 and beyond) will choke on lexing a user-defined rule named channels containing a semantic predicate. ANTLR v4.4 was perfectly happy to lex, parse and generate valid Java code for same. I changed my rule name to channelz, and the grammar now produces code with all ANTLR versions through the 4.9.3 snapshot. Unfortunately, the parser code generated by ANTLR v4.7 and beyond contains numerous other errors which are still to be addressed.
You can view the changes by opening the page https://github.com/antlr/antlr4/releases/tag/VERSION, where VERSION is the version number you're interested in.
So for 4.5 that'd be: https://github.com/antlr/antlr4/releases/tag/4.5

Conditional Compliation Constant VB

Error BC31030 Conditional compilation constant '; ^^ ^^ EXCLUDE_CODEGEN' is not valid: Identifier expected. GpsHost C:\Projects\GpsTrackSolution\GpsHost\vbc 1 N/A
I am getting the above error when I try and build a VB.NET win forms app. I refactored it a little, updated to framework 4.7.2 and now I am getting this.
There is NO reference in ANY vbproj for that string of characters, either partial or full. I've done a find in file contents across the entire solution and cannot find that anywhere. Almost at my wit's end as to what could be doing this.
This was unrelated to VB, it was actually due to Orleans code generation trying to insert constants. Orleans isn't really designed to work with VB, so I switched to runtime codegen, instead of build time, and it worked.

VBA Access Error displayed but nothing in the code

It's my first time using VBA and Access even if I'm coming from Angular and Swift, I'm completely lost.
I'm modifying an existing project and I have created a text label and used the expression generator, then the application crashed. I obviously think that there is a problem in the "expression" that I generated.
The problem is now that I cannot access to the Form where I was working and I get this message :
I have tried to go to the code but I haven't found my problematic expression. Do access store somewhere else the code generated, especially for the expressions generated? How can I find again my problematic expression?
In the code I found, I didn't find any object declaration, for example, as a TextBox...I tried to compile all code, since this is a syntax error, it should be easier to find and solve but it didn't work at all, the compile and run didn't show me any syntax error, I tried to change some settings to handling error but no success...
So if someone could tell me how to solve this problem. Thanks in advance.

Problems with Code in the Frege REPL

While trying to learn Frege I copied some code from Dierk's Real World Frege to the online REPL an tried to execute it (see also How to execute a compiled code snipped in Frege online repl). The scripts I've tried don't compile :-(
What am I doing wrong?
Here are examples of what does not compile:
println ( 2 *-3 ) -- unlike haskell, this will work!
and the whole ValuesAndVariables.fr code
It is unavoidable that over the course of more than a year, an evolving language (and its libraries) change so that older code will not compile anymore.
It would be nice, if we could see an example, instead of a generalization like "most".
The next best thing would be to have an issue in Dierks project that points to the error(s).
But the very best would be en effort to find out what is wrong. This would also intensify your learning process.
Here are two ressources that could help:
https://github.com/Frege/frege/wiki/New-or-Changed-Features -- the release notes for every release, contains a summary of things that have changed between releases, and especially the reasons why code would not compile anymore and how to correct it.
http://www.frege-lang.org/doc/fregedoc.html -- the library docs. May explain possible errors like import not found, or missing identifiers.
Go, give it a try. And I'm convinced Dierk will be happy to accept pull requests.
Edit: Fixes for announced errors.
The error in:
println ( 2 *-3 )
stems indeed from a syntactical change.
It is, as of recently, demanded that adjacent operators be separated by at least one space.
Hence
println (2 * -3)
However, the error message you got here was:
can't resolve `*-`, did you mean `-` perhaps?
which could have triggered the idea that it tries to interpret *- as a single operator.
The other error in ValuesAndVariables1.fr is indeed a show stopper for a beginner. The background is that we have one pi that has type Double and one that has type Float and potentially many more through type class Floating, so one needs to tell which one to print.
The following will work:
import Prelude.Math -- unless already imported
println Float.pi
println (pi :: Double)
the online REPL at http://try.frege-lang.org is currently based on Frege V3.23.370-g898bc8c . Dierk's code examples are based on V3.21.500-g88270a0 (which can be seen in the gradle build file).
It seems that the Frege developers decided to change the Frege syntax slightly between those versions. THe result is that you will not be able to run these code snippets in the online REPL anymore.

Semantic checking doesn't work in Qt Creator 2.5

I don't get an error for this obviously erroneous code sample. Instead, qt creator mark var as unused variable. Is it possible to fix this strange behavior? I want semantic checking working.
Update:
I've been talking about on the fly semantic checking. Most IDE's analyse code as you type, and highlite errors. Qt Creator seemd to do some code analisis on the fly (because syntax highliting shows differently types, virtual functions and other things), but it doesn't hightlte errors at all.
The code model used by Qt Creator is pretty good but is not based on a complete abstract syntax tree for each compilation unit. Some information about it is provided in this Qt blog post:
http://blog.qt.digia.com/2011/10/19/qt-creator-and-clang/
AFAIK, the current code model allows Qt Creator to do semantic highlighting, refactoring, displaying type hierarchies etc. but does not allow a complete on-the fly check for potential compile errors (like yours). Since the syntax of your code is correct, Qt Creator does not show an error.
Very strange behavior. I tried to compile such code:
#include <iostream>
using namespace std;
int main()
{
UndefinedType val;
cout<<"Test"<<endl;
return 0;
}
On My Qt 4.8.1, 4.8.3 with MinGW on Windows7, in QtCreator 2.5.2, but in every case got error:
main.cpp: In function 'int main()':
main.cpp:7:5: error: 'UndefinedType' was not declared in this scope
main.cpp:7:19: error: expected ';' before 'val'
Please, provide more information about your build environment.