68 lines
3.0 KiB
JavaScript
68 lines
3.0 KiB
JavaScript
//本JS为编译主JS,存放一些编译中通用的方法和变量及相关的数据
|
||
let CompilerStart = "1_0_1Compiler\r\n";//编译器版本标识
|
||
let CompilerIdentificationText = "-begin---====----==--==--==--==--==--==--==--==-end-"//编译器唯一标识文本,一些特殊字符可用该标识替换
|
||
let Comendfofdianhaobenin = "endfofdianhaobenin";//点号的替换符
|
||
let ComSymbol$FOFStuDio = "ComSymbolFOFStuDio{";//${}替换 通常在`${}`中
|
||
let ComSymbolCssFOFStuDio = "ComSymbolCssFOFStuDio";//$替换 在CSS中需要直接处理
|
||
let ComNewlineCharacterFOFStuDiorn = "ComNewlineCharacterRNFOFStuDio";// \r\n
|
||
let ComNewlineCharacterFOFStuDion = "ComNewlineCharacterFOFStuDion";// \n
|
||
let ComNewlineCharacterFOFStuDior = "ComNewlineCharacterRFOFStuDion";// \r
|
||
let ComShuangYinHaoFOFStuDion = "ComShuangYinHaoFOFStuDion";// "
|
||
let ComDanYinHaoFOFStuDion = "ComDanYinHaoFOFStuDion";// '
|
||
let ComFanYinHaoFOFStuDion = "ComFanYinHaoFOFStuDion";// `
|
||
let ComXingHaoFOFStuDioText1 = "ComXingHaoFOFStuDioText1";// /*
|
||
let ComXingHaoFOFStuDioText2 = "ComXingHaoFOFStuDioText2";// */
|
||
|
||
let FileTypeExtension = {
|
||
//代码文件格式
|
||
html: ".html",
|
||
css: ".css",
|
||
js: ".js",
|
||
lhtml: ".lhtml",
|
||
lcss: ".lcss",
|
||
ljs: ".ljs",
|
||
Nohtml: "html",
|
||
Nocss: "css",
|
||
Nojs: "js",
|
||
Nolhtml: "lhtml",
|
||
Nolcss: "lcss",
|
||
Noljs: "ljs",
|
||
}
|
||
|
||
/*
|
||
编译相关所需要的配置
|
||
@IfComPiler-是否正在编译,假代表不是,真代表是-【注意:判断编译调试状态以该字段为主,翻译、转换等都不在本字段范围中】
|
||
@IfComDebug-调试还是编译,2代表编译,1代表调试
|
||
*/
|
||
let ComPilerDataMsgType = {
|
||
IfComPiler: false,
|
||
IfComDebug: 0
|
||
}
|
||
let FOFStudioType = {
|
||
replaceStringsInCode: (JSCode) => {
|
||
const JsCodeJSonCompilerStr = [];
|
||
function replaceMatch(match) {
|
||
const uuid = StrCodeUuid(); // 每次匹配到字符串时都生成新的UUID
|
||
JsCodeJSonCompilerStr.push([uuid, match, false]); // 直接将新的UUID和原始字符串推入数组
|
||
return uuid; // 返回新的UUID用于替换原始字符串
|
||
}
|
||
// 匹配双引号和单引号包含的文本
|
||
const pattern1 = /(["'])(?:(?=(\\?))\2.)*?\1/g;
|
||
const matches1 = JSCode.match(pattern1);
|
||
if (matches1) {
|
||
JSCode = JSCode.replace(pattern1, replaceMatch);
|
||
}
|
||
// 匹配反引号包含的文本
|
||
const pattern2 = /([`])(?:(?=(\\?))\2.)*?\1/gs;
|
||
const matches2 = JSCode.match(pattern2);
|
||
if (matches2) {
|
||
JSCode = JSCode.replace(pattern2, replaceMatch);
|
||
}
|
||
return { JSCode, JsCodeJSonCompilerStr };
|
||
}
|
||
}
|
||
JsonJSCodeMain(JavascriptCompilationPNameAll_, JavascriptCompilationJQCode_, JsonJSCodeTransformation_, JavascriptCodeKey_, JavascriptNoCodeStatic_, JavascriptEvCode_, JavascriptYesCodeStatic_, JavascriptOverallCode_)
|
||
|
||
JSONCompilerInt_All(HTMLcompilation_, HTMLcompilationFun_, HTMLcompilationAttr_, HTMLcompilation2_, HTMLTripartiteClass_);//HTML编译器初始化
|
||
|
||
JsonCssCodeMain(CssCompilation_);//CSS编译器初始化
|