-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compiler.html
153 lines (134 loc) · 4.25 KB
/
Compiler.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MochaScript Compiler</title>
<link rel="icon" type="image/png" href="/Mocha.png" rel="stylesheet">
<style>
@font-face {
font-family: nasinnanpa;
src: url("https://arcane.kitties.cat/Nasin Nanpa.otf");
}
body {
margin: 0;
padding: 0;
font-family: 'Roboto', 'Arial', 'sans-serif', 'nasinnanpa';
background: url('https://wallpapercave.com/wp/wp10407656.png') no-repeat center center fixed;
background-size: cover;
color: #fff;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
position: relative;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(10px);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.content-container {
background: rgba(100, 100, 100, 0.1);
backdrop-filter: blur(10px);
padding: 60px;
border-radius: 15px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
text-align: center;
width: 70%;
max-width: 800px;
margin-bottom: 40px;
}
h1 {
font-size: 36px;
margin-bottom: 20px;
font-weight: 700;
}
.container {
display: flex;
justify-content: space-between;
width: 100%;
gap: 20px;
}
textarea {
width: 100%;
height: 400px;
padding: 10px;
font-size: 16px;
font-family: monospace;
background: rgba(255, 255, 255, 0.1);
color: #fff;
border: 1px solid #ccc;
border-radius: 10px;
}
textarea:focus {
outline: none;
border-color: #fff;
}
button {
padding: 15px 30px;
font-size: 18px;
margin-top: 20px;
border: none;
border-radius: 10px;
background-color: #ff9800;
color: #fff;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #e68a00;
}
</style>
</head>
<body>
<div class="overlay">
<div class="content-container">
<h1>MochaScript Compiler</h1>
<div class="container">
<textarea id="mochaCode" placeholder="Enter MochaScript code here..."></textarea>
<textarea id="output" placeholder="Your compiled JavaScript will appear here..." readonly></textarea>
</div>
<button onclick="compileMochaScript()">Compile to JavaScript</button>
</div>
</div>
<script>
function compileMochaScript() {
let mochaCode = document.getElementById('mochaCode').value;
// Process and clean up MochaScript code
let jsCode = mochaCode;
// Check if rac() is present to remove comments
const removeComments = /rac$begin:math:text$$end:math:text$\s*~/.test(jsCode);
// If rac() is present, remove it and strip all comments
if (removeComments) {
jsCode = jsCode.replace(/rac$begin:math:text$$end:math:text$\s*~/, '');
jsCode = jsCode.replace(/\/\/.*$/gm, '');
jsCode = jsCode.replace(/\/\*[\s\S]*?\*\//g, '');
}
// Replace 'func()' with 'function()'
jsCode = jsCode.replace(/func\s*(\w+)\s*\(/g, 'function $1(');
// Replace 'set' with 'var' outside of strings
jsCode = jsCode.replace(/(\bset\b)(?=(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$)/g, 'var');
// Replace 'yes' with 'true' and 'no' with 'false'
jsCode = jsCode.replace(/\byes\b/g, 'true');
jsCode = jsCode.replace(/\bno\b/g, 'false');
// Replace tildes with semicolons outside of strings
jsCode = jsCode.replace(/(~)(?=(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$)/g, ';');
// Ensure 'function' is not broken up
jsCode = jsCode.replace(/function tion/g, 'function');
// Display the compiled JavaScript code
document.getElementById('output').value = jsCode;
}
</script>
</body>
</html>