LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices



Reply
 
Search this Thread
Old 02-25-2012, 02:59 PM   #1
hrishi_j
LQ Newbie
 
Registered: Aug 2011
Posts: 3

Rep: Reputation: Disabled
lex yacc programming


hey i just want to learn more about lex and yacc programming in ubuntu as my final year project is based on it
in that i have to detect for loop in c program which can be pass using lex and yacc tool of linux and then it will insert openmp pragmas in to that c programm so that the c program shuld be parallelly executed..
 
Old 02-25-2012, 03:10 PM   #2
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,139

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
lex and yacc are ineffective tools for real world problems.
When parsing a very clean grammar, they are a convenient resource. But the uglier the grammar the harder it is to contort lex and yacc to handle it.
It quickly becomes easier to just code a parser in a general purpose language than to kludge the problem spots into lex and yacc.

In a typical academic project involving lex/yacc you get to define the target language, so lex and yacc show their one true value: If you are designing the language and the parser at the same time and you have trouble using lex and yacc, it likely means you are making poor choices in language design and use of lex an yacc may push you to better language design. But if someone else already designed the language, the language design choices that turn lex and yacc into a giant problem have already been made.

I think ANTLR is far better than lex/yacc. But that doesn't necessarily mean I recommend ANTLR. Having used lex/yacc, and ANTLR and simply coding a parser in C++ without any parser specific tools, I have always found that the last of those choices yields the least long term difficulty. ANTLR or lex/yacc may save a lot of boring work on the easy parts of the language. But as you dig into the hard parts of the language you are supporting, you over pay wildly for that initial benefit.

Quote:
Originally Posted by hrishi_j View Post
detect for loop in c program
C is a very ugly language in formal language terms. Parsing C in lex/yacc is an exercise in futility. I wouldn't be surprised if someone has done it. I've seen (and even been forced to work on) projects in which an impossible for lex/yacc language is parsed with lex/yacc by burying unreasonable kludges in the C actions (and usually by failing to find and fix a bunch of problem cases that even the kludges won't cover).

Superficially, it may appear that recognizing for loops is a much smaller problem than parsing the whole language. But most ways of taking advantage of that smaller size lead to designs that can be tricked. An academic project may allow work that is only mostly correct. But in my opinion a more practical project that can be done correctly is a better exercise.

Quote:
Originally Posted by hrishi_j View Post
then it will insert openmp pragmas in to that c programm so that the c program shuld be parallelly executed..
WHAT???
I assume you do not mean it will automatically detect loops for which an openmp pragma could be added without corrupting the answer. That would be impossible to do accurately.
Do you mean adding openmp pragma even in places where doing so would cause the program to crash (once compiled and run with openmp support)?

Last edited by johnsfine; 02-25-2012 at 03:28 PM.
 
Old 03-01-2012, 12:00 AM   #3
hrishi_j
LQ Newbie
 
Registered: Aug 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
thanks sir for suggesting ANTLR....before ur reply i really dnt knoew abt ANTLR...but noe i think it is good tool rather using lex yacc for parsing
 
Old 03-02-2012, 12:52 PM   #4
hrishi_j
LQ Newbie
 
Registered: Aug 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
can anyone tell me how to install gtk on ubuntu 11.04?
i have install it ie (libgtk-3-dev) using synaptic package manager but after executing the code
it gives an error msg as follows:
fatal error:gtk/gtk.h no such file or directory
 
Old 03-02-2012, 01:09 PM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,272

Rep: Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663Reputation: 2663
GTK2 : package name = libgtk2.0-dev


Using gtk2, example ..
gcc -Wall -g infile.c -o outfile `pkg-config --cflags gtk+-2.0` \
`pkg-config --libs gtk+-2.0`


Gtk2, gtk3 :
/usr/include/gtk-2.0/gtk/file.h
/usr/include/gtk-3.0/gtk/file.h

.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
lex and yacc aarsh Linux - Software 3 01-03-2011 09:58 AM
LEX and YACC with C gr33ndata Programming 4 11-18-2007 06:12 PM
lex and yacc tools ? vagrahb Programming 4 05-19-2006 02:38 PM
Lex & yacc programming in windows. hemanexp Linux - Software 1 01-09-2004 06:41 AM
Lex & yacc Programming in linux. hemanexp Linux - Software 2 01-07-2004 12:09 PM


All times are GMT -5. The time now is 09:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration