473,785 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Without semicolons

Write a program that takes a C program in source form as input and
prints the source code for a program with equivalent behaviour, but
without semicolons, on standard output.

Please note that I'm not interested in the DMS Software Reengineering
Toolkit.

Jeremy.
Nov 14 '05 #1
27 2014
int main(int x, char *t[]){if(puts(t[1])){}}

compile to file 'a' and run this in your command line

a "the source goes here"
Nov 14 '05 #2
Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> writes:
Write a program that takes a C program in source form as input and
prints the source code for a program with equivalent behaviour, but
without semicolons, on standard output. Please note that I'm not interested in the DMS Software Reengineering
Toolkit.

Yes sir, I'll get on to writing this program straight away.
I'm not interested in the DMS Software Reengineering Toolkit, either.

Chris.
Nov 14 '05 #3
Chris McDonald wrote:
Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> writes:
Write a program that takes a C program in source form as input and
prints the source code for a program with equivalent behaviour, but
without semicolons, on standard output.

Please note that I'm not interested in the DMS Software Reengineering
Toolkit.


Yes sir, I'll get on to writing this program straight away.
I'm not interested in the DMS Software Reengineering Toolkit, either.


If you were to search the archives (or lurk for a while) in order to
establish some context, you might be less inclined to post such rude
(and absurd) responses.

Jeremy.
Nov 14 '05 #4
Martin Johansen wrote:
int main(int x, char *t[]){if(puts(t[1])){}}

compile to file 'a' and run this in your command line

a "the source goes here"


I have no idea why you think this is a solution.

Jeremy.
Nov 14 '05 #5
Jeremy Yallop wrote:
Write a program that takes a C program in source form as input and
prints the source code for a program with equivalent behaviour, but
without semicolons, on standard output.


There is one really serious problem with that, other than string
literals and character constants (and being a stupid idea in the
first place): declarations are terminated with a semi-colon.

--
++acr@,ka"
Nov 14 '05 #6
Sam Dennis wrote:
Jeremy Yallop wrote:
Write a program that takes a C program in source form as input and
prints the source code for a program with equivalent behaviour, but
without semicolons, on standard output.


There is one really serious problem with that, other than string
literals and character constants (and being a stupid idea in the
first place): declarations are terminated with a semi-colon.


String literals and character constants are not a problem if you don't
mind restricting yourself to a particular character set. Declarations
are admittedly rather difficult to handle, but by no means impossible.
Here are a couple of clues:

int foo()
{
int x = 3;
float y = 2.0;
...
return something;
}

can be transformed to

void foo_helper(int x, float y, int *rv)
{
...
if (*rv = something) { }
}

void foo(int *rv)
{
if (foo_helper(3, 2.0, rv)) { }
}

It might appear that a (non-definition) declaration is required for at
least one of two mutually recursive functions, but that's not the
case:

void one()
{
if (((void (*)())two)(), 0) { }
}

void two()
{
if (one(), 0) { }
}

I'm pretty sure that it can be done, although I welcome
counterexamples . I'm sorry that you thought the problem was stupid; I
thought it was considerably more interesting than the usual "without
using a semicolon" sort of questions that come up fairly frequently,
and (if solved) it has the additional advantage of making it
unnecessary to ever have to think of answers to those questions again.

I think that a program I'm working on now will be able to solve the
problem (and many others) when finished, by the way, but it's not
written in C and it won't be ready for a couple of months at least.

Jeremy.
Nov 14 '05 #7
Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> writes:
Chris McDonald wrote:
Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> writes:
Write a program that takes a C program in source form as input and
prints the source code for a program with equivalent behaviour, but
without semicolons, on standard output.
Please note that I'm not interested in the DMS Software Reengineering
Toolkit.


Yes sir, I'll get on to writing this program straight away.
I'm not interested in the DMS Software Reengineering Toolkit, either.

If you were to search the archives (or lurk for a while) in order to
establish some context, you might be less inclined to post such rude
(and absurd) responses.

I read this newsgroup everyday.
What possible context is there?
Please explain how the directive to write such a program should be obeyed
by our readers.

The initial request is the absurb matter.
Nov 14 '05 #8
Chris McDonald wrote:
I read this newsgroup everyday.
What possible context is there?
Please explain how the directive to write such a program should be obeyed
by our readers.


Could we talk about C, instead, please?

Jeremy.
Nov 14 '05 #9
Chris McDonald wrote:
I read this newsgroup everyday.
What possible context is there?
Please explain how the directive to write such a program should be obeyed
by our readers.


Could we talk about C instead, please?

Jeremy.
Nov 14 '05 #10

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

Similar topics

1
2155
by: Mage | last post by:
Hello, I amafraid of I will stop using semicolons in other languages after one or two months of python. However I see that python simply ignores the semicolons atd the end of the lines. What's your advice? I don't want to write full-of-typo php scripts but I see the logic of the python syntax too. Mage
1
1805
by: jjbutera | last post by:
How do I escape these? The backslash doesn't seem to be working.
4
2953
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400, like DOS, uses memory-mapped display, two bytes per character (one char byte and one attribute byte). We can get the screen offset allright, and I've written a javascript which does the math to convert the offset into row/col (i.e. left, top)...
9
2189
by: Jukka K. Korpela | last post by:
I noticed that Internet Explorer (6.0, on Win XP SP 2, all fixes installed) incorrectly renders e.g. &harr &euro &Omega literally and not as characters denoted by the entities, but if a semicolon is appended to each of the entity references, they work. I'm pretty sure that previous versions of IE rendered them by the specifications. I first thought this has something to do with XML (i.e. maybe IE pretends to play a little bit of XML...
17
2348
by: subnet | last post by:
I'm not a C expert, but I've seen this topic discussed in the newsgroup several times. What's the deal with writing such programs? Why are they considered so interesting? Thanks
4
1412
by: Waxhead | last post by:
Hi folks, First of all I'm new to newsgroups so please don't kill me in case I'm breaking any rules , but if you really have to make it quick and painfull ;) What is actually propper hehaviour of Snippet 1 ? as I understand it the result should be the same as snippet 2. (but it isn't at least with my compiler). I expect snippet 1 to work like this: if then for and function() else just function() or perhaps a bit clearer:
3
1555
by: Stefan Mueller | last post by:
I've a web page with several input boxes. After the user clicks 'submit' I insert these data into my MySQL database. This worked for several months perfect. But today a user entered the street name Route d'Yverdon 59 unfortunately the data has not been inserted into my MySQL database because of the apostroph (') in the name of the street. I've no idea how to deal with this problem.
12
2541
by: feel | last post by:
Hi,All I am sure it's an old question. But I just find a interesting design about this: Polymorphism without virtual function in a C++ class. My solution is for some special case, trust me, very special. 1 single root class tree 2 the leaf(lowest level) classes are sealed which means we should not inherite class from them. 3 PImpl idiom. There is only one data mumber in root class and there is no any other data mumber in child class and...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
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
10098
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
9958
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...
1
7506
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
5390
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
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
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.