Libraryless. Click here for Pure Java version (1692L/12K/40K).
1 | //TODO: |
2 | // |
3 | //Add more features. |
4 | //Add + and > signs |
5 | // |
6 | !752 |
7 | |
8 | p{
|
9 | makeBot("Code generator.");
|
10 | } |
11 | |
12 | answer{
|
13 | if (matchStart("make code *",s ,m)) {
|
14 | S command = m.unq(0); |
15 | S encodedcmmnd = ""; |
16 | command = command.replace("make code", "");
|
17 | if(command == null){
|
18 | ret null; |
19 | } |
20 | if(command.indexOf("newbot") != -1){
|
21 | encodedcmmnd += [[ |
22 | ``` !752 |
23 | |
24 | p{
|
25 | makeBot('BOT NAME HERE');
|
26 | } |
27 | answer{
|
28 | ret "hello"; |
29 | }``` ]]; |
30 | } |
31 | if(command.indexOf("ifelifelse") != -1){
|
32 | encodedcmmnd += " ```if() {\n\n}else if() {\n\n}else{\n\n}``` ";
|
33 | }else if(command.indexOf("ifelse") != -1){
|
34 | encodedcmmnd += " ```if{\n\n}else{\n\n}``` ";
|
35 | }else if(command.indexOf("if") != -1){
|
36 | encodedcmmnd += " ```if() {\n\n}``` ";
|
37 | } |
38 | if(command.indexOf("for") != -1){
|
39 | encodedcmmnd += " ```for(INIT;TERMINATE;INC;){ //you know what to do,right? RIGHT??\n\n}``` ";
|
40 | } |
41 | if(command.indexOf("calculator") != -1){
|
42 | encodedcmmnd += [[ |
43 | ``` |
44 | import java.util.Scanner; |
45 | |
46 | double n1, n2; |
47 | String operation; |
48 | Scanner scannerObject = new Scanner(System.in); |
49 | |
50 | System.out.println("Enter first number");
|
51 | n1 = scannerObject. nextDouble(); |
52 | |
53 | System.out.println("Enter second number");
|
54 | n2 = scannerObject. nextDouble(); |
55 | |
56 | Scanner op = new Scanner(System.in); |
57 | System.out.println("Enter your operation");
|
58 | operation = op.next(); |
59 | |
60 | switch (operation) {
|
61 | case "+": |
62 | System.out.println("Your answer is " + (n1 + n2));
|
63 | break; |
64 | |
65 | case "-": |
66 | System.out.println("Your answer is " + (n1 - n2));
|
67 | break; |
68 | |
69 | case "/": |
70 | System.out.println("Your answer is " + (n1 / n2));
|
71 | break; |
72 | |
73 | case "*": |
74 | System.out.println("Your asnwer is " + (n1 * n2));
|
75 | break; |
76 | |
77 | default: |
78 | System.out.println("Dunno");
|
79 | |
80 | }```]]; |
81 | } |
82 | if(command.indexOf("fibonacci") != -1){
|
83 | encodedcmmnd += [[``` |
84 | int febCount = 15; //You can change this. |
85 | int[] feb = new int[febCount]; |
86 | feb[0] = 0; |
87 | feb[1] = 1; |
88 | for(int i=2; i < febCount; i++){
|
89 | feb[i] = feb[i-1] + feb[i-2]; |
90 | } |
91 | for(int i=0; i< febCount; i++){
|
92 | System.out.print(feb[i] + " "); |
93 | } |
94 | ```]]; |
95 | } |
96 | //ntUpload(programID(), programID() + " generated code", encodedcmmnd); Uncomment this later |
97 | ret encodedcmmnd; |
98 | } |
99 | } |
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jlatgrcjtklg, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1002233 |
| Snippet name: | Code generator |
| Eternal ID of this version: | #1002233/1 |
| Text MD5: | 207e26f745fe00194938485e3595534e |
| Transpilation MD5: | 8538860ab1e6af4201f72ec8dde5ceca |
| Author: | bgrgndz |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-02-28 16:13:53 |
| Source code size: | 2707 bytes / 99 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1358 / 2427 |
| Referenced in: | [show references] |