Preview

Symtab

Good Essays
Open Document
Open Document
1520 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Symtab
#include<stdio.h> #include<malloc.h> #include<string.h> #include<stdlib.h> int k=0; struct symtab { char name[10],type[10]; int size,address; char value[10]; }s[20];

int notexist(char tok[]) { int i; for(i=0;i<k;i++) { if(strcmp(s[i].name,tok)==0) return 0; } return 1; }

void delete(char word[]) { int i=0,j,exist=notexist(word); if(exist==1) printf("symbol not present!\n"); else { for(i=0;i<k;i++) { if(strcmp(s[i].name,word)==0) { for(j=i;j<k-1;j++) s[j]=s[j+1]; k--; for(j=1;j<k;j++) s[j].address=s[j-1].address+s[j-1].size; break; } }

} }

void modify(char word[]) { int i=0,exist=notexist(word); char val[20],a[100]; if(exist==1) printf("symbol not present!\n"); else { printf("enter new value:"); scanf("%s",a); for(i=0;i<k;i++) { if(strcmp(s[i].name,word)==0) { strcpy(s[i].value,a); break; } } }

}

void create(char word[]) { char tokens[20][20]={"int","float","char","double"}; char *tok,t[100],tem[30],*temp,*point,col[10],row[10],buff[100]; int array=0,gg=0,r,c,cc=0,g=0,z=0,i=0,flag=0,l=0,f=0,d=0; strcpy(tem,word); tok=strtok(word," ,+=;()-%[]}{\n"); while(tok!=NULL) { array=0; for(l=0;l<4;l++) { if(strcmp(tok,tokens[l])==0)// checking for int/float/char/const

{ flag=1; switch(l) { case 0: i++; break; case 1: f++; break; case 2: cc++; break; case 3: d++; break; } goto next; } } if(flag==1) { int exist=notexist(tok); if(exist!=0) {

if(i==1) { i--; strcpy(s[k].name,tok); strcpy(s[k].type,"int"); g=0; if(tem[strlen(tok)+4]=='[') { array=1; for(z=strlen(tok)+5;tem[z]!=']';z++) row[g++]=tem[z]; row[g]='\0'; r=atoi(row); g=0; if(tem[z+1]=='[')

{ array=2; z+=2; while(tem[z]!=']') col[g++]=tem[z++]; col[g]='\0'; c=atoi(col);

} else c=1; s[k].size=r*c*2; } else s[k].size=2;

if(k!=0) s[k].address=s[k-1].address+s[k-1].size; if(array==1||array==2) { g=0; if(tem[z+1]=='=') { z+=2; while(tem[z-1]!='}') buff[g++]=tem[z++]; buff[g]='\0'; strcpy(s[k].value,buff); } else strcpy(s[k].value,"-"); }

else { tok=strtok(NULL," ,+[]=;()}{\n"); if(isdigit(tok[0]))

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Pt1420 Unit 6 Lab Report

    • 288 Words
    • 2 Pages

    Step 6 : Break the input string into square matrices of maximum possible size of…

    • 288 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    cout << num1 << " * " << num2 << " = " << num1*num2;…

    • 426 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    NT1210 Lab 1

    • 30 Words
    • 1 Page

    NT1210 Lab 1.3 Caleb Waldemar 12/9/2014 Exercise 1.3.1 Byte 1=25, Byte 2= 233 Exercise 1.3.2 Byte 1 and 2= 6633 Exercise 1.3.3 120 MB= 125829120 Bytes Exercise 1.3.4 16GB and word size of 32 bits. Number of words= 536870912 Exercise 1.3.5 Binary 110110^ 2= Hexadecimal 36 Exercise 1.3.6…

    • 30 Words
    • 1 Page
    Satisfactory Essays
  • Powerful Essays

    System.out.println("i = " + i + " f = " + f + " d = " + d);…

    • 2338 Words
    • 10 Pages
    Powerful Essays
  • Good Essays

    letter → A | B | C | … | Z | a | b | … | z…

    • 703 Words
    • 3 Pages
    Good Essays
  • Better Essays

    = endbck) stbck = NULL; else stbck = stbck->nxt; delete np;…

    • 401 Words
    • 2 Pages
    Better Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    5.Write a program to enter a lower case letter and on the next line display another message with the letter in uppercase. Page: 76(Done)…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Nt1310 Unit 3 Assignment

    • 256 Words
    • 2 Pages

    Write a program to input a string and separate words in it using String Tokenizer class.…

    • 256 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    In the AQA Memory Game, a grid of nine five-letter words is displayed to the user. They are arranged in rows and positioned randomly. After 30 seconds, the grid of words shown is replaced by an identical grid with the exception of one new word has been added and one word has been replaced by the original grid. The player needs to correctly guess the word that has been removed and the word that has been replaced, testing the player’s memory.…

    • 553 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Holistic care aims to take care of the whole person - not only the physical needs (i.e. pain what they are suffering from) of the patient but also their mental & emotional needs (i.e. afraid, not knowing what`s wrong), their social needs (i.e. worrying about money, bills, or how supporting family) and spiritual needs (i.e. feelings of anger or guilt).…

    • 520 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Chapter 6 solutions

    • 4145 Words
    • 41 Pages

    b. Modify the reverse-display program so that the user can enter up to 10 numbers…

    • 4145 Words
    • 41 Pages
    Good Essays
  • Powerful Essays

    Linked List Basics

    • 8040 Words
    • 33 Pages

    Abstract This document introduces the basic structures and techniques for building linked lists with a mixture of explanations, drawings, sample code, and exercises. The material is useful if you want to understand linked lists or if you want to see a realistic, applied example of pointer-intensive code. A separate document, Linked List Problems (http://cslibrary.stanford.edu/105/), presents 18 practice problems covering a wide range of difficulty. Linked lists are useful to study for two reasons. Most obviously, linked lists are a data structure which you may want to use in real programs. Seeing the strengths and weaknesses of linked lists will give you an appreciation of the some of the time, space, and code issues which are useful to thinking about any data structures in general. Somewhat less obviously, linked lists are great way to learn about pointers. In fact, you may never use a linked list in a real program, but you are certain to use lots of pointers. Linked list problems are a nice combination of algorithms and pointer manipulation. Traditionally, linked lists have been the domain where beginning programmers get the practice to really understand pointers. Audience The article assumes a basic understanding of programming and pointers. The article uses C syntax for its examples where necessary, but the explanations avoid C specifics as much as possible — really the discussion is oriented towards the important concepts of pointer manipulation and linked list algorithms. Other Resources • Link List Problems (http://cslibrary.stanford.edu/105/) Lots of linked list problems, with explanations, answers, and drawings. The "problems" article is a companion to this "explanation" article. • Pointers and Memory (http://cslibrary.stanford.edu/102/) Explains all about how pointers and memory work. You need some understanding of pointers and memory before you can understand linked lists. •…

    • 8040 Words
    • 33 Pages
    Powerful Essays
  • Good Essays

    The Last Ride Together

    • 666 Words
    • 3 Pages

    Write a program to input a start limit S (S>0) and the last limit L (L>0). Print all the prime triplets between S and L (both inclusive), if S<=L otherwise your program should ask to re-enter the values of S and L again with a suitable error message.…

    • 666 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    wf DF SG jj hkjsiytu jrt ey fgvzg g t hgjh arj u s e er…

    • 408 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    int function1(char x) { //parameter x passed to the function, function returns an integer value…

    • 1596 Words
    • 7 Pages
    Good Essays