Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Source code recreated from a .class file by IntelliJ IDEA
- // (powered by Fernflower decompiler)
- //
- import java.io.BufferedWriter;
- import java.io.FileWriter;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.util.regex.Matcher;
- public class Lab3 {
- public Lab3() {
- }
- private static boolean writeToFile(String var0, String var1) {
- try {
- BufferedWriter var2 = new BufferedWriter(new FileWriter(var1));
- var2.write(var0);
- var2.close();
- return true;
- } catch (Exception var3) {
- var3.printStackTrace();
- return false;
- }
- }
- private static String getFileContent(String var0) {
- try {
- return new String(Files.readAllBytes(Paths.get(var0)));
- } catch (Exception var2) {
- var2.printStackTrace();
- return null;
- }
- }
- public static PatternWithColor[] getPatterns() {
- 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")};
- }
- public static String[] colorText(String var0) {
- String[] var1 = new String[var0.length()];
- PatternWithColor[] var2 = getPatterns();
- PatternWithColor[] var3 = var2;
- int var4 = var2.length;
- label45:
- for(int var5 = 0; var5 < var4; ++var5) {
- PatternWithColor var6 = var3[var5];
- Matcher var7 = var6.getPattern().matcher(var0);
- while(true) {
- boolean var8;
- int var9;
- do {
- if (!var7.find()) {
- continue label45;
- }
- var8 = true;
- for(var9 = var7.start(); var9 < var7.end(); ++var9) {
- if (var1[var9] != null) {
- var8 = false;
- }
- }
- } while(!var8);
- for(var9 = var7.start(); var9 < var7.end(); ++var9) {
- var1[var9] = var6.getColor();
- }
- }
- }
- return var1;
- }
- public static void createHtml(String var0) {
- StringBuilder var1 = new StringBuilder();
- String[] var2 = colorText(var0);
- 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");
- for(int var3 = 0; var3 < var0.length(); ++var3) {
- var1.append(String.format("<span style='color:%s;'>%c</span>", var2[var3], var0.charAt(var3)));
- }
- var1.append("</body>\n</html>");
- writeToFile(var1.toString(), "index.html");
- }
- public static void main(String[] var0) {
- String var1 = getFileContent("source.c");
- createHtml(var1);
- }
- }
- ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.
- //
- // Source code recreated from a .class file by IntelliJ IDEA
- // (powered by Fernflower decompiler)
- //
- import java.util.regex.Pattern;
- public class PatternWithColor {
- private Pattern pattern;
- private String color;
- public PatternWithColor(String var1, String var2) {
- this.pattern = Pattern.compile(var1);
- this.color = var2;
- }
- public Pattern getPattern() {
- return this.pattern;
- }
- public String getColor() {
- return this.color;
- }
- }
- ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
- тут файлы которые парсяться
- #include <stdio.h>
- /* many lines * comment */
- int main()
- {
- int year;
- printf("Enter a year: ");
- scanf("%d", &year);
- if(year % 4 == 0)
- {
- if( year % 100 == 0)
- {
- // year is divisible by 400, hence the year is a leap year
- if ( year % 400 == 0)
- printf("%d is a leap year.", year);
- else
- printf("%d is not a leap year.", year);
- }
- else
- printf("%d is a leap year.", year );
- }
- else
- printf("%d is not a leap year.", year);
- int a = 0x23, b = 3.555, c = 077610, d = 1.0E+10;
- char ch = '\'';
- printf("test \"TEST\" test ");
- char error_test = ";
- return 0;
- }
- и
- #include <iostream>
- using namespace std;
- /*ome additional * comment*/
- int main()
- {
- int a = 0x23, b = 3.555, Ci = 077610, d = 1.0E+10;
- int res = a * a / b % 10;
- int firstNumber, secondNumber, sumOfTwoNumbers;
- char ch = '\\';
- char c = '\m';
- cout << "Enter two \" own \" integers: " jkjk";
- cin >> firstNumber >> secondNumber;
- // sum of two numbers in stored // in variable sumOfTwoNumbers
- sumOfTwoNumbers = firstNumber + secondNumber;
- // Prints sum
- cout << firstNumber << secondNumber << sumOfTwoNumbers;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement