Sunday, July 8, 2018

DSC Summit 2018 Experience

Transformation: A revolutionary act or process which brings about change in our 
lives. It is the phenomenon which governs the birth of many ideas, inspirations, 
motivations and I got the opportunity to undergo such a transformation at the first ever 
DSC Summit 2018, as I became a part of the exciting congregation of DSC Leads 
from all over India, who religiously worship technology 
in their own campuses and ecosystems!

My journey to the DSC Summit began with an email stating that I had been 
selected as the DSC Lead of PICT, on the 30th September 2017, a day I 
remember so well! Since then, I had been conducting sessions on mobile 
development along with the ACS Facilitator, Nikita Kotak, and Akshay Ubale, 
a friend who is extremely passionate about development on my campus, out of 
my interest to learn about technology and share the learnings. We enjoyed the
process as it was! The sessions were going well, we were still to get the 
bigger picture of things, at that time! All of that was about to be levelled up soon! 

The DSC Summit, the catalyst, began with the enthusiasm of leads from all 
over the nation, moving towards one goal: harnessing the power of technology to 
create impact in the society! Till that day, each of us had been engaging in technological
activities in our respective campuses, transcending limits and yet, a little oblivious to 
what other leads were doing. And there we were, on the first evening of the Summit, 
gathered at one magical place, Goa, introducing ourselves, talking about our work, 
our likes and dislikes and networking with each other! On the very first evening, 
I got to know about the wider perspective of things, which was only to be expanded 
further on the next days!

We had sessions on leadership which gave me teachings of a lifetime, design thinking 
workshop which introduced me to innovative and effective ways of problem-solving, 
panel discussion on careers in technology on the first day! The next day unfolded exciting 
tech-talks, a talk on internationalization, storytelling, and much more.., each of which gave 
tremendous amounts of learning, much more than any tutorial, lecture or book :D

Here’s a slightly more detailed account of the sessions in the Summit: 

Day 1:
  • The Persuasive Leader by Anson Ben: The session on effective communication skills 
    gave me teachings of a lifetime!
  • The Design Thinking workshop by University Innovation Fellows: Ghanshyam S and the Fellows 
    conducted a fun session which enabled us to interact with a local business person, understand 
    his/her problems and develop a solution prototype. The activity helped me to understand a 
    creative, innovative and fun process to approach a problem, gave me an opportunity to 
    work in a team and exposed me to innovative ideas!! 

  • Product Excellence by Dimple Batra: The session by Program Manager at Google gave wonderful insights on how to develop fantastic products.  
  • Panel Discussion on Careers in Tech- Anson Ben, Shikha Gupta, Arjun Pratap, moderated by 
Vaishali Sabhahit: I got a chance to view technological careers from different perspectives.

Day 2:

Included sessions like: 

Karthik Ramakrishnan, and moderated by Deepak Sridhar:
This discussion made me understand that the scope of DSC activities 
can extend far and wide beyond the college campus. It was truly 
motivating to hear success stories of each of the community leads,
  including one involving the setting up of a startup support 
platform by the Mangalore Government, because of startups being founded 
by the efforts of the Community Lead!

  • Jobs at Google By Suhail AH: This was the most awaited talk of the day!! 
    Suhail talked about what Google looks in a candidate before hiring, how 
    students can prepare and how we, as DSC leads can spread information 
    regarding this. Google looks for the following qualities while hiring candidates:
    • The thought process
    • Leadership skills
    • Domain knowledge
    • A hint of Googliness!
     
The pathways to a job at Google:  
  • CodeJam Kickstart
  • YouTube Livestreams
  • Tech Dev Guide
  • Developmental Workshops
With these exhilarating sessions, we also had a fun DJ night, where all of us put on our 
dancing shoes and grooved to the beat! The standup comedy by Azeem Banatwala 
lightened the air!

The DSC Summit was a combo of networking, leadership skills, problem solving and 
more than that, FUN!! Every minute, I learnt something and eventually realized that 
I have a world full of possibilities, to be traversed, explored and discovered! 
With every step that I took, I could learn something new, move closer to transformation, 
for, “Life and death are illusions, we are in a constant state of transformation”!





Applied CS with Android Bootcamp Experience!

It is so well said by Bobby Unser : “Success is where preparation and opportunity meet”. 
This quote exactly revolutionized my journey as a developer!! In my third year when I was
learning basics of android and implementing them in small projects, that is when the  
opportunity to facilitate Applied CS with Android Course knocked on my door and then
 started this amazing journey!

To begin with, we attended a boot camp at Google Bangalore Office on 30th-31st August 2017
where facilitators from colleges across India were present. Very soon the wonderful interactions
and  discussions had started pouring in that room with various experiences and expertise 
shared by previous  facilitators from different institutions across India. They shared their 
challenges and learning experiences while conducting sessions at their campus. Also there
were enlightening talks by Googlers and our Program Coordinators to guide us into conducting 
sessions. There was immense enthusiasm among all the facilitators and we all aimed to conduct 
sessions back home with the motto to transform CS theory into practise and bringing foundational
Computer Science and Android Skills together!

At PICT, I then formed a team with Rucha Tambe : Developer Students Lead, PICT with a 
similar initiative of transforming concepts into applications. We formed a group PICT Applied 
CS and DSC under which we have been conducting Android sessions every weekend right 
since October 2017. We conducted the sessions in two phases : basics and intermediate 
targeting audience from all classes.

We feel immense pleasure and content to see the results of this club where many novice coders
were driven into development and started working on some great projects! The entire journey has 
been a great learning experience for me , strengthening me as a developer. Also This opportunity
has given me a community of like minded developers from all across the country! All in all it was
an experience beyond words and thanking Google and PICT for this wouldn’t be enough!!

Wednesday, May 30, 2018

A Lex program to generate tokens of a subset of input Java program

Inputs

javatoken.txt

import java.sql.*;
class Hello{
public static void main(String args[]){
    System.out.println("HI");
    //printing
}
}

javatoken.l

 %{
    #include<stdio.h>
%}

DATATYPE int|char|bool|float|double|String
SC [;]
DOTOP [.]
OPERATOR "+"|"-"|"/"|"*"|"="
UNARY "++"|"--"
IDENTIFIER [a-zA-Z]+[a-zA-Z0-9]*
COMMENT "//"[a-zA-Z0-9]*
PREPROCESSOR "import"[a-zA-Z0-9 "." "*"]*
KEYWORD public|static|void|main|abstract|class
BLOCK_S "{"
BLOCK_E "}"
BRACKET ")"|"("
STRING "\""[a-zA-Z0-9]*"\""

%%
{DOTOP} {printf("");}
{BRACKET} {printf("\n %s: bracket",yytext);}
{DATATYPE} {printf("\n %s: datatype",yytext);}
{SC} {printf("\n %s: semi colon \n",yytext);}
{OPERATOR} {printf("\n %s: operator \n",yytext);}
{UNARY} {printf("\n %s: unary \n",yytext);}
{BLOCK_S} {printf("\n %s: block start",yytext);}
{BLOCK_E} {printf("\n %s: block end",yytext);}
{COMMENT} {printf("\n %s: comment",yytext);}
{PREPROCESSOR} {printf("\n %s: preprocessor",yytext);}
{KEYWORD} {printf("\n %s: keyword",yytext);}
{STRING} {printf("\n %s: string",yytext);}
{IDENTIFIER} {printf("\n %s: identifier",yytext);}
%%
int yywrap(){
    return (1);
}
main(){
    yyin=fopen("javatoken.txt","r");
    yylex();
    return 0;
}

Commands to run a file with '.l' extension

1) lex filename.l
2) gcc lex.yy.c
3) ./a.out

Output 


A Lex program to count number of words, lines and characters of given input file.

Input: file.txt

hi
HELLO
how are you

wordcount.l

%{
    #include<stdio.h>
    int cletter=0,sletter=0,lines=0,spaces=0,num=0,chara=0,words=0;
%}

%%
[\t ' ']+ {words++; spaces++; chara=chara+yyleng;}
\n  {lines++; words++;}
[A-Z] cletter++;
[a-z] sletter++;
[0-9] num++;
%%

main(){
    yyin=fopen("file.txt","r");
    yylex();
    printf("FILE HAS \n");
    printf("%d spaces",spaces);
    printf("\n");
    printf("%d words",words);
    printf("\n");
    printf("%d characters",chara);
    printf("\n");
    printf("%d  numbers",num);
    printf("\n");
    printf("%d  upper case letters",cletter);
    printf("\n");
    printf("%d  lower case letters",sletter);
    printf("\n");
    printf("%d  lines",lines);
    return 0;
}

int yywrap(){
    return (1);
}

Output

 



A Java program for pass-II of a two-pass macro-processor. The output of Macro pass one preprocessor (MNT, MDT) is input for this program.

A Java Program for Macro Pass Two Preprocessing

//===============================================
// Name        : PassTwo.java
// Author      : Rucha Tambe
// Version     :
// Copyright   : Your copyright notice
// Description : Pass Two Preprocessor in Java
//================================================

 PassTwo.java

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;


public class PassTwo {

    ArrayList<mntf> mnt = new ArrayList<>();
    ArrayList<String>mdt = new ArrayList<>();
    HashMap<String, ArrayList<String>> pntab = new HashMap<>();
    ArrayList<String>kptab = new ArrayList<>();
    PassOne p;
    public PassTwo() throws Exception {
        p = new PassOne();
        p.PassOne();
        mnt = p.mnt;
        mdt = p.mdt;
        pntab = p.pntab;
        kptab = p.kptab;
       
    }
   
    void passtwo() throws IOException{
        BufferedReader br = new BufferedReader(new FileReader("input1.asm"));
        String line = "";
       
        int flag=0;
        while((line=br.readLine())!=null){
            String[] split = line.split("\\s+");
            if(split[1].equals("START")){
                flag=1;
            }
            if(flag==1){
                if(pntab.containsKey(split[1])){
                    ArrayList<String> apt = new ArrayList<>();
                   
                    int index = getIndexMnt(split[1]);
                    int kpdtp = mnt.get(index).getKpdtp();
                    //fill default values
                   
                    int pp = mnt.get(index).getPp();
                    int kp = mnt.get(index).getKp();
                    int i=0;
                    for(i=0;i<pp;i++){
                        apt.add("0");
                    }
                    int j=0;
                    for(i=pp;i<pp+kp;i++){
                        String kpara = kptab.get(kpdtp+j);
kpara=kpara.substring(kpara.indexOf("=")+1,kpara.length()).replace(",","");
                       
                        if(kpara.length()>1){
                            apt.add(kpara);
                        }else{
                            apt.add("0");
                        }
                        j++;
                    }
                   
                    int k=2,l=0;
                    while(k<split.length){
                        if(l<pp){
                            apt.remove(l);
                            apt.add(l,split[k].replace(",", ""));
                        }else{
                          String para =  split[k].substring(split[k].indexOf("&")+1,split[k].indexOf("="));
                            String value = split[k].substring(split[k].indexOf("=")+1,split[k].length()).replace(",", "");
                           
                  int in = pntab.get(split[1]).indexOf(para);
                            apt.remove(in);
                            apt.add(in,value);
                        }
                        l++;
                        k++;
                    }
                   
                    int mdtp = mnt.get(index).getMdtp();
                   
                    while(true){
                        String inst = mdt.get(mdtp);
                        if(inst.contains("MEND")){
                            break;
                        }
                       
                        String[] sp = inst.split("\\s+");
                       
                        k=1;
                        while(k<sp.length && sp[k].contains("P")){
                             String val =  apt.get(Integer.parseInt(sp[k].substring(sp[k].indexOf(",")+1,sp[k].indexOf(")"))));
                             sp[k] = val;
                             k++;
                        }
                        System.out.println(sp[0]+" "+sp[1]+" "+sp[2]);
                        mdtp++;
                    }
                    System.out.println("APTAB:");
                    for(i=0;i<apt.size();i++){
                        System.out.println(apt.get(i));
                    }
                }
            }
        }
    }
   
    public int getIndexMnt(String mn){
        int temp=0;
        while(!mnt.get(temp).getName().equals(mn)){
            temp++;
        }
        return temp;
    }
    public static void main(String[] args) throws Exception {
        PassTwo p = new PassTwo();
        p.passtwo();
    }



Output 

MOVER AREG 10
ADD AREG ='1'
MOVER CREG 20
ADD CREG ='5'
APTAB:
10
20
AREG
CREG
MOVER BREG 100
MOVER AREG 200
ADD BREG ='15'
ADD AREG ='10'
APTAB:
100
200
BREG
AREG

Design suitable data structures and implement pass-I of a two-pass macro-processor in Java

A Java Program for Macro Pass One Preprocessor

//===============================================
// Name        : PassOne.java
// Author      : Rucha Tambe
// Version     :
// Copyright   : Your copyright notice
// Description : Macro Pass One Assembler in Java
//================================================


Inputs

input1.asm

    MACRO
    M1    &X, &Y, &A=AREG, &B=
    MOVER    &A, &X
    ADD    &A, ='1'
    MOVER    &B, &Y
    ADD    &B, ='5'
    MEND
    MACRO
    M2    &P, &Q, &U=CREG, &V=DREG
    MOVER    &U, &P
    MOVER    &V, &Q
    ADD    &U, ='15'
    ADD    &V, ='10'
    MEND
    START    100
    M1    10, 20, &B=CREG   
    M2    100, 200, &V=AREG, &U=BREG
    END 

PassOne.java 

import java.io.*;
import java.util.*;


public class PassOne {

    static ArrayList<mntf> mnt = new ArrayList<>();
    static ArrayList<String>mdt = new ArrayList<>();
    static HashMap<String, ArrayList<String>> pntab = new HashMap<>();
    static ArrayList<String>kptab = new ArrayList<>();
   
    static void PassOne() throws Exception{
       
        BufferedReader br = new BufferedReader(new FileReader("input1.asm"));
        String line = "";
        while((line = br.readLine()) != null)
        {
            String split[] = line.split("\\s+");
            if(split[1].equals("MACRO")){
               
                ArrayList<String> pnt = new ArrayList<>();
                line = br.readLine();
                int k = 2,pp=0,kp=0;
               
                String sp[] = line.split("\\s+");
                mntf mn = new mntf();
                mn.name = sp[1];
                mn.kpdtp = kptab.size();
                mn.mdtp = mdt.size();
                //System.out.println();
                while(k < sp.length){
                    String s = "";
                    if(sp[k].contains("=")){
                        //Keyword parameter present
      s = sp[k].substring(sp[k].indexOf("&")+1,sp[k].indexOf("="));
                        kptab.add(sp[k]);
                        kp++;
                       
                    }else{
                        //Positional Parameter present
         s = sp[k].substring(sp[k].indexOf("&")+1,sp[k].indexOf(","));
                   
                        pp++;
                    }
                    pnt.add(s);
                    //System.out.println(s);
                    k++;
                }
                //Setting the macro and putting it in pntab
               
                mn.setKp(kp);
                mn.setPp(pp);
                mnt.add(mn);
                pntab.put(mn.name,pnt);
                //Reading macro and putting the definition in mdt
                while((line = br.readLine())!=null){
                    String s = "";
                    String def[] = line.split("\\s+");
                    if(def[1].equals("MEND")){

                         mdt.add("MEND");
                         break;
                    }
                   
                    s = def[1]+" ";
                    k=2;
                    while(k < def.length){
                        if(def[k].contains("&")){
           s += "(P,"+ pnt.indexOf(def[k].replace("&", "").replace(",",""))+")    ";
                           
                        }else{
                             s += def[k];
                           
                        }
                        k++;
                    }
                    mdt.add(s);
                }
            }
           
        }
        print();
    }
    public static void print() {
        for(int i=0;i<mnt.size();i++) {
            mntf m = mnt.get(i);
            //System.out.println(m.getName()+" "+m.getKp()+" "+m.getPp()+" "+m.getKpdtp()+" "+m.getMdtp());
            ArrayList<String> p = pntab.get(m.getName());
            System.out.println("Pntab for "+m.getName());
            for(int k=0;k<p.size();k++) {
                System.out.println(p.get(k));
            }
        }
        for(int i=0;i<mdt.size();i++) {
            System.out.println(mdt.get(i));
        }
    }
   
    public static void main(String[] args) {
       
        try {
            PassOne();
           
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

}

Output 

Macro Pass One Output

 

Implement Pass Two of two pass assembler for pseudo-machine in Java using object oriented features. The output of pass one assembler (intermediate file and symbol table) should be input for pass two assembler.

A Java Program for Pass Two Assembler

 
//===============================================
// Name        : PassTwo.java
// Author      : Rucha Tambe
// Version     :
// Copyright   : Your copyright notice
// Description : Pass Two Assembler in Java
//================================================


Inputs:

sym.txt

A  100
L1  103
B  109
C  100
D  101
L2  107 

lit.txt

12  106
5  110 

pool.txt

0
1

PassTwo.java

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;

public class PassTwo {
    ArrayList<Integer> symaddr=new ArrayList<>();
    ArrayList<String> littab=new ArrayList<>();
    ArrayList<Integer> litaddr=new ArrayList<>();
    ArrayList<Integer> pooltab=new ArrayList<>();

    public void readFile() throws Exception {
        BufferedReader br=new BufferedReader(new FileReader("sym.txt"));
        String line=" ";
        while((line=br.readLine())!=null) {
            String split[]=line.split("\\s+");
            symaddr.add(Integer.parseInt(split[1]));
        }
        BufferedReader br2=new BufferedReader(new FileReader("lit.txt"));
        while((line=br2.readLine())!=null) {
            String split[]=line.split("\\s+");
            littab.add(split[0]);
            litaddr.add(Integer.parseInt(split[1]));
        }

        BufferedReader br3=new BufferedReader(new FileReader("pool.txt"));
        while((line=br3.readLine())!=null) {
            pooltab.add(Integer.parseInt(line));
        }
    }

    public void generateMachineCode() throws Exception {
        String line=" ";
        BufferedReader br=new BufferedReader(new FileReader("ic.txt"));
        int p=0;
        while((line=br.readLine())!=null) {
            String split[]=line.split("\\s+");

            String sp[]=split[0].replace("(","").replace(")", "").split("\\,");

            if(sp[0].equals("DL")) {
                String arr[]=split[1].replace("(", "").replace(")", "").split("\\,");
                System.out.println("+00 0 "+String.format("%03d", Integer.parseInt(arr[1])));
            }

            else if(sp[0].equals("IS")) {
                System.out.print(sp[1]+" ");

                int i=1;
                while(i<split.length) {
                    String arr[]=split[i].replace("(", "").replace(")","").split("\\,");
                    if(arr[0].equals("S")) {
                     
                        System.out.println(symaddr.get(Integer.parseInt(arr[1])));
                    }
                    else if(arr[0].equals("L")) {
                       
                        System.out.println(litaddr.get(Integer.parseInt(arr[1])));
                    }
                    else if(arr[0].equals("C")) {
                       
                        System.out.println((Integer.parseInt(arr[1])));
                    }
                    else {
                        System.out.print(arr[0]+"  ");
                    }
                    i++;
                }
            }
            else if(sp[0].equals("AD") && (sp[1].equals("04") || sp[1].equals("05"))){
                if(sp[1].equals("05")) {
                    for(int i=pooltab.get(p);i<pooltab.get(p+1);i++) {
                        System.out.println("+00 0 "+Integer.parseInt(littab.get(i)));
                    }
                  
                }
                else {
                    for(int i=pooltab.get(p);i<littab.size();i++) {
                        System.out.println("+00 0"+Integer.parseInt(littab.get(i)));
                    }
                }
                p++;
            }
        }

    }


    public static void main(String[] args) throws Exception {
        PassTwo p=new PassTwo();
        p.readFile();
        p.generateMachineCode();
    }

Output