OneStopGate.Com
OnestopGate   OnestopGate
   Monday, December 23, 2024 Login  
OnestopGate
Home | Overview | Syllabus | Tutorials | FAQs | Downloads | Recommended Websites | Advertise | Payments | Contact Us | Forum
OneStopGate

GATE Resources
Gate Articles
Gate Books
Gate Colleges 
Gate Downloads 
Gate Faqs
Gate Jobs
Gate News 
Gate Sample Papers
Training Institutes

GATE Overview
Overview
GATE Eligibility
Structure Of GATE
GATE Coaching Centers
Colleges Providing M.Tech/M.E.
GATE Score
GATE Results
PG with Scholarships
Article On GATE
Admission Process For M.Tech/ MCP-PhD
GATE Topper 2012-13
GATE Forum




GATE 2025 Exclusive
Organizing Institute
Important Dates
How to Apply
Discipline Codes
GATE 2025 Exam Structure

GATE 2025 Syllabus
Aerospace Engg..
Agricultural Engg..
Architecture and Planning
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Geology and Geophysics
Instrumentation Engineering
Life Sciences
Mathematics
Mechanical Engg..
Metallurgical Engg..
Mining Engg..
Physics
Production & Industrial Engg..
Pharmaceutical Sciences
Textile Engineering and Fibre Science

GATE Study Material
Aerospace Engg..
Agricultural Engg..
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Instrumentation Engg..
Life Sciences
Mathematics
Mechanical Engg..
Physics
Pharmaceutical Sciences
Textile Engineering  and Fibre Science

GATE Preparation
GATE Pattern
GATE Tips N Tricks
Compare Evaluation
Sample Papers 
Gate Downloads 
Experts View

CEED 2013
CEED Exams
Eligibility
Application Forms
Important Dates
Contact Address
Examination Centres
CEED Sample Papers

Discuss GATE
GATE Forum
Exam Cities
Contact Details
Bank Details

Miscellaneous
Advertisment
Contact Us


Home » GATE Study Material » Computer Science » Compiler Design

Compiler Design

Looking for GATE Preparation Material? Join & Get here now!

** Gate 2013 Question Papers.. ** CEED 2013 Results.. ** Gate 2013 Question Papers With Solutions.. ** GATE 2013 CUT-OFFs.. ** GATE 2013 Results.. **

<<Previous Next>>
Overview Of Module And Algorithm Continue...




Contd...
			   
			   if symb=�=�

                                    print symb is a relational operator

                           else

                                   ungetc symb from output file

                                   print symb is a operator

          end{if}

          if symb=�=�

       begin

                   advance to next token in input file

                           if symb=�=�then

                                    print symb is  equal to operator

               else

                                     ungetc symb from output file

             print symb is assignment operator

end{if}

if symb=�&� then

begin

                             advance to next token in input file

                             if symb=�&� then

                                       print symb is a logical and operator

                    else

                                      print & symb is an address operator

end{if}

if symb=�/� then

begin

                             advance to next token in input file

                             if symb=�*� then

                             begin

                                      advance to next token in input file

                                      while symb!=�/� do

                                                advance to next token in input file

                                      end{while}

                             end{if}

                             else if symb=�/� then

                   begin

                                      advance to next token in input file

                                      while symb!=�\n� do

                                                advance to next token in input file

                                      end{while}

                            end{if}

                             else

                                      ungetc symb from output file

                                      print symb is a division operator

end{if}

if symb is a digit then

            begin

                   advance to next token in input file

                   while symb is a digit or symb=�.� then

                   begin

                             advance to next token in input file

                    end {while}

                    print symb is a number

          end{if}

          if symb =��� then

          begin

                   advance to next token in input file  

                   while symb!=��� do

                   begin

                             advance to next token in input file

                   end{while}

                   print symb is a string

          end{if}}

          if symb= �{� then

                   print open brace

          if symb=�}� then

                   print close brace

          if symb=�[� then

                   print  open bracket

          if symb=�]� then

                   print close bracket

          if symb=�(� then

                   print open parenthesis

          if symb=�)� then

                   print close parenthesis

end {procedure main}

procedure verify

begin

        scan the symbol table to check if encountered token exists

        if exists

            return token value

end{procedure}

USER MANUAL

The code for modules appears in two files: lex.c and output.c. The file lex.c contains the main source code of the lexical analyzer. And the input to the lexical analyzer is contained in test.c. Under the DOS operating system, the program is compiled by using alt F9, and is executed by using ctrl F9. The output i.e token types are stored in the output file, output.txt

Sample Input


#include<stdio.h>

#include<stdlib.h>

#define abc 100

void main()

{

          int a_,b=30;

          printf("enter 2 no.s\n"); // printf statement

          scanf("%d%d",&a,&b); 

         /* scanf

          statement*/

          if(a<20)

          a=a+1;

}

 Sample Output:
 
LINE NO                TOKENS
-----------------------------------------------

    1:          #include<stdio.h> is a header file

    2:          #include<stdlib.h> is a header file

    3:          #define statement: abc is a constant

    4:          void: token value : 7

                main :identifier, token value : 18

                (: open parenthesis

                ): close parenthesis

    5:          {: open brace

    6:          int: token value : 1

                a_ :identifier, token value : 18

                , : comma

                b :identifier, token value : 18

                =: assignment operator

                30 is a number

                ; : semi colon

    7:         printf: token value : 5

                (: open parenthesis

                enter 2 no.s\n : is a string

                ): close parenthesis

                ;: semi colon

    8:         scanf: token value : 6

                (: open parenthesis

               %d%d : is a string

                ,: comma

               &a: address operator

                , : comma

                &b: address operator

                 ): close parenthesis

                ;: semi colon

    9:

    10:

    11:        if: token value : 8

                (: open parenthesis

                a :identifier, token value : 18

                <: less than operator

                20 is a number

                ): close parenthesis

    12:        a: token value : 18

                =: assignment operator

                a: token value : 18

                +: plus operator

                1 is a number

                ;: semi colon

    13:        }: close parenthesis
	

CONCLUSION

Generally, when syntactic analysis is being carried out by the parser it may call upon the scanner for tokenizing the input. But the LEXICAL ANALYZER designed by us is an independent program. It takes as input a file with an executable code in C. There fore, the parser cannot make use of the designed scanner as and when required.

Consider as an example an array ch[20].The designed lexical analyzer will tokenize 'ch' as an identifier,'[' as an opening brace,'20' as a number, and ']' as a closing brace. But the parser might require a[5] to be identified as an array. Similarly, there may arise a number of cases where the parser has to identify a token by a different mannerism than the one specified and designed. Hence, we conclude that the LEXICAL ANALYZER so designed is an independent program which is not flexible.

<<Previous Next>>



Discussion Center

Discuss/
Query

Papers/
Syllabus

Feedback/
Suggestion

Yahoo
Groups

Sirfdosti
Groups

Contact
Us

MEMBERS LOGIN
  
Email ID:
Password:

  Forgot Password?
 New User? Register!

INTERVIEW EBOOK
Get 9,000+ Interview Questions & Answers in an eBook. Interview Question & Answer Guide
  • 9,000+ Interview Questions
  • All Questions Answered
  • 5 FREE Bonuses
  • Free Upgrades
GATE RESOURCES
 
  • Gate Books
  • Training Institutes
  • Gate FAQs
  • GATE BOOKS
     
  • Mechanical Engineeering Books
  • Robotics Automations Engineering Books
  • Civil Engineering Books
  • Chemical Engineering Books
  • Environmental Engineering Books
  • Electrical Engineering Books
  • Electronics Engineering Books
  • Information Technology Books
  • Software Engineering Books
  • GATE Preparation Books
  • Exciting Offers



    GATE Exam, Gate 2009, Gate Papers, Gate Preparation & Related Pages


    GATE Overview | GATE Eligibility | Structure Of GATE | GATE Training Institutes | Colleges Providing M.Tech/M.E. | GATE Score | GATE Results | PG with Scholarships | Article On GATE | GATE Forum | GATE 2009 Exclusive | GATE 2009 Syllabus | GATE Organizing Institute | Important Dates for GATE Exam | How to Apply for GATE | Discipline / Branch Codes | GATE Syllabus for Aerospace Engineering | GATE Syllabus for Agricultural Engineering | GATE Syllabus for Architecture and Planning | GATE Syllabus for Chemical Engineering | GATE Syllabus for Chemistry | GATE Syllabus for Civil Engineering | GATE Syllabus for Computer Science / IT | GATE Syllabus for Electronics and Communication Engineering | GATE Syllabus for Engineering Sciences | GATE Syllabus for Geology and Geophysics | GATE Syllabus for Instrumentation Engineering | GATE Syllabus for Life Sciences | GATE Syllabus for Mathematics | GATE Syllabus for Mechanical Engineering | GATE Syllabus for Metallurgical Engineering | GATE Syllabus for Mining Engineering | GATE Syllabus for Physics | GATE Syllabus for Production and Industrial Engineering | GATE Syllabus for Pharmaceutical Sciences | GATE Syllabus for Textile Engineering and Fibre Science | GATE Preparation | GATE Pattern | GATE Tips & Tricks | GATE Compare Evaluation | GATE Sample Papers | GATE Downloads | Experts View on GATE | CEED 2009 | CEED 2009 Exam | Eligibility for CEED Exam | Application forms of CEED Exam | Important Dates of CEED Exam | Contact Address for CEED Exam | CEED Examination Centres | CEED Sample Papers | Discuss GATE | GATE Forum of OneStopGATE.com | GATE Exam Cities | Contact Details for GATE | Bank Details for GATE | GATE Miscellaneous Info | GATE FAQs | Advertisement on GATE | Contact Us on OneStopGATE |
    Copyright © 2024. One Stop Gate.com. All rights reserved Testimonials |Link To Us |Sitemap |Privacy Policy | Terms and Conditions|About Us
    Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | India Job Forum | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Free Classifieds | Jobs Assist | Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Web Hosting | Quick Site Kit | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Software Testing Interview Questions | Free Online Exams | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World
    C Interview Questions | C++ Interview Questions | Send Free SMS | Placement Papers | SMS Jokes | Cool Forwards | Romantic Shayari