Since LLVM/cLang is especially well designed.
This seems like a great opportunity to augment the C/C++ macro/preprocessor system.
Does anyone know of
additional macro/preprocessor abilities added by Clang or
side projects to make the macro system more powerful (like turing complete)
Note: I am asking about macros. Not C++ templates. I want this thread to be macro/preprocessor specific.
LLVM/clang is especially well designed. The clang preprocessor is especially nice: It keeps track of macro expansions, etc. I suspect the reason that it has not been extended is that 1. An extended preprocessor is non-standard, and 2. No one has done it. Feel free to extend it. As they say on the LLVM IRC: "Patches are welcome", although I suspect that very non-standard preprocessor extensions may not be.
For an example of a preprocessor taken to the ultimate extreme, take a look at PL/1. ;-)
Why don't you just use M4 as a pre-preprocessor?
Related
I want to generate tags file for system verilog.
I found this really helpful link, and I was able to generate UVM tags file.
But my question is about SV. Since there is no separate sv files, the language is build into the compiler itself, how do i go about creating tags file for that?
Thanks in advance.
What was wrong with the link you provided? here are some others
https://verificationacademy.com/forums/systemverilog/ctags-systemverilog
http://hackdut.blogspot.com/2015/03/ctags-and-vim-to-work-with-systemverilog.html
For improved support of SystemVerilog you can try Universal Ctags, where the Verilog parser was improved to also support SystemVerilog.
I also suggest that you use this Verilog/SystemVerilog Vim Plugin that also includes some basic omni-completion.
Disclaimer: most of this is my work. Your mileage may vary, but feel free to report issues and ask for improvements.
I have found an older question about a similar topic, but I am still wondering how to do this: I'd like to try to use clang for code navigation, instead of gtags / GNU global or similar tools. I am already using autocomplete-clang for Emacs, which works really well. But it does only completion. Now I would like to ask clang: "Where is the definition and / or declaration of the symbol in xyz.cc:42:23". Is this possible with either c-index-test or clang?
Clang definitely knows where is the definition of the symbol. I switched from clang-autocomplete to clang-autocomplete-async which uses clang-complete tool built on top of clang instead of stock clang. Although this tool does not support navigation yet, I believe it would be possible to implement it quite easily.
Is it possible to call a Common Lisp function in iOS?
If so, is it possible create it in a dynamic library?
It depends on what you mean by calling a CL function, but most likely ECL will be your shortest path. Start here, as there is a patch for ECL to better accommodate iOS: http://funcall.posterous.com/tag/iphone
ECL generates C code, so you should be in safe territory with Apple's shifting policies.
Have you tried MOCL?
According to the website "mocl is a highly optimizing CL implementation, delivering tight native code via LLVM/Clang".
Maybe you can create a dynamic library, though it is designed for use the other way around.
Clozure Common Lisp (CCL) runs in Linux on the ARM, and Gary Byers long ago made an experimental iPhone version, but it would only run on a jail-broken iPhone. The problem is that the CCL compiler writes executable code, but iOS out-of-the-box does not allow a writable page to be made executable, so you can't ever RUN that code.
We've had discussions about putting the code that ships with an iOS app be in a read-only code section, and adding a byte-code compiler, so that code created at run-time can be fairly quickly interpreted, but nobody has offered to fund that project, so it hasn't gotten done.
You might think that we could just interpret code created at run-time, but the current CCL "interpreter" compiles non-trivial code before executing it.
MOCL is probably your best option to write code callable from other apps, but that's only a guess, since I haven't used it.
You could use Gambit Scheme or Clozure Common Lisp, both are able to interface with Cocoa, the first because it generates C and the latter because there is a bridge from Clozure to Cocoa. Do a google search about it and you will find a few things.
You might want to keep an eye on this (new) project. It will be publicly available during October 2019: EQL5 iOS EQL5 iOS libs
There also exists Mobile Common Lisp1
Are there any libraries out there that do this? Playing around with Common Lisp it seems like this would be one of the most useful things to lower barrier of entry for newcomers. ASDF seems mostly designed for deployment, not for rapid prototyping and development. Following threads on comp.lang.lisp it seems like people agree that CL's package system is powerful, but lacks the ease of something like Python's dead simple module system. It is FAIL in the sense that it's designed for power not usability.
Glad to know if I'm wrong. If I'm right, I'm stunned that noone has tried to build a Python module-like system on top of ASDF.
Zach Beane wrote how he nowadays starts new Common Lisp projects by using Quicklisp and Quickproject. This might be along the lines you want.
Not sure if it's ready for prime time or whether it fits your requirements at all, but here's a link to XCVB.
I don't know. I mostly use ASDF for my in-development compilation needs. Once you notice that you'd benefiot from more than one source file, open <projectname>.asd, slap in a basic ASDF system definition template and start slapping filenames in. As and when you notice a cross-file dependency, update the dependency list.
But, then, I use the exact same method dealing with Makefiles (yes, I know there are automatic dependency checkers that can do it for you, but since I mostly code on my own, it's easier to just amend the Makefile/ASDF definition as I go).
In SBCL, there's a hook on REQUIRE that checks for ASDF systems, so you end up with something that is about as convenient as Python's import, but somehow I suspect that is not what you meant.
This may not be the answer you want, but clearly you have some idea of what you want in a module system. Have you considered creating one yourself? That is, taking your limited domain, your limited requirements, your environment and simply pounding out whatever abstractions will quickly make your life easier?
That's one of the key benefits of Lisp I'm sure you know, is that these simple abstractions and little tools are typically very easy to craft in Lisp.
I'm not suggesting solving everyone who has a problem with the package system or ASDF, I'm simply suggesting solving your own problem as you understand it, which is likely simpler and smaller than some more powerful larger scope.
There is Mudballs now, too.
If you're looking for a piece of software to add this functionality to then it's a good bet.
If you want a command line tool that just uses bash to generate new common lisp project directory and file layouts, you may find one that I created for myself useful: lispproject. If it doesn't match your needs, go ahead and fork it or the repo it gets it templates from to suit your needs: lisp-project-template. Look at the sh file in lispproject repo to see how the templates are used. Also, please note that you may need to adjust the calls to sed to fit your platform as I am using this on macOS. Alternative sed calls are in the main script but just commented out if you need them.
it's designed for power not usability
that's how most Lisp gurus like it.
Googling has turned up little to nothing.
I need to develop some heavy stuff in m4 and I'd love to do it in my favorite environment with all the bells and whistles thereof.
There are packages for running m4 on just about every platform, such as windows. So I know at the very least I can create a default project and test from the CLI. But I'd rather not :)
You can also try colorer for Eclipse (http://colorer.sourceforge.net/eclipsecolorer/) — it almost certainly supports m4 syntax (though I did not check).
Unfortunately, just syntax coloring will be of little help - you need something that's capable of interpreting m4 because unless defines are processed you can't tell if it's just a word or a predefined macro. mc (Midnight Commander) has some rudimentary highlighting for m4, you might take a look at that.
I'm not aware of any specific editing support for m4. However, if you have some time to spare (!) and the BNF for m4, then you could use Xtext (http://wiki.eclipse.org/Xtext) to create a syntax-coloring and -completing editor, with an outline view.
Updated an answer below suggests that m4 doesn't have a BNF, or is not BNeFfable, and certainly a short search of the literature shows no claims that an m4 BNF is available - and it appears, though not explicitly stated, that the m4 language is inexpressible in this way.
Obviously this negates my suggestion, so I must retract it, unless of course Xtext has been extended to deal with such languages. Consult the Xtext website linked above for FAQs and mailing list links.
If you are familiar with (and like) vim, you could try out Eclim and then setup syntax highlighting for m4.