lex - int bcount=0; char

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Description :  A simulated lexical analyser for HLL like C,PASCAL etc. I have given a sample text file  from which the source code reads the dummy program n analyses it. The program can be extended by  adding more. /* LEX.cpp */ /*PROGRAM TO IMPLEMENT LEXICAL ANALYSER ON C AS A LANGUAUGE */ # include <iostream.h> # include <conio.h> # include <fstream.h> # include <ctype.h> //header files # include <dos.h> # include <stdlib.h> # include <stdio.h> # include <string.h> # define MAX 50 # define ERROR 0 # define ID 1 # define KEY 2 # define DELIM 3 # define OP 4 //constant declarations # define DATA_TYPE 0 # define OPER 2 # define KWORD 4 # define RTYPE 5 # define NUM 6
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int bcount=0; char *msg={&quot;error!!&quot;,&quot;id&quot;,&quot;key&quot;,&quot;delim&quot;,&quot;oprtr&quot;,&quot;num&quot;},token[MAX][MAX],lex[MA X][MAX],attr[MAX][MAX]; char *msg2={&quot;data type&quot;,&quot;identifier&quot;,&quot;operator&quot;,&quot;special character&quot;,&quot;keyword&quot;,&quot;return type&quot;,&quot;number&quot;}; char buff[MAX],spl={' ',',',';',' ','(',')','{','}'}; char *data={&quot;int&quot;,&quot;char&quot;,&quot;float&quot;,&quot;long&quot;,&quot;unsigned&quot;,&quot;void&quot;}; char oper={'+','-','*','/','%','=','|','^','&lt;','&gt;','&lt;=','&gt;=','&lt;&gt;'}; char keys[4][10]={{&quot;begin&quot;},{&quot;end&quot;},{&quot;start&quot;},{&quot;int&quot;}},row[2],col[2]; /********************FUNCTIONS************************/ void display(int symcount); //display function for symbol table int flush_buff(char buff[MAX]) { for(int i=0;buff[i]!='...
View Full Document

Page1 / 2

lex - int bcount=0; char

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online