LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2023, 12:04 AM   #16
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753

Quote:

PAN64

But you can almost never translate a real source code from one language to another, there is no such tool. And because of the complexity (and incompatibility) of the existing languages it will never exist.
Actually, back in the days of the Y2K project, there were some one-to-one tools.

I ended up trying a FORTRAN to C tool to try and save time.
The code prob worked (I can't remember), but it was very odd looking 'C' of course ...
Iirc in the end I did re-code it into C by hand, but it was handy to have a 'C' version as an extra reference ...

Last edited by chrism01; 04-04-2023 at 08:23 PM. Reason: missed ']'; dang and a missed word ...
 
Old 04-04-2023, 01:31 AM   #17
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,033

Rep: Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344
Quote:
Originally Posted by chrism01 View Post
Actually, back in the days of the Y2K project, there were some one-to-one tools.

I ended up trying a FORTRAN to C tool to try and save time.
The code prob worked (I can't remember), but it was very odd looking 'C' of course ...
Iirc in the end I did re-code it into C by hand, but it was handy to a 'C' version as an extra reference ...
Oh yes, there are examples like this, but there is no general "translator". Interestingly the gnu compiler set (and probably other compilers) will produce byte code [during the compilation] which is quite similar (or identical) for every language handled by the tool, but the reverse direction does not work very well (reconstructing the original source files).
By the way using those "reasonably arbitrary text as comments" would mean just a new language - which can be easily converted to some(?) other languages.
 
Old 04-06-2023, 08:13 PM   #18
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,688

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
my purpose is to attach a code or certificate to each file. i probably will need to create something different for each class of language (classed by comment syntax) that reads a common form of the text/cert (probably 8 or so lines of 64 chars). python and bash would be in one class with a bunch of others. C would be in another with some. Fortran might have is own. same for COBOL.
 
Old 04-07-2023, 01:07 AM   #19
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Maybe you mean `signature`?
 
Old 04-07-2023, 01:15 PM   #20
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
You'd want to store stuff like that in the filesystem, not in the file. Here's one way you can do it:

https://learn.microsoft.com/en-us/wi...reparse-points

Of course, it's important what you want that "code or certificate" to say say/do. Are you withholding that information, or do you not know the answer yourself?

Before you answer, read the following very carefully:

https://xyproblem.info/

Last edited by dugan; 04-07-2023 at 01:36 PM.
 
1 members found this post helpful.
Old 04-08-2023, 02:37 PM   #21
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,688

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
the current need is to give a file to other people for them to add to each file. it can be added anywhere in their file, and the process using it will work. they may have lots of files of many languages to add it to. i do not want to burden them with the need to figure out which of many variants for many languages they need to use with that file, which maybe is too hard for them to automate.

i do not believe a universal tool exists for that purpose. for example, when using the "file" utility, many of my Python source files are typed as "CLIPPER instruction trace" (no idea what CLIPPER is). a nice tool would be able to read a file and give the correct language it is (with its common name extension) or list of possible languages it could be. maybe some new AI could do that (what would we train it with?).
 
Old 04-08-2023, 02:40 PM   #22
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,688

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Quote:
Originally Posted by NevemTeve View Post
Maybe you mean `signature`?
for what?
 
Old 04-08-2023, 02:55 PM   #23
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,688

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
here is a string to attach to every source file involved:
Code:
voodoo code = 4e3c1f5b5e617112b85872c4243a60f927e528023a0577f76f1a190c3b12668ef3a073f7ad7ff50393dd98d6bbe81e425aaa2753ee23d92a9d7eec08285ba3f041b13fcea40a16bf29e2fd73b7b2f35c09db44a592f77300b0e2895be19482d1abc747d64e9f695e6580f3d7cc8eda1471974d29077ddc498af4b83d6adc56bc5cc0c6fb091dd532ef8cbea668297ae8
if you can embed this string inside of another such that this string can still be seen, but will look like something that does not change the working of the source file when compiled (such as a comment or discarded literal) then that might be the solution. as you can see, this will be very difficult, if not impossible.

C:
Code:
/* voodoo code = 4e3c1f5b5e617112b85872c4243a60f927e528023a0577f76f1a190c3b12668ef3a073f7ad7ff50393dd98d6bbe81e425aaa2753ee23d92a9d7eec08285ba3f041b13fcea40a16bf29e2fd73b7b2f35c09db44a592f77300b0e2895be19482d1abc747d64e9f695e6580f3d7cc8eda1471974d29077ddc498af4b83d6adc56bc5cc0c6fb091dd532ef8cbea668297ae8 */
C++ or C:
Code:
// voodoo code = 4e3c1f5b5e617112b85872c4243a60f927e528023a0577f76f1a190c3b12668ef3a073f7ad7ff50393dd98d6bbe81e425aaa2753ee23d92a9d7eec08285ba3f041b13fcea40a16bf29e2fd73b7b2f35c09db44a592f77300b0e2895be19482d1abc747d64e9f695e6580f3d7cc8eda1471974d29077ddc498af4b83d6adc56bc5cc0c6fb091dd532ef8cbea668297ae8
Python or Bash:
Code:
# voodoo code = 4e3c1f5b5e617112b85872c4243a60f927e528023a0577f76f1a190c3b12668ef3a073f7ad7ff50393dd98d6bbe81e425aaa2753ee23d92a9d7eec08285ba3f041b13fcea40a16bf29e2fd73b7b2f35c09db44a592f77300b0e2895be19482d1abc747d64e9f695e6580f3d7cc8eda1471974d29077ddc498af4b83d6adc56bc5cc0c6fb091dd532ef8cbea668297ae8
Fortran:
Code:
C voodoo code = 4e3c1f5b5e617112b85872c4243a60f927e528023a0577f76f1a190c3b12668ef3a073f7ad7ff50393dd98d6bbe81e425aaa2753ee23d92a9d7eec08285ba3f041b13fcea40a16bf29e2fd73b7b2f35c09db44a592f77300b0e2895be19482d1abc747d64e9f695e6580f3d7cc8eda1471974d29077ddc498af4b83d6adc56bc5cc0c6fb091dd532ef8cbea668297ae8
 
Old 04-08-2023, 02:56 PM   #24
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
How would that voodoo code be generated, what information would it contain, and what would read it?

I see that in your post, the voodoo code is the same every time. If it's just an identifier, and the the idea is to locate files that contain it, then I have a better idea. Create a directory named after the voodoo code, and symlink all of the source files into it.

Last edited by dugan; 04-08-2023 at 03:44 PM.
 
1 members found this post helpful.
Old 04-09-2023, 02:23 AM   #25
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,033

Rep: Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344
Quote:
Originally Posted by Skaperen View Post
here is a string to attach to every source file involved:
Code:
voodoo code = 4e3c1f5b5e617112b85872c4243a60f927e528023a0577f76f1a190c3b12668ef3a073f7ad7ff50393dd98d6bbe81e425aaa2753ee23d92a9d7eec08285ba3f041b13fcea40a16bf29e2fd73b7b2f35c09db44a592f77300b0e2895be19482d1abc747d64e9f695e6580f3d7cc8eda1471974d29077ddc498af4b83d6adc56bc5cc0c6fb091dd532ef8cbea668297ae8
if you can embed this string inside of another such that this string can still be seen, but will look like something that does not change the working of the source file when compiled (such as a comment or discarded literal) then that might be the solution. as you can see, this will be very difficult, if not impossible.
I still have no idea what do you want to solve and how will it solve anything. Obviously we can embed [almost] any string into any language.
 
Old 04-09-2023, 11:19 AM   #26
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Quote:
Originally Posted by Skaperen View Post
the current need is to give a file to other people for them to add to each file. it can be added anywhere in their file, and the process using it will work. they may have lots of files of many languages to add it to. i do not want to burden them with the need to figure out which of many variants for many languages they need to use with that file, which maybe is too hard for them to automate.
So you're intending to have source code files edited by people who don't even know how to write comments in those languages?

Silliness of this aside, it's standard practice to have a Continuous Integration server that builds the source code and ensures that it's at least is still syntactically correct. Yes this is also (largely) true for interpreted languages.

Last edited by dugan; 04-09-2023 at 08:32 PM.
 
Old 04-10-2023, 12:53 PM   #27
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Why can't you just do a separate "echo >>" operation for each file extension?

Why would you have people do it with a text editor?
 
Old 04-10-2023, 01:16 PM   #28
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Deleted. Oops. Wrong thread. Carry on.

Last edited by dugan; 04-10-2023 at 01:45 PM.
 
Old 04-17-2023, 11:03 AM   #29
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,831

Rep: Reputation: 1217Reputation: 1217Reputation: 1217Reputation: 1217Reputation: 1217Reputation: 1217Reputation: 1217Reputation: 1217Reputation: 1217
You can assume that all interpreted languages support #comment, in order to ignore a #! shebang.
Code:
#!/bin/sh
voodoo="4e3c1f5b5e617112b85872c4243a60f927e528023a0577f76f1a190c3b12668ef3a073f7ad7ff50393dd98d6bbe81e425aaa2753ee23d92a9d7eec08285ba3f041b13fcea40a16bf29e2fd73b7b2f35c09db44a592f77300b0e2895be19482d1abc747d64e9f695e6580f3d7cc8eda1471974d29077ddc498af4b83d6adc56bc5cc0c6fb091dd532ef8cbea668297ae8"
bv=" $voodoo"
for fn
do
  fgrep -q "$bv" "$fn" ||
  # only if not yet found
  case $fn in
  ( *.c ) echo "/*$bv */"
  ;;
  ( *.cpp ) echo "//$bv"
  ;;
  ( *.f ) echo "c   $bv"
  ;;
  ( * ) echo "#$bv"
  esac >> "$fn"
done
 
Old 04-17-2023, 11:15 AM   #30
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,033

Rep: Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344
Quote:
Originally Posted by MadeInGermany View Post
You can assume that all interpreted languages support #comment, in order to ignore a #! shebang.
Code:
#!/bin/sh
voodoo="4e3c1f5b5e617112b85872c4243a60f927e528023a0577f76f1a190c3b12668ef3a073f7ad7ff50393dd98d6bbe81e425aaa2753ee23d92a9d7eec08285ba3f041b13fcea40a16bf29e2fd73b7b2f35c09db44a592f77300b0e2895be19482d1abc747d64e9f695e6580f3d7cc8eda1471974d29077ddc498af4b83d6adc56bc5cc0c6fb091dd532ef8cbea668297ae8"
bv=" $voodoo"
for fn
do
  fgrep -q "$bv" "$fn" ||
  # only if not yet found
  case $fn in
  ( *.c ) echo "/*$bv */"
  ;;
  ( *.cpp ) echo "//$bv"
  ;;
  ( *.f ) echo "c   $bv"
  ;;
  ( * ) echo "#$bv"
  esac >> "$fn"
done
and what about perl, php, bash, java, js, cobol, fortran, assembler, python, basic, pascal (just to name a few)
https://www.simplilearn.com/best-pro...-today-article
(nightmare)
 
  


Reply



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
What are the top few most human-readable programming languages? punchy71 Programming 46 01-11-2023 02:17 PM
LXer: How To Print Files Without Comments And Empty Lines In Linux LXer Syndicated Linux News 0 07-01-2020 02:57 AM
Request: Slackware Info-Zip ZipNote be patched to support writing back comments ruario Slackware 0 04-24-2014 12:44 PM
[SOLVED] Add lines end of file above the end comments bkone Programming 2 02-27-2012 09:58 AM
languages of linux: which languages can be choosen in suse and red-hat distributions? Klaus Schnorr Linux - Software 3 09-10-2005 02:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:44 PM.

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
Open Source Consulting | Domain Registration