📄 skymanager.pas
字号:
end
else if Pos('/BlockCommentOffs=', slParser[i]) = 1 then
begin //多行注释结束符
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 19, Length(slParser[i]) - (19 - 1));
TSkyParser(FParserList.Items[iParserIdx]).BlockCommentOffs.Text :=
StringReplace(sTmpStr, FDelimiterChar, #13#10, [rfReplaceAll]);
end;
end
else if Pos('/Characters=', slParser[i]) = 1 then
begin //单个字符指示符
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 13, Length(slParser[i]) - (13 - 1));
TSkyParser(FParserList.Items[iParserIdx]).Characters :=
GetIndicator(sTmpStr);
end;
end
else if Pos('/StringChars=', slParser[i]) = 1 then
begin //字符串指示符
if FParserList.Count > 0 then
begin
TSkyParser(FParserList.Items[iParserIdx]).StringChars :=
Copy(slParser[i], 14, Length(slParser[i]) - (14 - 1));
end;
end
else if Pos('/Delimiters=', slParser[i]) = 1 then
begin //分隔符
if FParserList.Count > 0 then
begin
TSkyParser(FParserList.Items[iParserIdx]).Delimiters :=
Copy(slParser[i], 13, Length(slParser[i]) - (13 - 1));
end;
end
else if Pos('/EscapeChar=', slParser[i]) = 1 then
begin //字符串忽略符
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 13, Length(slParser[i]) - (13 - 1));
TSkyParser(FParserList.Items[iParserIdx]).EscapeChar :=
GetIndicator(sTmpStr);
end;
end
else if Pos('/FileExtentions=', slParser[i]) = 1 then
begin //所关联的文件扩展名
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 17, Length(slParser[i]) - (17 - 1));
TSkyParser(FParserList.Items[iParserIdx]).FileExtentions.Text :=
StringReplace(sTmpStr, FDelimiterChar, #13#10, [rfReplaceAll]);
end;
end
else if Pos('/FloatHeadChar=', slParser[i]) = 1 then
begin
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 16, Length(slParser[i]) - (16 - 1));
TSkyParser(FParserList.Items[iParserIdx]).Float_HeadChar :=
GetIndicator(sTmpStr);
end;
end
else if Pos('/Int 1 HeadChar=', slParser[i]) = 1 then
begin
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 17, Length(slParser[i]) - (17 - 1));
TSkyParser(FParserList.Items[iParserIdx]).Int_1_HeadChar :=
GetIndicator(sTmpStr);
end;
end
else if Pos('/Int 2 HeadChar=', slParser[i]) = 1 then
begin
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 17, Length(slParser[i]) - (17 - 1));
TSkyParser(FParserList.Items[iParserIdx]).Int_2_HeadChar :=
GetIndicator(sTmpStr);
end;
end
else if Pos('/Int 4 HeadChar=', slParser[i]) = 1 then
begin
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 17, Length(slParser[i]) - (17 - 1));
TSkyParser(FParserList.Items[iParserIdx]).Int_4_HeadChar :=
GetIndicator(sTmpStr);
end;
end
else if Pos('/MacroSymbols=', slParser[i]) = 1 then
begin //宏指示符(指预处理)
if FParserList.Count > 0 then
begin
TSkyParser(FParserList.Items[iParserIdx]).MacroSymbols :=
Copy(slParser[i], 15, Length(slParser[i]) - (15 - 1));
end;
end
else if Pos('/MacroWrapChar=', slParser[i]) = 1 then
begin //宏换行符(指预处理)
if FParserList.Count > 0 then
begin
sTmpStr := Copy(slParser[i], 16, Length(slParser[i]) - (16 - 1));
TSkyParser(FParserList.Items[iParserIdx]).MacroWrapChar :=
GetIndicator(sTmpStr);
end;
end
else if Pos('/Word', slParser[i]) = 1 then
begin //遇到一种新单词
iPos := Pos('=', slParser[i]);
if iPos > 5 then
begin
iWordsIdx := StrToIntDef(Copy(slParser[i], 6, iPos - 6), 0);
sTmpStr := Copy(slParser[i], iPos +1, Length(slParser[i])- iPos);
if (iWordsIdx > 0) and (sTmpStr <> '') then
begin
SetWordsName(iWordsIdx, sTmpStr);
end;
end;
end
else if (slParser[i] = 'NoCase') and (FParserList.Count > 0) then
begin //当前语言之单词不区分大小写
TSkyParser(FParserList.Items[iParserIdx]).CaseSensitive := False;
end
else if Pos('/Alphabet=', slParser[i]) = 1 then
begin //使用自定义字母表
iLen := Length(slParser[i]);
if iLen > 10 then //=10表明字母表为空,则用默认字母表
begin
with ParserList[iParserIdx] do
begin
AlphabetChars := Copy(slParser[i], 11, Length(slParser[i]) - (11 - 1));
//Alphabet := []; //以下循环填充字母表
//for k := 10 + 1 to iLen do
// Alphabet := Alphabet + [slParser[i][k]];
end;
end
end
else if Pos('/Int 1 Chars=', slParser[i]) = 1 then
begin //整数一字符集合
iLen := Length(slParser[i]);
if iLen > 13 then //=13表明字符集合为空,则用默认值
begin
with ParserList[iParserIdx] do
begin
Int_1_Chars := Copy(slParser[i], 14, Length(slParser[i]) - (14 - 1));
end;
end
end
else if Pos('/Int 2 Chars=', slParser[i]) = 1 then
begin //整数二字符集合
iLen := Length(slParser[i]);
if iLen > 13 then //=13表明字符集合为空,则用默认值
begin
with ParserList[iParserIdx] do
begin
Int_2_Chars := Copy(slParser[i], 14, Length(slParser[i]) - (14 - 1));
end;
end
end
else if Pos('/Int 3 Chars=', slParser[i]) = 1 then
begin //整数三字符集合
iLen := Length(slParser[i]);
if iLen > 13 then //=13表明字符集合为空,则用默认值
begin
with ParserList[iParserIdx] do
begin
Int_3_Chars := Copy(slParser[i], 14, Length(slParser[i]) - (14 - 1));
end;
end
end
else if Pos('/Int 4 Chars=', slParser[i]) = 1 then
begin //整数四字符集合
iLen := Length(slParser[i]);
if iLen > 13 then //=13表明字符集合为空,则用默认值
begin
with ParserList[iParserIdx] do
begin
Int_4_Chars := Copy(slParser[i], 14, Length(slParser[i]) - (14 - 1));
end;
end
end
else if Pos('/Float Chars=', slParser[i]) = 1 then
begin //浮点数字符集合
iLen := Length(slParser[i]);
if iLen > 13 then //=13表明字符集合为空,则用默认值
begin
with ParserList[iParserIdx] do
begin
Float_Chars := Copy(slParser[i], 14, Length(slParser[i]) - (14 - 1));
end;
end
end
else if Pos('//', slParser[i]) = 1 then
begin //注释行则跳过
end
else //其余行作为“单词”处理!!!
begin
if (iWordsIdx > 0) and (slParser[i] <> '') then
AppendWords(iWordsIdx, slParser[i]);
end
;
end;
finally
slTemp.Free;
end;
end;
procedure TSkyManager.LoadParserFile(const sFileName: String);
var //载入语法文件
slParser: TStrings;
begin
if FileExists(sFileName) then
begin
FreeSkyParserOfList(); //先释放 SkyParser 语法解析器
slParser := TStringList.Create;
try
slParser.LoadFromFile(sFileName);
ParserSyntax(slParser);
finally
slParser.Free;
end;
end;
end;
function TSkyManager.GetParserByFileExt(const sFileExt: String): TSkyParser;
var //根据文件扩展名取得相应的 SkyParser 语法解析器
idx: Integer;
begin
Result := GetParserByFileExt(sFileExt, idx);
end;
function TSkyManager.GetParserByFileExt(const sFileExt: String;
var iParserIdx: Integer): TSkyParser;
var //根据文件扩展名取得相应的 SkyParser 语法解析器
i: Integer;
sExt: String;
begin
Result := nil;
iParserIdx := -1;
sExt := sFileExt;
if (sExt <> '') and (sExt[1] = '.') then
Delete(sExt, 1, 1);
if sExt <> '' then
begin
for i := 0 to FParserList.Count - 1 do
if TSkyParser(FParserList.Items[i]).FileExtentions.IndexOf(sExt) >= 0 then
begin
Result := TSkyParser(FParserList.Items[i]);
iParserIdx := i;
Break;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -