Template class using Gold Parser and the Klimstra engine - parsing

I'm using Klimstra's VB.NET template from the "Create skeleton program" of the GOLD parser but the resulting template has methods with the overrides keyword and inherits from TemplateParser..
Am I supposed to create the TemplateParser class or is there a tool to create it? I thought that the "create skeleton" function created a template that I was supposed to inherit and provide implementation to the "MustOverride" methods but now I don't know.
I'm following a tutorial that makes it look like we have to create it using a tool but I'm not sure. I don't know if the tutorial is very outdated (it's dated 2005) and the GOLD parser changed this mechanism. This is the tutorial I'm following: http://www.codeproject.com/KB/recipes/IntrotoGoldParser.aspx

I were just looking into this topic a your link to the article really helped me.
I figured out that in the source files provided with the artictle there are two file with extension .pgt. These are templates for GOLD Code generator. Yout have to copy them into your GOLD installation folder -> Templates and to use them both when you are creating the skeleton program.
I hope this is helpful.

Related

Generated files in xtext with xbase

I followed this tutorial: https://www.eclipse.org/Xtext/documentation/104_jvmdomainmodel.html, but the generated files are .java, I want to change the file extension as well as the grammar, but I want to keep some java features. Also the class DomainmodelGenerator extends AbstractGenerator does not get generated when I use grammar org.example.domainmodel.Domainmodel with org.eclipse.xtext.xbase.Xbase, only if I use terminals. How can I achieve that?
If you use Xbase then, JvmModelGenerator will be used as IGenerator(2). So you have to customize that one and override org.eclipse.xtext.xbase.DefaultXbaseRuntimeModule.bindIGenerator() for binding.
But also triple check if you really want to customize the generator and not enhance the inferrer

Geany custom folding for custom filetype

Company i work develops a new programming language which will ease job of engineer. My job is to supply this language with a nice editor which is also involves code folding. I need to have custom code folding which is not include "{" and "}". I am working with Geany filetypes. I add new filetype. I want to fold some structure like below.
if %condition% then for each %element% in %range% do
%statement% %statement%
else if %condition% then end for
%statement%
else
end if
I know my language far from c type , however add such line to my code for enabling syntax coloring.
[settings]
lexer_filetype=C
Any kind of help will be appreciated.
I dont know exact answer but i know how i can dig it up. As far there is no an answer i am going to write how can the answer can be appeared. Using scintilla and its lexers can take us to solution of this problem. Both Geany and Scintilla documentations mention about support of that feature.
Under Debian :
cp /usr/share/geany/filetypes.c ~/.config/geany/filedefs/
chown myUser:myGroup ~/.config/geany/filedefs/filetypes.c
Edit the file. Under the section [lexer_properties] add the line:
fold.cpp.comment.explicit=1
Save the file.
Open geany. You are now able to put userfoldings using the default //{ and //} delimiters in c and in cpp. These do not influence your code because to c and cpp it are comments.

ZF2 BBCode Parser

Hiho,
I use the ckeditor on my website for special textareas like forum
or signatures.
But I have a problem with the output. I use ZF2 and would like to
use ZendMarkup to render the output bbcode back in html.
But at every time I call
$bbcode->render(...)
I got the error
There is no Zend_Markup_Root markup.
The ZendMarkup is an extension inspired by the Zend_Markup from ZF1.
But I can't find any thing on API or other guides.
Does someone has any idea what as the problem is?
The ZendMarkup library is very old (last update is 10 months ago!) so I wouldn't use such library. If you would like, I think I traced the error down.
On this line there is a reference to Zend_Markup_Root while that should be ZendMarkup\Renderer\Markup\Html\Root. Try to change that line and see what happens.
Another way is to replace the ZendMarkup library with another library which does work and is updated regularly. An example is Decoda. If you load mjohnson/decoda in your composer.json, you can use Decoda in your Zend Framework 2 application:
<?php
use Decoda\Decoda;
$parser = new Decoda($bbcode);
$html = $parser->parse();
With tools like composer, there is no need to use solely Zend* components when there are better alternatives.

Xtext: referencing existing java packages and methods

I developed a DSL which I use together with standard java code.
In my DSL I can write things like this:
package: packagename;
method: void testMethod (int, double);
What I want to do, is that the user of the DSL can only write package names and method signatures which already exist in the Java project.
Example:
When my project only consists of one package e.g. “TestPackage”, the user of the DSL should only be able to write:
package: TestPackage
the name “TestPackage” should also be suggested by the code completor. The same shall also work with the methods.
Is it possible? And how can I do this with Xtext?
I've not used it (yet), but take a look at the relevant Xtext documentation on this. Also, I'd look through the "7 Languages", find one that does what you want (which I think you'll find), and study the source.

How to create/use custom classes and helper in symfony 1.4?

What is the best way to put custom library or helper methods in symfony?
I am using doctrine with my project. One place I consider to put is under project_root/lib/vendor/MyClasses/
But if I want to create a class or helper function which will use some core symfony/doctrine methods and return a result then how to do that and where should I put it?
I want it to call from different modules to avoid code duplication.
As for the custom library part of the question, you might probably want to put your external library into the lib/vendor folder. Since symfony doesn't automatically load everything that's in there, you'll have to tell its autoloader to do so.
You can either extend your config/ProjectConfiguration.class.php (as described here) or (and this is the much simpler and cleaner way) you add them to your config/autoload.yml (you might have to create this one).
For the latter option, this is a great place to start looking at.
It seems to be a duplicate question.
As asked in symfony's 1.2 "Definitive Guide" docs :
Helper functions (regular PHP functions returning HTML code) should be saved in a file called FooBarHelper.php, where FooBar is the name of the helper group. Store the file in the apps/myapp/lib/helper/ directory (or in any helper/ directory created under one of the lib/ folders of your project) so it can be found automatically by the use_helper('FooBar') helper for inclusion.
So, if you want to create custom helper FooBar for foo() function, create file lib/helper/FooBarHelper.php :
function foo() {echo "foo!"; }
to use it in your template:
use_helper('FooBar')
....
foo(); //outs "foo!"

Resources