Lexical

100 %
0 %
Information about Lexical
Software

Published on October 12, 2014

Author: ShubhamShah001

Source: slideshare.net

Description

Lexical Analysis

1. Seminar on LEXICAL PROGRAM Presented by- Sonali Sulgadle Shrushti Swami Vijaylaxmi Yemul KajalWaghmare

2. An overview of Lex Lex is a program generator designed for lexical processing of character input streams. +-------+ Source -> | Lex | -> yylex +-------+ +-------+ Input -> | yylex | -> Output +-------+

3. OVERVIEW lexical grammar rules rules | | v v +---------+ +---------+ | Lex | | Yacc | +---------+ +---------+ | | v v +---------+ +---------+ Input -> | yylex | >| yyparse| -> Parsed input +---------+ +---------+

4. Parser generator: – Takes a specification for a context-free grammar. – Produces code for a parser. 4 Yacc: Overview Input: a set of grammar rules and actions Output: C code implementing a parser: function: yyparse() file [default]: y.tab.c yacc

5. Lex Source. The general format of Lex source is: {definitions} %% {rules} %% {user subroutines} where the definitions and the user subroutines are often omitted. The second %% is optional, but the first is required to mark the beginning of the rules. The absolute minimum Lex program is thus %%which translates into a program which copies the input to the output unchanged.

6. Lex Source. . Thus an individual rule might appear integer printf("found keyword INT"); As a slightly more useful example, suppose it is desired to change a number of words from British to American spelling. Lex rules such as colour printf("color"); mechanise printf("mechanize"); petrol printf("gas");

7. Special Functions 7 yytext where text matched mst recently is stored yyleng number of characters in text most recently matched yylval associated value of current token yymore() append next string matched to current contents of yytext yyless(n) remove from yytext all but the first n characters unput(c) return character c to input stream yywrap() may be replaced by user The yywrap method is called by the lexical analyser whenever it inputs an EOF as the first character when trying to match a regular expression

8. Program %{ #include<stdio.h> //#include"y.tab.h" int num_lines=0; %} label [a-z][a-z 0-9 _]* number[0-9]+ %%

9. n++num_lines; char printf("n Keyword=Char n"); double printf("n Keyword=Doublen"); int printf("n Keyword=Intn"); float printf("n Keyword=Floatn"); for printf("n Keyword=For n"); if printf("n Keyword=Ifn"); else printf("n Keyword=Elsen"); while printf("n Keyword=Whilen"); exit printf("n Keyword=Exitn"); auto printf("n Keyword auton"); switch printf("n Keyword switch");

10. continue printf("n keyword=continue n"); "{"printf("nOpen brace"); "+""|""-""|""*""|""/""|""%" printf("n Arithmetic Operators"); " " printf("n Blank spaces n"); "++" printf("Increment Operator"); "--" printf("Decrement Operator"); {label} printf("n Labeln"); {number} printf("n Numbern"); "==""|"">=""|""<=""|"">""|""<" printf("n Conditional operatorn");

11. "=" printf("nAssignment operatorn"); %% main() { yylex(); printf("# of lines is %d",num_lines); yywrap(); } int yywrap() { return 0 }

12. THANK YOU…….

Add a comment

Related presentations

Speaker: Matt Stine Developing for the Cloud Track Marc Andressen has famou...

This presentation explains how to develop a Web API in Java using (JAX-RS or Restl...

1 App,

1 App,

November 10, 2014

How to bring innovation to your organization by streamlining the deployment proces...

Cisco Call-control solutions can handle voice, video and data

Nathan Sharp of Siemens Energy recently spoke at the SAP Project Management in Atl...

Related pages

dict.cc | lexical | Wörterbuch Englisch-Deutsch

Übersetzung für lexical im Englisch-Deutsch-Wörterbuch dict.cc.
Read more

Lexical - Wikipedia

The adjective lexical refers to things concerning the words or lexicon of a language. Linguistics, the study of language, often uses lexical concepts.
Read more

Lexical | Definition of Lexical by Merriam-Webster

Seen and Heard. What made you want to look up lexical? Please tell us where you read or heard it (including the quote, if possible).
Read more

Lexical Word Finder - Scrabble and Words With Friends Cheat

Calculates the highest scoring word to play at the highest scoring position on the board.
Read more

dict.cc Wörterbuch :: lexical :: Deutsch-Englisch-Übersetzung

Englisch-Deutsch-Übersetzung für lexical im Online-Wörterbuch dict.cc (Deutschwörterbuch).
Read more

Lexical analysis - Wikipedia

In computer science, lexical analysis is the process of converting a sequence of characters (such as in a computer program or web page) into a sequence of ...
Read more

Lexical | Define Lexical at Dictionary.com

Lexical definition, of or relating to the words or vocabulary of a language, especially as distinguished from its grammatical and syntactical aspects. See ...
Read more

Lexical - definition of lexical by The Free Dictionary

And here Manser offers a guided tour of English, exploring the origins of words, their changing meaning, lexical peculiarities, word games and lost words.
Read more

What are lexical sets? - uni-due.de

A lexical set consists of a group of words all of which have the same pronunciation for a certain sound in a given variety. For instance, the lexical set ...
Read more

Lexica - definition of lexica by The Free Dictionary

Define lexica. lexica synonyms, lexica pronunciation, lexica translation, ... lexica; lexical; lexical ambiguity; lexical database; lexical decision task;
Read more