How to extend Doxygen to support Lua? Or: how to write Doxygen filters? - lua

I am working on a code base that is one half Lua and one half C++. We use Doxygen to document our C++ code.
Now, we want to use Doxygen for the Lua part, too. But Doxygen lacks support for Lua.
There is a project that kind of adds Lua support for Doxygen. It is written in Perl and I understand what it does. It implements a filter that converts a Lua source file into something that Doxygen can parse. However, Doxygen does not seem to recognize all the functions etc.
So my question really is: What is the format Doxygen expects from the filter?

The strict answer is that your filter should produce grammatically valid output in a language doxygen supports (you can use EXTENSION_MAPPING to map the file extension for your language to a supported language).
Since doxygen's parser is rather loose (it is a lexical scanner, not really a parser), it might work as well if you do not 100% follow the grammar rules of the language, but it will be a trail and error process to find out which deviations are allowed and might break if you upgrade to a future version of doxygen.

Related

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

Can Coco/R turn a parsed file into bytecode?

I want to write a simple compiler for educational purposes in Delphi. I have read about Coco/R and found this implementation for Delphi: http://code.google.com/p/dcocor/ . From what I have read, this is a parser for the Delphi 2009 syntax.
What would I have to do to turn the parsed file into a bytecode? Can Coco/R do this?
I know about scripting languages like FastScript or DWS, but I'd like to try and write my own for my own purposes.
Please give me some advice or clarify things a little.
What would I have to do to turn the parsed file into a bytecode?
First, decide what kind of bytecode would you like to have: JVM? LLVM? MSIL? Inventing your own?
Can Coco/R do this?
Coco/R is a parser generator framework, it only generates lexer-parser for a language you define and feed to the generator. Steps after that is your responsibility. Though there might be projects out there that can help generating ast/target code (but I haven't found any for Coco/R ).

Other scriptable editors?

I'm just wondering what editors you know which are "scriptable". E.g take an Emacs, one can really say you can do everything from within the editor: writing,reading, programming. All with the "scripting language" Emacs-Lisp. What other editors you know are out there as scriptable?
Do you know let's say an editor scriptable in Perl, Ruby or any other more C-like language?
On the Windows platform, the Zeus editor is scriptable in the Lua, Python, Java Script, VB Script and TCL languages.
Yi is the Haskell equivalent to Emacs. It is specifically designed along the same lines as Emacs: everything is scriptable in Haskell, the editor itself is more or less just a Haskell script, and there is only a very small, very generic, non-scriptable core. In contrast to most Emacs implementations, however, which use a different language for the core than for the scripts, Yi's core is also implemented in Haskell.
Vim has Vimscript for writing plugins and extending functionality.
Redcar is a text editor written in (mostly) Ruby, which is fully scriptable in Ruby. It is not nearly as flexible as Emacs, but more on the level of TextMate.
UltraEdit and UEStudio have the feature to record many of its commands during a manual execution to a macro and run this macro again later. The macro can be also edited to add a loop or simple conditions.
And UltraEdit / UEStudio support also scripts. Those scripts are parsed with the JavaScript core engine. Therefore everything supported by JavaScript core like variables, arrays, string manipulations, calculations of integers or floats, nested loops, etc. can be also used in those scripts plus lots of commands of UltraEdit / UEStudio itself.
UltraEdit is available for Windows, Linux and Mac and as portable application for Windows.

llvm-clang: incremental or online parser?

Is there anyway to use the llvm-clang parser in an incremental/online manner?
Say I'm writing an editor and I want to be able to parse the C++ code I have in front of me.
I don't want to write my own hacked up parser.
I'd like to use something full featured, like llvm-clang.
Is there an easy way to hijack the llvm-clang parser? (And is it fast enough to run it continuously in the background)?
Thanks!
I don't think clang can incrementally parse C++ files, but it's one of this project goals: http://clang.llvm.org/features.html
I've written something similar for my final year project. It wasn't C++ editor, but a Visual Studio plugin, which main task was improving C++ intellisense (like Visual Assist X).
When I was writing this project I've been also thinking about C++ incremental parser, but I haven't found any suitable solution. To solve the C++ intellisense problem I used normal C++ parser from GCC. However it was to slow, to parse file after each code completion request (ctrl+space), just try including boost::spirit. To make this project work properly I parsed files in the background and after each code completion request I compared current file with it's previous version (via diff) to detect changes made from last parsing. Having those changes I updated syntax tree, mostly by adding or removing variables.
Except incremental parsing, there is also another problem with projects like this. Mostly you'll be parsing C++ code which is being edited so it's invalid code. Given the complex C++ grammar, sometimes parser won't be able to recover from syntax errors, so it won't detect correctly some symbols in code.
Another issue are C++ parsers / compilers differences. Let's say I'm using working in Visual Studio and I have used some VC++ compiler specific contruction in my code. Clang parser won't be able to parse it correctly.
For writing something similair to IntelliSense, I would advise you to write your own parser using the LALR parsing algorithm. Since you can save its state in each line so you don't have to reparse the whole file when a file has been editted, which is very fast!
Note that C++ can't be fully expressed in BNF, but I think you could get pretty far with some adjustments. It's ofcourse a lot more work than using Clang's frontend, but you could still use Clang for analysing header files in coöperation with you own written parser.

Parser generator for Delphi?

Can anyone recommend a parser generator that will produce win32 Delphi code? What I'm trying to do is create a simple Domain-Specific Language.
How complex is your DSL?
I created a parser (in Delphi) for the new Delphi RIDL language to support some in-house COM generation tools we use.
My approach was to use ANTLR to play around with the syntax rules until I had something that parsed the various test files I had. I then hand-coded a recursive descent parser (based on the Java generated by ANTLR). I was also using the Castalia Delphi Parser in the project, so I based my lexical analyser on that.
Recursive descent parsers are actually really simple (but tedious :-) ) to write manually.
The Delphi versions of Coco/R are quite ok:
http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
most notably Pat Terry's one:
http://www.scifac.ru.ac.za/coco/
Try this:
http://www.grendelproject.nl/dyacclex/
I have not tried this at all and I just noticed the information while I was reading through the documentation, but FastScript, in their documentation which you can get here, says that you can use their parser to create your own language which you specify in an XML file. This might give you something you can use.
I found Antlr For Delphi 3.1.1.
SharpPlus Antlr For Delphi Target
3.1.1, a language tool that provides a framework for constructing
recognizers, interpreters, compilers
with Delphi!
It is a commercial product. I have no idea what it is like.

Resources