Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.26 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. import java.io.BufferedWriter;
  7. import java.io.FileWriter;
  8. import java.nio.file.Files;
  9. import java.nio.file.Paths;
  10. import java.util.regex.Matcher;
  11.  
  12. public class Lab3 {
  13.     public Lab3() {
  14.     }
  15.  
  16.     private static boolean writeToFile(String var0, String var1) {
  17.         try {
  18.             BufferedWriter var2 = new BufferedWriter(new FileWriter(var1));
  19.             var2.write(var0);
  20.             var2.close();
  21.             return true;
  22.         } catch (Exception var3) {
  23.             var3.printStackTrace();
  24.             return false;
  25.         }
  26.     }
  27.  
  28.     private static String getFileContent(String var0) {
  29.         try {
  30.             return new String(Files.readAllBytes(Paths.get(var0)));
  31.         } catch (Exception var2) {
  32.             var2.printStackTrace();
  33.             return null;
  34.         }
  35.     }
  36.  
  37.     public static PatternWithColor[] getPatterns() {
  38.         return new PatternWithColor[]{new PatternWithColor("/[*].*[*]/", "gray"), new PatternWithColor("//.*[\n$]?", "gray"), new PatternWithColor("[\"][^\"][ ]*(%d|%s|%c|%f)[^\"][\"]", "#6666cc"), new PatternWithColor("\"(?:\\\\\"|[^\"])*?\"", "#002aaa"), new PatternWithColor("'[^']+'", "#002aaa"), new PatternWithColor("#[ ]*(define|import|include|elif|else|ifndef|error|if|ifdef|pragma|line|undef|using|endif)", "#680000"), new PatternWithColor("0x[0-9A-Fa-f]*", "#683000"), new PatternWithColor("[-+ ]?[0-9]*[.]?[0-9]+([eE][-+]?[0-9]+)?", "#683000"), new PatternWithColor("0[1-7][0-7]*", "#683000"), new PatternWithColor("[^a-zA-Z][ ]*(asm|auto|bool|break|case|catch|char|class|const|const_cast|continue|delete|do|dynamic_cast|far|near|new|sizeof|volatile|double|goto|static|explicit|export|false|else|huge|try|true|this|throw|typeid|switch|struct|sizeof|enum|if|register|typedef|operator|mutable|namespace|template|extern|int|inline|return|union|using|virtual|wchar_t|whiledefault|for|long|unsigned|signed|void|int)[^a-zA-Z]", "#009666"), new PatternWithColor("[\\(\\)\\+\\-\\*\\/\\.\\%\\{\\}]", "#8700bc"), new PatternWithColor("[_A-Za-z][0-9A-Za-z_]*", "#bc8900"), new PatternWithColor("[\\<<\\>>\\=\\&]", "#afbc00"), new PatternWithColor("\"", "white")};
  39.     }
  40.  
  41.     public static String[] colorText(String var0) {
  42.         String[] var1 = new String[var0.length()];
  43.         PatternWithColor[] var2 = getPatterns();
  44.         PatternWithColor[] var3 = var2;
  45.         int var4 = var2.length;
  46.  
  47.         label45:
  48.         for(int var5 = 0; var5 < var4; ++var5) {
  49.             PatternWithColor var6 = var3[var5];
  50.             Matcher var7 = var6.getPattern().matcher(var0);
  51.  
  52.             while(true) {
  53.                 boolean var8;
  54.                 int var9;
  55.                 do {
  56.                     if (!var7.find()) {
  57.                         continue label45;
  58.                     }
  59.  
  60.                     var8 = true;
  61.  
  62.                     for(var9 = var7.start(); var9 < var7.end(); ++var9) {
  63.                         if (var1[var9] != null) {
  64.                             var8 = false;
  65.                         }
  66.                     }
  67.                 } while(!var8);
  68.  
  69.                 for(var9 = var7.start(); var9 < var7.end(); ++var9) {
  70.                     var1[var9] = var6.getColor();
  71.                 }
  72.             }
  73.         }
  74.  
  75.         return var1;
  76.     }
  77.  
  78.     public static void createHtml(String var0) {
  79.         StringBuilder var1 = new StringBuilder();
  80.         String[] var2 = colorText(var0);
  81.         var1.append("<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Title</title>\n</head>\n<style>\n\nspan {\n    white-space: pre-wrap;\n}\n</style>\n<body bgcolor=\"#142100\">\n\n");
  82.  
  83.         for(int var3 = 0; var3 < var0.length(); ++var3) {
  84.             var1.append(String.format("<span style='color:%s;'>%c</span>", var2[var3], var0.charAt(var3)));
  85.         }
  86.  
  87.         var1.append("</body>\n</html>");
  88.         writeToFile(var1.toString(), "index.html");
  89.     }
  90.  
  91.     public static void main(String[] var0) {
  92.         String var1 = getFileContent("source.c");
  93.         createHtml(var1);
  94.     }
  95. }
  96.  
  97. ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.
  98.  
  99. //
  100. // Source code recreated from a .class file by IntelliJ IDEA
  101. // (powered by Fernflower decompiler)
  102. //
  103.  
  104. import java.util.regex.Pattern;
  105.  
  106. public class PatternWithColor {
  107.     private Pattern pattern;
  108.     private String color;
  109.  
  110.     public PatternWithColor(String var1, String var2) {
  111.         this.pattern = Pattern.compile(var1);
  112.         this.color = var2;
  113.     }
  114.  
  115.     public Pattern getPattern() {
  116.         return this.pattern;
  117.     }
  118.  
  119.     public String getColor() {
  120.         return this.color;
  121.     }
  122. }
  123.  
  124. ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
  125.  тут файлы которые парсяться
  126.  
  127.  
  128. #include <stdio.h>
  129.  
  130. /* many lines * comment */
  131.  
  132. int main()
  133. {
  134.     int year;
  135.  
  136.     printf("Enter a year: ");
  137.     scanf("%d", &year);
  138.  
  139.     if(year % 4 == 0)
  140.     {
  141.         if( year % 100 == 0)
  142.         {
  143.             // year is divisible by 400, hence the year is a leap year
  144.             if ( year % 400 == 0)
  145.                 printf("%d is a leap year.", year);
  146.             else
  147.                 printf("%d is not a leap year.", year);
  148.         }
  149.         else
  150.             printf("%d is a leap year.", year );
  151.     }
  152.     else
  153.         printf("%d is not a leap year.", year);
  154.  
  155.     int a = 0x23, b = 3.555, c = 077610, d = 1.0E+10;
  156.  
  157.     char ch = '\'';
  158.  
  159.     printf("test \"TEST\" test ");
  160.     char error_test = ";
  161.  
  162.    return 0;
  163. }
  164.  
  165. и
  166.  
  167. #include <iostream>
  168.  
  169. using namespace std;
  170.  
  171.  
  172.  
  173. /*ome additional * comment*/
  174.  
  175.  
  176.  
  177. int main()
  178.  
  179. {
  180.  
  181.    int a = 0x23, b = 3.555, Ci = 077610, d = 1.0E+10;
  182.  
  183.    int res = a * a / b % 10;
  184.  
  185.    int firstNumber, secondNumber, sumOfTwoNumbers;
  186.  
  187.    char ch = '\\';
  188.  
  189.    char c = '\m';
  190.  
  191.  
  192.  
  193.    cout << "Enter two \" own \"  integers: " jkjk";
  194.  
  195.  
  196.  
  197.    cin >> firstNumber >> secondNumber;
  198.  
  199.  
  200.  
  201.    // sum of two numbers in stored // in variable sumOfTwoNumbers
  202.  
  203.    sumOfTwoNumbers = firstNumber + secondNumber;
  204.  
  205.  
  206.  
  207.    // Prints sum
  208.  
  209.    cout << firstNumber << secondNumber << sumOfTwoNumbers;
  210.  
  211.  
  212.  
  213.    return 0;
  214.  
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement