Tuesday 9 August 2016

My Experiment with Compiler Writing. Part-1

Introduction

Well, I have written a small OS kernel(NanoOS) earlier(2008-2010). It was written in C++ and assembly language for Self learning as well as for Fellow colleagues at Redhat, Pune. But never tried a compiler or interpreter, as it was never needed for my Job.

The need

Recently for a small project I had to write a small parser. It is not a language parser though.  It was written for a parsing a logfile of an application. Even it was designed to detect wrong sequence in that application. Well forget about the application. After that project is complete I thought to write a small Interpreter or Compiler for a very small language. As a first thought It came to me that I should write a Compiler for BASIC(Beginners' All purpose Symbolic Instruction Code) but implementing a full blown BASIC compiler is a big task for me(I sincerely believe I am not that intelligent to write a full blown compiler single handedly). So in my so-called Compiler a very very small subset of BASIC language will be implemented, as it was meant for self training and example for who ever wants to study this subject practically.

My approach

I prefer practical way to learn. So i will try to lay down fragments of code in sequence. So that any one can follow and understand.
  1. We will be using C or C++ 
  2. We will start with a very basic tokenizer
  3. Modify the code to have a parser
  4. Code generator.
Why I choose C or C++ is, I write code more easily in these 2 languages. Any other language can be used. Even BASIC can be used to write a BASIC compiler.
But it needs through understanding of the language.

I deliberately avoided Gramars and all those Compiler jargon. If those things are needed then please pickup a Compiler writing book and read. If you have read such a book then you may find this article informative on implementation.

Keep in mind "This is not a tutorial for Compiler construction courses" or class assignment. Secondly Please Don't Expect it to be of any practical use. This is just for my personal pleasure and to share my pleasure with others.

In next instalment I will start with lexing/parsing code.

Thanks
DE VU3VFU

Saturday 6 August 2016

A 30 years Dream

Today I got my HAM license. My call sign is VU3VFU( Viktor Uniform number 3 Viktor Foxtrot Uniform).

It was 1986 june. My Matric Exam(10th Board exam) was over. So no study pressure no mathematics no algebra no geometry no trigonometry... Initially it was enjoying but after 2 weeks it was horribly boring. While I was roaming in the market I saw EFY(Electronics For You). Got tempted and bought it. Those days it was costing Rs.5/- yes Five Rupees. I found it interesting but somany topics are over my head ( You know What I mean Hi Hi Hi).
In that issue they have published about HAM radio. when I read it I was thrilled. Can I really keep a Transmitter at home??? intrigued me.

I read that article repeatedly and convinced yes it is possible to have transmitters at home. Next is gathering information. Those days there were no internet, no mobile phone nothing. So ultimate part is going to electronics department and asking them. But I never find any answer from them.

Fortunately there was a Marine Radio Communication training institute in my college (Ravenshaw college).I  approached the chief instructor Mr.Choudhury. He gave me a good and convincing answer. I collected monitoring station's address in Gopalpur,Sarkarpul, Chabis praganas,WB. Wrote mail but they never gave inspiring or detailed procedure. Next my research found "ABC of Amateur Radio". I read that from begin to end.

Then time flew by and I joined Engineering college(UCE Burla.) in Civil Engineering. My interest gone dormant. But some fine day my younger brother(now K14DDY) informed me there are few hams at Sambalpur. I tried to meet them but unfortunately i could not. Then Course work pressure, then after completion JOB hunt from during 1993... I could not look towards HAM radio.

Then comes 2011. I came back to Odisha and Got to know about VU3PLP( now VU2FRD) called him up and his assurance kindled new hope in me and gradually we formed an association ARSO(Amateur Radio Society Odisha). Arranged Exam and Now we have 18 more HAMs in odisha...

This is my story it may not inpire you or not interest you, but I felt I should share this 30years of wait.
Any ways please share your story and comments.

Thanks 
de VU3VFU.

Neural Network from Scratch Using C (Part-3)

  XOR Problem In part 2, AND gate and OR gate could be trained using a single perceptron. But XOR gate could not be as it is not linearly...