473,799 Members | 3,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

give me some tips

"No newline at the end of your output" is really a problem? I've never
learned that before.
So I desire to know some tips about writting a program perfectly.Can
anyone give me some tips which are hardly learned from textbook or
easily ignored?
Thank you very much.

Mar 12 '06
28 3335

"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...

Essentially, whatever you can learn from the Dragon Book or
Muchnick's book.

Found them. Thanks again.

Dragon Book:
"Compilers: Principles, Techniques and Tools" Alfred V. Aho, Ravi Sethi,
Jeffrey D. Ullman
"Advanced Compiler Design and Implementation" by Steven S. Muchnick

RP
Mar 12 '06 #21
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47***** *******@individ ual.net...


Essentially , whatever you can learn from the Dragon Book or
Muchnick's book.


Found them. Thanks again.

Dragon Book:
"Compilers: Principles, Techniques and Tools" Alfred V. Aho, Ravi Sethi,
Jeffrey D. Ullman
"Advanced Compiler Design and Implementation" by Steven S. Muchnick


Note that the Dragon Book nowadays is quite outdated; IIRC,
there is a "21st Century Compilers" (or similar) book under way
or even out by much the same authors.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 12 '06 #22
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47***** *******@individ ual.net...

Apart from that: Have a look at graph theory; there is much nice
stuff on the web and, as discrete maths goes, it is a fun subject
as you can state really deep problems on a sheet of paper within
five minutes so that everyone understands the problem but the
proof took a hundred years to be found and conversely can prove
things in an easily understandable way. If you understand graph
theory and get an intermediate representation of some code, you
are ready to do general (not target specific) optimisations.


Hmm, graph theory. I'll _definately_ have a look at this. It'll probably
be a big time saver for me since my spatial relationship abilities are
(supposedly) off the charts.


I am not quite sure whether I understand this remark.
We are both talking about
http://en.wikipedia.org/wiki/Graph_theory ,
aren't we?
I am not actually writing a traditional compiler but am involved
in the optimisation of an intermediate representation of code;
the output of the product is C.
More about that only via PM and only as far as I am allowed to
tell about it.


Well, you don't have to talk about that. I'm sure you've looked at other
stuff like:

GCC's RTL
TenDRA's ANDF


This one's new to me.
LCC's DAGs
Necula's CIL

So far, the only "C" compiler I've found that uses both a yacc and lex
grammar is Lutz Hamel's "C Subset Compiler" WCC for VMS.


Hmmm, as resources go, you probably know
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 12 '06 #23

"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47***** *******@individ ual.net...
Apart from that: Have a look at graph theory; there is much nice
stuff on the web and, as discrete maths goes, it is a fun subject
as you can state really deep problems on a sheet of paper within
five minutes so that everyone understands the problem but the
proof took a hundred years to be found and conversely can prove
things in an easily understandable way. If you understand graph
theory and get an intermediate representation of some code, you
are ready to do general (not target specific) optimisations.


Hmm, graph theory. I'll _definately_ have a look at this. It'll probably
be a big time saver for me since my spatial relationship abilities are
(supposedly) off the charts.


I am not quite sure whether I understand this remark.
We are both talking about
http://en.wikipedia.org/wiki/Graph_theory ,
aren't we?


You were. I wasn't... But, I just went through a number of graph theory
pages. I'm not sure exactly where I can use it in a compiler (yet). In
other words, binary trees, stacks, and reverse polish notation seem to do
everything I'm thinking of at the moment... Maybe I'll get it in the
future. Since I was just skimming, I didn't get to heavily into the
mathematics of graph theory.
I am not actually writing a traditional compiler but am involved
in the optimisation of an intermediate representation of code;
the output of the product is C.
More about that only via PM and only as far as I am allowed to
tell about it.


Well, you don't have to talk about that. I'm sure you've looked at other stuff like:

GCC's RTL
TenDRA's ANDF


This one's new to me.


Darn. I couldn't get a version for my OS, and was hoping someone had some
familiarity with ANDF...
http://www.info.uni-karlsruhe.de/~andf/index.htm

The TenDRA C and C++ compiler has two branches:
http://www.ten15.org/
http://www.tendra.org/
LCC's DAGs
Necula's CIL

So far, the only "C" compiler I've found that uses both a yacc and lex
grammar is Lutz Hamel's "C Subset Compiler" WCC for VMS.


Hmmm, as resources go, you probably know
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html


Yes, I've updated for myself, both his flex and bison grammar's to C99.

Are you aware of Edward Willink's C++ grammars:
http://www.computing.surrey.ac.uk/research/dsrg/fog/

Unfortunately, some of his links are incorrect, extra /v/. These are
corrected:
CxxGrammar.y
http://www.computing.surrey.ac.uk/re...g/CxxGrammar.y
CxxTester.y http://www.computing.surrey.ac.uk/re...og/CxxTester.y
FogGrammar.y
http://www.computing.surrey.ac.uk/re...g/FogGrammar.y
FogTester.y http://www.computing.surrey.ac.uk/re...og/FogTester.y
Rod Pemberton
Mar 12 '06 #24
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47***** *******@individ ual.net...
Rod Pemberton schrieb:
>"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
>news:47*** *********@indiv idual.net...

Apart from that: Have a look at graph theory; there is much nice
stuff on the web and, as discrete maths goes, it is a fun subject
as you can state really deep problems on a sheet of paper within
five minutes so that everyone understands the problem but the
proof took a hundred years to be found and conversely can prove
things in an easily understandable way. If you understand graph
theory and get an intermediate representation of some code, you
are ready to do general (not target specific) optimisations.

Hmm, graph theory. I'll _definately_ have a look at this. It'll
probably
be a big time saver for me since my spatial relationship abilities are
(supposedl y) off the charts.
I am not quite sure whether I understand this remark.
We are both talking about
http://en.wikipedia.org/wiki/Graph_theory ,
aren't we?


You were. I wasn't... But, I just went through a number of graph theory
pages. I'm not sure exactly where I can use it in a compiler (yet). In
other words, binary trees, stacks, and reverse polish notation seem to do
everything I'm thinking of at the moment... Maybe I'll get it in the
future. Since I was just skimming, I didn't get to heavily into the
mathematics of graph theory.


Okay, let us keep this basic.
If you introduce an intermediate representation, it is often
advantageous to introduce a graph with certain properties,
e.g. a tree; if you compile on a translation unit by translation
unit base, then you could make an abstract translation unit
the base of your tree and everything stored in file scope the
first level nodes. Then you descend, into functions, declarations,
statements, operations...
For intraprocedural analysis, you can build a hypergraph on top
of this tree representing your control flow, e.g. you can use
an SSA form for constant propagation, constant folding,
control flow optimisation, copy propagation, scope reduction, ...
The tree gives you the chance to navigate scopes (just stay on
one level).
Recognition of certain patterns as detection of certain kinds
of induced subgraphs can be much easier.
One key to success is an appropriate intermediate representation;
here is one point where intellectual property can rest.
TenDRA's ANDF


This one's new to me.


Darn. I couldn't get a version for my OS, and was hoping someone had some
familiarity with ANDF...
http://www.info.uni-karlsruhe.de/~andf/index.htm

The TenDRA C and C++ compiler has two branches:
http://www.ten15.org/
http://www.tendra.org/


Anyway, thank you for the information :-)
LCC's DAGs
Necula's CIL

So far, the only "C" compiler I've found that uses both a yacc and lex
grammar is Lutz Hamel's "C Subset Compiler" WCC for VMS.


Hmmm, as resources go, you probably know
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html


Yes, I've updated for myself, both his flex and bison grammar's to C99.


Would you put that up on the clc wiki?
BTW: We made it back on topic ;-)
Are you aware of Edward Willink's C++ grammars:
http://www.computing.surrey.ac.uk/research/dsrg/fog/

Unfortunately, some of his links are incorrect, extra /v/. These are
corrected:
CxxGrammar.y
http://www.computing.surrey.ac.uk/re...g/CxxGrammar.y
CxxTester.y http://www.computing.surrey.ac.uk/re...og/CxxTester.y
FogGrammar.y
http://www.computing.surrey.ac.uk/re...g/FogGrammar.y
FogTester.y http://www.computing.surrey.ac.uk/re...og/FogTester.y


I will check these out, too.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 12 '06 #25
On 2006-03-12, Michael Mair <Mi**********@i nvalid.invalid> wrote:
Rod Pemberton schrieb:
So far, the only "C" compiler I've found that uses both a yacc and lex
grammar is Lutz Hamel's "C Subset Compiler" WCC for VMS.

Why would anyone use lex? Handwritten lexers for C and C-ish languages
are cleaner, more maintainable, and perhaps faster. And they're quite
readily written in standard C.
Hmmm, as resources go, you probably know
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html


Is there a license to go with that?

--
- David A. Holland
(the above address works if unscrambled but isn't checked often)
Mar 13 '06 #26
>"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******* *****@individua l.net...
I am not actually writing a traditional compiler but am involved
in the optimisation of an intermediate representation of code;
the output of the product is C. ...

In article <dv***********@ news3.infoave.n et>
Rod Pemberton <do*********@so rry.bitbuck.cmm > wrote:... I'm sure you've looked at other stuff like:

GCC's RTL
TenDRA's ANDF
LCC's DAGs
Necula's CIL

So far, the only "C" compiler I've found that uses both a yacc and lex
grammar is Lutz Hamel's "C Subset Compiler" WCC for VMS.


In reverse order: lex does not do grammars (it only does regular
expressions), and you would want flex rather than lex, or a hand-built
lexer, as original lex's C code was, um, "not so great". :-)

GCC uses a grammar written in bison, which is essentially the same
as yacc (with of course the inevitable GNU extensions). As of many
years ago it was possible to feed this into byacc, Bob Corbett's
"Berkeley YACC", at least with a few bells added (I added them, at
BSDI).

I have never looked at CIL nor LCC.

ANDF came out of the Open Software Foundation's attempt to come up
with an "Architectu re Neutral Distribution Format" (hence the
acronym). The goal was to be able to distribute the equivalent of
".o" (compiled object) files that were not compiled for any
*particular* machine, but rather would be fed into a "re-compiler"
that would turn them into appropriate machine-specific code and
link them together. Libraries would be either native (i.e., already
compiled for the target machine) or a collection of ANDF objects.
"Architectu re neutral" intermediate file formats were not a new
idea, but previous attempts had always been abandoned or surpassed
(or both), due to what I think are pretty obvious reasons. Note
that ANDF was supposed to be "source-language neutral" as well as
"target-machine neutral", and there really is no such thing: while
it is possible to wedge a number of different source languages into
one intermediate language -- GCC does this with its RTL -- one
invariably winds up with a "union of all source constructs"
intermediate system

GCC's RTL ("register transfer language") is an outgrowth of research
originally done at the University of Arizona (Chris Fraser and J.
Davidson, in the 1980s). GCC's RTL was rather Lispified, not
surprising since the original versions of GCC itself were done by
Richard Stallman. While doing some quick background checks in
order to write this paragraph, I learned that GCC 3 and/or 4 added
some new layers between the original syntax trees built by its
front-ends and the RTL system. (I have not done anything major
inside GCC since 2.95.x, so this is all new to me.) GCC now does
a number of optimizations using the Static Single Assignment model
(which has obvious advantages over attempting them in RTL; see
<http://gcc.gnu.org/onlinedocs/gccint/SSA.html> et seq.).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Mar 14 '06 #27
Chris Torek <no****@torek.n et> writes:
GCC uses a grammar written in bison, which is essentially the same
as yacc (with of course the inevitable GNU extensions).


This was true for a long time, but no longer. GCC 4.1.0,
released on 2006-02-28, replaces GCC's C parser by a "new, faster
hand-written recursive-descent parser", as you can see at:
http://gcc.gnu.org/gcc-4.1/changes.html
--
"Programmer s have the right to be ignorant of many details of your code
and still make reasonable changes."
--Kernighan and Plauger, _Software Tools_
Mar 14 '06 #28
>Chris Torek <no****@torek.n et> writes:
GCC uses a grammar written in bison, which is essentially the same
as yacc (with of course the inevitable GNU extensions).

In article <87************ @benpfaff.org>
Ben Pfaff <bl*@cs.stanfor d.edu> wrote:This was true for a long time, but no longer. GCC 4.1.0,
released on 2006-02-28, replaces GCC's C parser by a "new, faster
hand-written recursive-descent parser", as you can see at:
http://gcc.gnu.org/gcc-4.1/changes.html


Well, at least there is still a C parser. :-)

And (on-topic, more or less) I see at the bottom of that page:

Some built-in functions have been fortified to protect applications
from stack-smashing attacks. The protection is realized by
buffer overflow detection and reordering of stack variables
to avoid pointer corruption.

This could cause "interestin g" surprises with existing code that
makes use of undefined behavior. The web page gives no additional
details, though.

I also see that x86-64 uses multiple memory models, and attempts
to bypass Standard C by using "out-of-segment" memory references
may behave in ways that surprise programmers. Everything old is
new again. :-)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Mar 14 '06 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1865
by: arthur-e | last post by:
A new Machine was set up by our IS department - it came with Office Pro 2003. Access97, Word97 and Excel 97 were added. I'm trying to update an Access 97database to 2003 but get weird compiling errors - Date, Format and Left give errors. I've registered the missing (or those ocx's) that were indicated as missing- iincluding - mscomct2.ocx - and the date picker showed up but
7
2155
by: MLH | last post by:
?2944*24 gives me an overflow error, entered in the immediate window. Anybody else?
0
1045
by: mike | last post by:
Recently I posted a message about deploying an application over a network. I had the .net framework installed on the pcs, the local intranet set to full trust, and I had copied the bin directory to the production location. However, I didn't have any trouble running the program on any pcs that had visual studio 2003 installed on it. So, there was no problem with any development machines. However, some non-development machines would run the...
44
4198
by: Christoph Zwerschke | last post by:
In Python, it is possible to multiply a string with a number: >>> "hello"*3 'hellohellohello' However, you can't multiply a string with another string: >>> 'hello'*'world' Traceback (most recent call last): File "<interactive input>", line 1, in ?
2
1571
by: Lauren Wilson | last post by:
Hi Folks, We have a user who is suddenly getting the following error message when they start our very mature application. Other users of the same version are NOT getting this error: "Error 3075 - Function is not available in expressions in query expression 'Trim(!)' " I believe that this function comes from the DAO 3.6 library.
1
2105
by: Ellen12c | last post by:
On the last post I asked about a code to make a vertical scroll bar and ends up I didn't need one. I was told by a big group of people on this forum that I needed to do away with all the flash and the backgrounds to make the web site more conservative. I received post to let members know so they can go and give me tips and more help to make the web sit better. So I'm finished the new web site it took me 2 days to make it....
5
1222
by: Shanthagomathi | last post by:
can u pl give me some java1.5 tips which should be useful for projects..it can be general also Thanks
10
2152
by: sara | last post by:
Hi - I have a report that is 14 columnar sub-reports (Line up: Position- holders in each of our 14 locations - Manager, Assistant Manager, Receiving, Office, etc). I output directly to PDF (using ConvertReportToPDF from this site - Stephan Lebans) The formatting - Outlines on some fields - do not appear on subreports
0
1239
by: zzzmail.01 | last post by:
I find some useful tips about C/C++ and want to share with you. Sorry if it bothers you. Tips for better Coding Style: http://tmh-coding-tips.blogspot.com/2008/09/cc-guidelines-for-better-coding-style.html Tips for better Memory Management: http://tmh-coding-tips.blogspot.com/2008/09/cc-tips-for-better-memory-management.html Tips for Performance Enhancements
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.