Syntax validation – GCP backend

Continuing to talk about Code Assistance Backend, I will introduce my next step on my project. Let’s review which we have in gcp backend.

So, first, we have 4 programming languages backend: python, xml, C and vala. For xml syntax validation, we need to install a extra-pkg called lxml and, for vala, we need libvala pkg.

Talking about vala and libvala, because this was a programming language backend which I implement and I have more idea about how it works. I use a vala class Report to create a new diagnostic tag with some severity (error, warning, notice) which will displayed this diagnostic message on gedit document. A report object is a attribute of another class – CodeContext – that will start to scanning a souce content and will call report when each syntax issues is found.

Yes, libvala turns vala syntax validation very automated. As the same to Python using itself and I think is the same to xml using lxml. But a question about ways to do syntax analysis arose when I decided to build a JS backend. The first thing that I need to search was about some js feature to do syntax analysis and binds to be used between JS and python or vala. Every time that I want a new language as backend I will need to search some package to provide binds between this language and Python/Vala? Maybe could be easy use some packages features, but I, for example, really don’t like to install a lot of packages to be able to use some application. As more packages I installed, more packages conflict I will be susceptible to deal.

Search for a solution for JS Backend, I found a JS minimizer called SlimIt which uses Python PLY to provide JS syntax analysis. So, I think “why don’t we use a PLY based class as abstract class for every backend and just worry about grammar and tokens?” You can ask me: is not really simple implement grammar and tokens. Yes, you are right, but using PLY we will not need to install a lot of packages and, if you could not find a parser to assist you for some language, you can do it by yourself.

So, my new step is use PLY to provide backends for any language which has free context grammar. Begining with JS.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: