Design a mini script language - language-design

my project this year is to develop a text mining tool (with new features)
so we need a mini script language in this tool to add annotation to texts
this language should be simple and like lisp grammars (left and right side) .
what i need is how to design this language ,i know how to constract the compiler ,
but how to write language grammars ? , and i want to use some mini open source language or any language bnf
please advice me and if there is a language i can use and customize to meet my needs ?
EDIT : if anybody can give a link for grammar (bnf) for lisp or any language like it
many thanks

You can consider us this
http://www.antlr.org/
to design your language.

If possible, I would recommend just using Lua. If you use their interpreter, which is designed to be easily embedded in other programs, it will save you the time of designing, implementing, and testing your own language.
Otherewise, you may be able to re-use the Lua parser code to parse your own Lua-like language.

Related

What are the scripting languages one should know to effectively use the Selenium tool for automation testing

I am a fresher and being hired as a Quality Analyst in a software firm in automation testing
I have been told to study the Selenium tool.
Can you guys help me in knowing that what are the scripting languages I should get in touch so that I can effectively and efficiently use the tool to give the very best output of mine,
Hoping for responses....It would definitely help me a lot in going in proper direction....
Thanks in ADVANCE
Not exactly scripting languages, but be very fluent with HTML and XML/XPath to easily work with pages and understand how they work.
Knowing a little about JavaScript will also come in handy. As for other languages, Selenium natively speaks HTML, but you can write test cases in any of the following languages (list is not exhaustive):
C#
Java
Perl
PHP
Python
Ruby
Native HTML test case can be translated easily to the aforementioned languages, pick whichever you like the most.
You can get all these details from seleniumhq.org site. Please check the documentation section . Also, regardless of the language you choose selenium features remain the same. So choose the language which you are comfortable with.
Adding to what others have already said, to begin programming with your favorite language using Selenium RC, you need to be familiar with the basic Object Orient Programming concepts.
To help you with XPath there are tools like XPather and Firebug which automatically fetch you the XPath of the element.
The perl language binding is quite reliable and up-to-date.
On the CPAN, the current release Test-WWW-Selenium-1.25 is from 28 Apr 2011. It's actively maintained.
Perl's Test Runners and TAP are cool. There are many other testing modules that you can combine with Test-WWW-Selenium.
Using E-P-I-C perl Editor for the Eclipse IDE, you'd get statement completion in your testcase files.
The Perl API calls are written in a slightly different naming convention: for instance, getEval becomes get_eval
but this is a minor point.
IMHO, the perl code template that Selenium IDE generates for you is ok, it can be adapted. (e.g. I prefer Test::Fatal instead of Test::Exception.)
Cannot say anything about the other language bindings.
Choose the language you are most familiar with, and start building up your expert knowledge of testing tricks, Selenium and browser idiosyncrasies. this will take a lot of time anyway.
For any kind of strong automation, you should know atleast one scripting language like JavaScript, VBScript etc... and one full fledged programming language like Java, C# etc.. benefit of learning java or #C is ... you are comfortable in developing complex solutions because of their OOP nature and Java,C# are widely used in IT Industry.
Robot Framework is a robust scripting engine and reporting tool for automation testing.

What interpreted language can i leverage for debugging?

I spoke about developing a programming language. Instead of making it compiled i am considering making it interpreted. So what i like to do is parse the syntax myself, build the AST and output source in an existing scripting language.
The thing i'd like to know is what interpreted language can i leverage for debugging? I'd like a call stack, file/source name and line #, to modify variables on the fly, etc.
What IDE must i use? i like visual studios but i presume it has no support for any interpreted languages
You should use Eclipse to do what you want. There is a lot of any interpreted language supports and you can easily debug with the Debug Perspective.
The advantage of the Python language is that all is open-source. Indeed, there is no obfuscation and you can watch the source code without any problem.

How to create an Eclipse editor plugin with syntax checking and coloring as fast as possible?

I'm working on a project that requires me to create a series of editors for languages that are quite different. The syntaxes are defined by us.
I'm looking for a solution for this.
Is there a shortcut to take in this problem?
You could use XText:
a framework for development of textual domain specific languages (DSLs).
Just describe your very own DSL using Xtext's simple EBNF grammar language and the generator will create a parser, an AST-meta model (implemented in EMF) as well as a full-featured Eclipse text editor from that.
Alternatives to XText are Rascal or Spoofax, both less popular than XText but interesting for they support more general context-free grammars, among other things. Nice to check out.
If you are looking for a more low level, programmable solution, then Eclipse's IDE Meta-tooling platform is a good choice (IMP).
What IMP gives you is API to connect your existing parsers to Eclipse without much hassle. You need to implement an IParseController interface, to call your parser and ITokenIterator to produce tokens and some other interface to assign fonts to each kind of token.
The aforementioned Rascal and Spoofax are both build on top of IMP.
Not mentioned is DLTK (proposed also in Tutorial regarding the development of a custom Eclipse editor)
There are Ruby, bash that are implemented with it.

Google code search - missed languages

This is very odd, but I don't see neither PowerShell nor XAML among supported languages
http://www.google.com/codesearch/advanced_code_search ?!
How can I filter results for that languages?
From the Codesearch FAQ:
What programming languages do you support?
The Advanced Code Search page lists
the programming languages we're able
to detect. But even if your language
of choice isn't on there, you can
still search for code written in that
language. We make as much code
searchable as possible, including code
where we can't detect the language.
When we're able to detect the
programming language for a file, we
indicate that in the search results,
and you can restrict your search to
code written in that language.
If we're not detecting a language you
care about, the file: operator can be
useful to search for files with a
specific extension. For example, you
could restrict your search to files
with a .x or .abc extension with a
query like myquery file:\.(x|abc)$. If
we're not detecting a language you
think is important, be sure to let us
know.

Creating your own language

If I were looking to create my own language are there any tools that would help me along? I have heard of yacc but I'm wondering how I would implement features that I want in the language.
Closely related questions (all taken by searching on [compiler] on stackoverflow):
Learning Resources on Parsers, Interpreters, and Compilers
Learning to write a compiler
Constructing a simple interpreter
...
And similar topics (from the same search):
Bootstrapping a language
How much of the compiler should we know?
Writing a compiler in its own language
...
Edit: I know the stackoverflow related question search isn't what we'd like it to be, but
did we really need the nth iteration of this topic? Meh!
The first tool I would recommend is the Dragon Book. That is the reference for building compilers. Designing a language is no easy task, implementing it is even more difficult. The dragon book helps there. The book even reference to the standard unix tools lex and yacc. The gnu equivalent tools are called flex and bison. They both generate lexer and parser. There exist also more modern tools for generating lexer and parser, e.g. for java there are ANTLR (I also remember javacc and CUP, but I used myself only ANTLR). The fact that ANTLR combines parser and lexer and that eclipse plugin is availabe make it very comfortable to use. But to compare them, the type of parser you need, and know for what you need them, you should read the Dragon book. There are also other things you have to consider, like runtime environment, programming paradigm, ....
If you have already certain design ideas and need help for a certain step or detail the anwsers could be more helpful.
ANTLR is a very nice parser generator written in Java. There's a terrific book available, too.
I like Flex (Fast Lex) [Lexical scanner]
and Bison (A Hairy Yacc) [Yet another compiler compiler]
Both are free and available on all *NIX installations. For Windows just install cygwin.
But I old school.
By using these tools you can also find the lex rules and yacc gramers for a lot of popular languages on the internet. Thus providing you with a quick way to get up and running and then you can customize the grammers as you go.
Example: Arithmetic expression handling [order of precedence etc is a done to death problem] you can quickly get the grammer for this from the web.
An alternative to think about is to write a front-end extension to GCC.
Non Trivial but if you want a compiled language it saves a lot of work in the code generation section (you will still need to know love and understand flex/bison).
I never finished the complete language, I had used rply and llvmlite implements a simple foxbase language, in https://github.com/acekingke/foxbase_compiler
so if you want use python, rply or llvmlite is helpful.
if you want use golang, goyacc maybe useful. But you should write a lexical analyzer by hard coding by hand. Or you can use https://github.com/acekingke/lexergo to simplify it.