Java "only" 498 Bytes
The following java program takes in input as command line arguments.
class Q{
public static void main(String[]a){
System.out.println(a[0]);System.out.print("static char[]s={");a[2]+="}static void q(){System.out.print(\""+a[0]+"\\n\");System.out.print(\"static char[]s={\");for(char c:s)System.out.print((int) c+\",\");System.out.print(\"\\b};\\n"+a[1]+"\\n\");for(char c:s)System.out.print(c);System.out.print(\"\\n}\");}";for(char c:a[2].toCharArray())System.out.print((int) c+",");System.out.println("\b};");System.out.println(a[1]);System.out.print(a[2]+"\n}");
}}
In this case my language "X" is (a subset of) Java, and my Quine Command string "Q" is q();for each instance of q(); the output program will print its source. Input is restricted to only four lines, and any more or less results in undefined behavior. My golfed program technically follows these same restrictions. So my subset is programs that fit on four lines as shown and do not have a function called q or use any variable named s.
Sample Input
class sampleInput{//class def on this line
public static void main(String[]argument){//method header here and optional code although avoid putting code here
System.out.println("Hello World Of Quines");q();System.out.println("\n------------");q();/*Avoid comments on this line unless you use this format YOU MUST! put two braces on the next line*/
}}
Sample Output
class sampleInput{//class def on this line
static char[]s={83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,108,110,40,34,72,101,108,108,111,32,87,111,114,108,100,32,79,102,32,81,117,105,110,101,115,34,41,59,113,40,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,108,110,40,34,92,110,45,45,45,45,45,45,45,45,45,45,45,45,34,41,59,113,40,41,59,47,42,65,118,111,105,100,32,99,111,109,109,101,110,116,115,32,111,110,32,116,104,105,115,32,108,105,110,101,32,117,110,108,101,115,115,32,121,111,117,32,117,115,101,32,116,104,105,115,32,102,111,114,109,97,116,32,112,117,116,32,116,119,111,32,98,114,97,99,101,115,32,111,110,32,116,104,101,32,110,101,120,116,32,108,105,110,101,42,47,125,115,116,97,116,105,99,32,118,111,105,100,32,113,40,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,99,108,97,115,115,32,115,97,109,112,108,101,73,110,112,117,116,123,47,47,99,108,97,115,115,32,100,101,102,32,111,110,32,116,104,105,115,32,108,105,110,101,92,110,34,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,115,116,97,116,105,99,32,99,104,97,114,91,93,115,61,123,34,41,59,102,111,114,40,99,104,97,114,32,99,58,115,41,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,32,99,43,34,44,34,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,92,98,125,59,92,110,112,117,98,108,105,99,32,115,116,97,116,105,99,32,118,111,105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,97,114,103,117,109,101,110,116,41,123,47,47,109,101,116,104,111,100,32,104,101,97,100,101,114,32,104,101,114,101,32,97,110,100,32,111,112,116,105,111,110,97,108,32,99,111,100,101,32,97,108,116,104,111,117,103,104,32,97,118,111,105,100,32,112,117,116,116,105,110,103,32,99,111,100,101,32,104,101,114,101,92,110,34,41,59,102,111,114,40,99,104,97,114,32,99,58,115,41,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,99,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,92,110,125,34,41,59,125};
public static void main(String[]argument){//method header here and optional code although avoid putting code here
System.out.println("Hello World Of Quines");q();System.out.println("\n------------");q();/*Avoid comments on this line unless you use this format put two braces on the next line*/}static void q(){System.out.print("class sampleInput{//class def on this line\n");System.out.print("static char[]s={");for(char c:s)System.out.print((int) c+",");System.out.print("\b};\npublic static void main(String[]argument){//method header here and optional code although avoid putting code here\n");for(char c:s)System.out.print(c);System.out.print("\n}");}
}
1What if the language has a builtin quine command, but we designate a different string as a new quine command? – Conor O'Brien – 2016-07-07T01:33:12.810
It seems dubious, but what language do you have in mind? – Rohan Jhunjhunwala – 2016-07-07T01:43:37.937
Languages like Jolf, Actually, etc. – Conor O'Brien – 2016-07-07T01:44:11.267
Is it clear what I am asking? – Rohan Jhunjhunwala – 2016-07-07T01:44:13.097
Yes, it is, for the most part – Conor O'Brien – 2016-07-07T01:44:29.470
Ok, Thanks, I feel like an esolang like that with a built in quine may not be in the spirit of the challenge. A simple implementation would just find and replace the string for a new quine command into the old one. That being said if the implementation of such a thing is not too trivial I would accept it. Feel free to write one up, and message it to me and I can take a look. – Rohan Jhunjhunwala – 2016-07-07T01:46:16.780
@CᴏɴᴏʀO'Bʀɪᴇɴ Upon further review I have decided that you are permitted to define a new quine character, except the new quine operator must be implemented without use of the old one. – Rohan Jhunjhunwala – 2016-07-07T02:17:53.837
Is a quine flag cheating? – NoOneIsHere – 2016-07-07T03:15:24.910
I would say yes – Rohan Jhunjhunwala – 2016-07-07T08:10:38.217
Totally confused, can you define it in terms of functions? i.e. if a quinine is
(Compile(Source))() = Sourcewhat are you after? – weston – 2016-07-07T10:34:12.553The Q comand should output the compiled program – Rohan Jhunjhunwala – 2016-07-07T12:32:37.963
"... the compiled source of language Y" doesn't even make sense. I'm not sure whether the edited explanation is worse than the previous one, but it's certainly still far from clear. – Peter Taylor – 2016-07-07T13:42:02.800
I slightly tweaked it again. I however feel that while the challenge is hard to understand it certainly is doable as there are two answers to this question. @Peter Taylor – Rohan Jhunjhunwala – 2016-07-07T13:54:59.873
In that case maybe you can enlist the aid of Anders to write a clear spec - although I'm not convinced that he's understood what you want either. At least his CJam program doesn't behave as I would expect. – Peter Taylor – 2016-07-07T14:55:31.703
This got less clear with recent edits. The problem as I understand it is as follows. Given some programming language X, you are to define (1) a quine command string Q; (2) a language X′ that is a subset of X; (3) a compiler, written in X′, and producing an output program B in X for any input program A that is in X′ except in that A may also contain copies of Q. When B is run, it should behave like A would if all its copies of Q had been replaced with a statement in X that prints the source code of B. We’ve thus created a language Y (X′ augmented with Q) that contains a quining builtin Q. – Anders Kaseorg – 2016-07-07T17:38:26.887
@RohanJhunjhunwala, does that match your intention? If so you are welcome to edit it into the question, or I can. – Anders Kaseorg – 2016-07-07T17:39:08.557
@Anders Kaesorg yes that matches my intention – Rohan Jhunjhunwala – 2016-07-07T18:08:19.180
Is it now clear enough? – Rohan Jhunjhunwala – 2016-07-07T18:08:57.787
@RohanJhunjhunwala Since one can hide a fair amount of logic within the quine command string, this might be more interesting if the score were something like the sum of the length of the compiler and the length of the quine command string, rather than just the length of the compiler—what do you think? – Anders Kaseorg – 2016-07-07T18:37:28.153
yes if this question gets off of hold I would consider that. Do you think it deserves to be taken off of hold? – Rohan Jhunjhunwala – 2016-07-07T19:18:49.147
@RohanJhunjhunwala It’s on hold because people thought it was unclear, but I think the new wording will satisfy them. I voted to reopen. – Anders Kaseorg – 2016-07-07T20:36:09.793
@busukxuan are the new rule clarifications more accepatable and clear enough to warrant reopening? – Rohan Jhunjhunwala – 2016-07-08T01:51:21.900
@Connor O' Brien are the new rules more appropriate? I am interested in reopening this question – Rohan Jhunjhunwala – 2016-07-08T14:19:09.110