listener and visitor ANTLRworks 2 - antlrworks

I dont know how to make visitor and listener to work via ANTLRworks 2, I managed to create them, but do I need to write code via cmd or can I use them directly through ANTLRworks 2?

ANTLRWorks 2 is currently designed as an IDE for ANTLR grammars themselves. The generated visitors and listeners, along with any implementation(s) of them, would be developed as part of a separate project in the target language (currently Java and C# are supported).
If you have ANTLRWorks 2 installed as a plugin for NetBeans (as opposed to the alone application), you can work with ANTLR 4 grammars directly within the context of a Java project, which may better fit your needs.

Related

Built-in code analysers vs NuGet packages

Having just switched to VS2019 I’m exploring whether to use code analysis. In the project properties, “code analysis” tab, there are numerous built-in Microsoft rule sets, and I can see the editor squiggles when my code violates one of these rules. I can customise these rule sets and “save as” to create my own.
I have also seen code analyser NuGet packages such as “Roslynator” and “StyleCop.Analyzers”. What’s the difference between these and the built-in MS rules? Is it really just down to more comprehensive sets of rules/more choice?
If I wanted to stick with the built-in MS rules, are there any limitations? E.g. will they still get run and be reported on during a TFS/Azure DevOps build?
What's the difference between legacy FxCop and FxCop analyzers?
Legacy FxCop runs post-build analysis on a compiled assembly. It runs as a separate executable called FxCopCmd.exe. FxCopCmd.exe loads the compiled assembly, runs code analysis, and then reports the results (or diagnostics).
FxCop analyzers are based on the .NET Compiler Platform ("Roslyn"). You install them as a NuGet package that's referenced by the project or solution. FxCop analyzers run source-code based analysis during compiler execution. FxCop analyzers are hosted within the compiler process, either csc.exe or vbc.exe, and run analysis when the project is built. Analyzer results are reported along with compiler results.
Note
You can also install FxCop analyzers as a Visual Studio extension. In this case, the analyzers execute as you type in the code editor, but they don't execute at build time. If you want to run FxCop analyzers as part of continuous integration (CI), install them as a NuGet package instead.
https://learn.microsoft.com/en-us/visualstudio/code-quality/fxcop-analyzers-faq?view=vs-2019
So, the built-in legacy FxCop and NuGet analyzers only run at build time while the extension analyzers can run at the same time the JIT compiler does as you type. Also, you have to specifically say to run legacy code analysis on build, whereas the NuGet analyzers will run on build just because they are installed. And analyzers installed as NuGet or extensions won't run when you go to the menu option "Run Code Analysis".
At least, that's what I get out of that page.
There's a link near the bottom of that page that takes you to what code analysis rules have moved over to the new analyzers, including rules that are now deprecated.
https://learn.microsoft.com/en-us/visualstudio/code-quality/fxcop-rule-port-status?view=vs-2019
The different analyzers attempt to cover different coding styles and things Microsoft didn't cover when they built FxCop. With the little research I just did on this, there's a whole rabbit hole to follow, Alice, that would take more time than I have right now to devote to it. And it seems to be filled with lots of arcane knowledge and OCD style code nitpicks that make Wonderland seem normal. But that's just my opinion.
There's lots of personal and professional opinion about various rules in these and basic Microsoft rules, so there's plenty of room to use what you want and disable what you don't. For a beginner, I'd suggest turning on only a few rules at a time. That way you aren't inundated with more warnings and errors than lines of code you might have. Ok, so that might be a bit of an exaggeration, but there's so many rules that really are nitpicks, especially on legacy code, that they aren't really worth it to have enabled, since you likely won't have time to fix it all. You will also want to do basic research and use "common sense" when you decide what to enable. ("Do I really need to worry about variable capitalization coding style consistency on an app that's been ported into 4 different languages over 15+ years and has 10k files?") This is both personal and professional opinion here, so follow it or not.
And don't forget the rules that contradict each other. Those are fun to deal with.......

Autocomplete punctuation using grammar

I'm working on a tool that is able to autocomplete the necessary literals defined in a grammar. For example: in C# if a programmer enters: for with a space after it, then it's entirely possible to parse the code, determine that the programmer has started a for statement and autocomplete the necessary punctuation: ( ; ; ).
The more I think about the problem, the more I think there must already be a solution for it, because it's such a common use case, but I can't find anything.
Is there a tool that can do this using a given grammar?
If you don't mind using ANTLR v3 instead of v4 you can use Xtext in order to generate an editor that features auto-complete and error-highlighting. This will happen in form of a plugin for eclipse and apparently also for IntelliJ IDEA.
If you want to use a different IDE or simply want to make use of ANTLR v4's powerfull features you could still have a look at the Xtext Sources as they have to do what you are searching for in order to provide the above mentioned features properly...
This package looks very promising at first glance... You might find the respective code in there.
Be aware though that Xtext is mainly written with Xtend so you either have to do so as well or you have to rewrite it a bit

Single Xtext Language Server for two extensions

I have two Eclipse plugin Xtext(2.11) projects.(Called Project A and B) Project B grammar file is dependent on Project A grammar file. Project A's grammar file extension is a and Project B is b.
I am able to generate the language server for Project B. I want to generate the single language server for both projects.(Currently, in project B it includes project A.)
Depend on extension type it needs invoke respective Xtext grammar functionality.
In above scenario, I have below questions:
Does Xtext can handle this kind of scenario seamlessly? Do I need to generate the language server for Project A also and need to add in Project B? What is the best way to do this?
What kind of Xtext changes required?
What kind of changes required at client side also? like in Visual code/ Che?
Xtext LS can be used with multiple Xtext languages. It uses java service loading to look up language setups: https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext/src/org/eclipse/xtext/resource/ResourceServiceProviderServiceLoader.xtend#L25. In ide project of your language you should be able to find META-INF/services/org.ecalipse.xtext.ISetup file that says java what implementations should be used for ISetup interface.
Having jars for ide projects on the classpath should be enough. No changes are required.
VS code and Che does not care about implementation details of Xtext LS, but both languages should be registered for them

What do I need to know to create a server script interpreter? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am interested in model an develop a new object pascal interpreter for web site scripting.
We have PHP, Pearl, Java, Javabeans... But not Pascal as a option for web developers.
Since Delphi only works in Windows based servers...
I would like to do things like:
<input name="ClientName" value="<?pas write(ClintObj.Name); ?>">
or
<input name="ClientName" value="<?pas #ClintObj.GetName; ?>">
not just as a template, but just like PHP, something I could use with a MVC framework, or even create one:
<?pas
System.Writeln('<html><head>...');
?>
Where should I start?
Or is it already done and I fail to find it? (for linux)
Two existing products:
Oxygene
You can check out Oxygene, formerly known as Delphi Prism, formerly known as RemObjects Chrome.
They have found a way to compile a Pascal style language to Java. Not convert Pascal code to Java code, but actually compile it to the bytecode that runs in the Java runtime engine. Apart from that, they can also compile to the .NET runtime.
I don't know if you can use Oxygene for your purpose, but at least their product may give you some inspiration and some insight of the possibilities and difficulties of building something like that yourself.
PascalScript
Maybe you can use PascalScript, also by RemObjects. It is a script interpreter. So you can embed it in a server application. For instance, if you create an ISAPI application that embeds PascalScript, all you need to do is expose some 'write' method to the script to allow it to write output. All the application needs to do is output that output to ISS, and your basis server side Pascal scripting is done. After that, you can expose more convenience functions to the script to make it more useful.
PascalScript can be used in Delphi as well as FreePascal, so maybe you can make it work in Linux as well.
You are mixing embedding a scripting version of a language in templates with general web development in that language.
While Pascal isn't really used much as templating language, doing webdevelopment is perfectly possible, e.g. with http://brookframework.org/ and several Delphi component suites.
Some of the Delphi options also support Apache, and have supported Kylix in the past. I used webhub from http://www.href.com for a while.
Writing such a interpreter is not a piece of cake:
your script files would need have be parsed, the contained Pascal code compiled / checked for syntax errors
as this compilation phase would be a CPU consuming task, the resulting object code would have to be cached for better performance
maybe you do not want to use / install the FPC or Delphi compiler on the server, then your language will be limited to what your compiler can suppport
the generated code needs access to "shared data" if different script parts need to interchange information or access global data, like a database
Also a critical functional requirement unless your application is stateless:
different users of the web site need their separate data (state), so your code needs to be session-aware (stateful)
Oh, one minor issue:
the application should not expose any vulnerabilites for malicious clients, see OWASP
So I guess this will be a long weekend ;-)
Don't forget about the free DelphiWebScript (DWS).
Though started as a Delphi-like WebScript language, it is a general purpose Delphi like language that can be used as a script, and also has a JIT compiler (though without it, the performance already is very good).
The main project compiles in Delphi (so it is Windows-only) but there is a FreePascal DelphiWebScript initiative to make it run on Linux too.
There are multiple demo web server projects to choose from so you can host your own DWS scripts, for instance the WebServer project which is based on http.sys version 2, then there are Indy based and Synopse based ones.
The development tool Smart Mobile Studio is using DWS to compile the forms and Pascal based source code into HTML5 and JavaScript then serve it from a web server to run in any HTML5/JavaScript compatible browser (including the mobile ones).
So there is a lot of power in DWS, demos and the eco system around it (:

Running Scala code on iOS [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Any way to use some Scala for iOS coding?
Would it be possible to use the Scala.NET implementation, and then MonoTouch to run Scala code on an iOS device?
I have not been able to find a page with binaries of Scala.NET that I can test, so the following are just general guidelines as to what you can do with MonoTouch and .NET languages.
MonoTouch can run any ECMA CIL that you feed to it. When you consider using a new language with Monotouch, there are two components that come into play:
Tooling for the IDE
Runtime for the language
The tooling for the IDE is the part responsible for starting the builds, providing intellisense and if you use Interface Builder, it creates a set of helper methods and properties to access the various outlets in your UI. As of today, we have only done the full implementation for C#. What this means for an arbitrary language is that you wont get the full integrated experience until someone does the work to integrate other languages.
This is not as bad as it sound, it just means that you need to give up on using XIB files from your language and you probably wont get syntax highlighting and intellisense. But if you are porting code from another language, you probably dont need it. This also means that you would probably have to build your assembly independently and just reference that from your C# project.
So you compile with FoobarCompiler your code into a .dll and then reference in your main C# project.
The language runtime component only matters for languages that generate calls into a set of supporting routines at runtime and those routines are not part of the base class libraries (BCL). C# makes a few of those calls, but they are part of the BCL.
If your compiler generates calls to a supporting runtime that is not part of the BCL, you need to rebuild your compiler runtime using the Mono Mobile Profile. This is required since most runtimes target a desktop edition of the BCL. There are many other API profiles available, like Silverlight, Mono Mobile, Compact Framework and Micro Framework.
Once you have your runtime compiled with our core assemblies, then you are done
If you had read the MonoTouch FAQ, you would have noticed that it currently supports only C# and no other CLR languages.
Binaries for the Scala.NET library and the compiler can be obtained via SVN, in the bin folder of the preview:
svn co http://lampsvn.epfl.ch/svn-repos/scala/scala-experimental/trunk/bootstrap
Bootstrapping has been an important step, and ongoing work will add support for missing features (CLR generics, etc). All that will be done.
For now we're testing Scala.NET on Microsoft implementations only, but we would like our compiler to be useful for as many profiles and runtime implementations as possible.
A survivor's report on using Scala.NET on XNA at http://www.srtsolutions.com/tag/scala
Miguel Garcia
http://lamp.epfl.ch/~magarcia/ScalaNET/

Resources