The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Lexical Analyser using Lex/Flex
Discuss Lexical Analyser using Lex/Flex in the C Programming forum on Dev Shed. Lexical Analyser using Lex/Flex C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 10th, 2012, 03:14 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 10
Time spent in forums: 2 h 27 m 19 sec
Reputation Power: 0
|
|
|
Lexical Analyser using Lex/Flex
hello everyone
i need help from you
i want a Program to create Lexical Analyser for C Programming Language using Lex/Flex
thanks to you all 
|

December 10th, 2012, 03:47 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Code:
flex -P _my_prefix_ my_lex_file.l
What you put in my_lex_file.l depends on your requirements, which you haven't specified in your post.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

December 10th, 2012, 04:49 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 10
Time spent in forums: 2 h 27 m 19 sec
Reputation Power: 0
|
|
|
i mean write a program using lex language that analyse a c programm and test every character and show its type if it is a digit or alpha or keyword like if or while or .... or special character i hope you understand what i meann... thanks for replying
|

December 11th, 2012, 12:10 AM
|
 |
Contributed User
|
|
|
|
|

December 11th, 2012, 06:53 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 10
Time spent in forums: 2 h 27 m 19 sec
Reputation Power: 0
|
|
thanks,it's not what i really mean but it helps me a lot .thanks again 
|

December 11th, 2012, 09:33 AM
|
 |
Contributing User
|
|
|
|
|
beginnings of a php parser.
Attached is an (incomplete) php parser I just wrote (36 hours, including sleep.) It builds a parse tree and evaluates it. Handles integer variables, expressions, echo, if, string concatenation and some common operators. Not completely tested. Leaks memory. I'm not a php expert (not even a novice, I should say). (I DO know more about php than I knew last week.) The code sufficiently meets the rules of the task I was assigned.
Code:
109 253 1814 z.y (I used z.y to work out syntax tree execution.)
19 77 543 00README.txt
22 30 313 a.php
61 174 1542 dictionary.c
6 6 45 ex1.html
6 6 45 ex1.php
9 10 66 ex2.html
9 13 83 ex2.php
9 10 62 ex3.html
9 13 79 ex3.php
9 10 76 ex4.html
11 13 93 ex4.php
12 13 92 ex5.php
16 18 173 example1.php
21 24 266 example2.php
73 206 1510 php2html.lex
381 1252 9159 php2html.y
27 70 374 test.sh
21 42 353 tree.h
830 2240 16688 total
__________________
[code] Code tags[/code] are essential for python code!
|

December 11th, 2012, 03:46 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 10
Time spent in forums: 2 h 27 m 19 sec
Reputation Power: 0
|
|
i found this one ...and this is what i mean thanks to everyone
letter [a-zA-Z]
digit[0-9]
%%
{digit}+("E"("+"|"-")?{digit}+)? printf("\n%s\tis real number",yytext);
{digit}+"."{digit}+("E"("+"|"-")?{digit}+)? printf("\n%s\t is floating pt no ",yytext);
"if"|"else"|"int"|"char"|"scanf"|"printf"|"switch"|"return"|"struct"|"do"|"while"|"void"|"for"|"float" printf("\n%s\t is keywords",yytext);
"\a"|"\\n"|"\\b"|"\t"|"\\t"|"\b"|"\\a" printf("\n%s\tis Escape sequences",yytext);
{letter}({letter}|{digit})* printf("\n%s\tis identifier",yytext);
"&&"|"<"|">"|"<="|">="|"="|"+"|"-"|"?"|"*"|"/"|"%"|"&"|"||" printf("\n%s\toperator ",yytext);
"{"|"}"|"["|"]"|"("|")"|"#"|"'"|"."|"\""|"\\"|";"|"," printf("\n%s\t is a special character",yytext);
"%d"|"%s"|"%c"|"%f"|"%e" printf("\n%s\tis a format specifier",yytext);
%%
int yywrap()
{
return 1;
}
int main(int argc,char *argv[])
{
yyin=fopen(argv[1],"r");
yylex();
fclose(yyin);
return 0;
}
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|