Showing posts with label open source. Show all posts
Showing posts with label open source. Show all posts

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

Tuesday, 4 November 2014

Welcome to my first post

Hello There!!!!
I Thought to post few things here which will be beneficial to others. After all It is everybody's duty to give back something to the society. 

I have 20 years of software development Experience. Throughout this 2 decade long career I used OpenSource platform 99.999% of time. Rest fractional part is spent on old favourite MS-DOS (versions 3,5,6,6.2). I have learnt so many things from OpenSource Projects. So I started few open source projects back in 2007-2012. All my projects are hosted here. 

Besides software I also keep interest in Electronics(Hobby), Photography, Aero modelling and SWL(Radio listening). In this blog time to time I will post my experiments on these topics and few social concerns too. What ever is posted will be purely my personal experience. If any thing which is not my own is presented due credit will be given to the source.

This is all for now, stay tuned for more in future.

Thank you for your patience and visit.
 

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...