Added: primitive support for ZScript in the script editor (all classes in the current file are listed)

This commit is contained in:
ZZYZX 2017-02-09 02:26:25 +02:00
parent 1382d144fe
commit 7f2f51d48d
7 changed files with 83 additions and 11 deletions

View file

@ -0,0 +1,25 @@
/*******************************************************************\
GZDoom Builder Script highlighting definitions for ZSCRIPT
\*******************************************************************/
// Editor settings
description = "ZDoom ZSCRIPT";
codepage = 0;
extensions = "txt";
casesensitive = false;
terminator = ";";
insertcase = 1; // 0=Normal, 1=Lowercase, 2=Uppercase
lexer = 35; // CPP-style, case-insensitive
keywordhelp = "http://zdoom.org/wiki/ZScript";
scripttype = "ZSCRIPT";
// todo
keywords
{
}
constants
{
}

View file

@ -141,6 +141,7 @@
<Compile Include="Data\FileImage.cs" /> <Compile Include="Data\FileImage.cs" />
<Compile Include="Data\FlatImage.cs" /> <Compile Include="Data\FlatImage.cs" />
<Compile Include="Data\ImageLoadState.cs" /> <Compile Include="Data\ImageLoadState.cs" />
<Compile Include="Data\Scripting\ZScriptScriptHandler.cs" />
<Compile Include="Data\UnknownImage.cs" /> <Compile Include="Data\UnknownImage.cs" />
<Compile Include="Data\PatchNames.cs" /> <Compile Include="Data\PatchNames.cs" />
<Compile Include="Data\PK3Reader.cs" /> <Compile Include="Data\PK3Reader.cs" />
@ -523,6 +524,7 @@
<Compile Include="ZDoom\DecorateActorStructure.cs" /> <Compile Include="ZDoom\DecorateActorStructure.cs" />
<Compile Include="ZDoom\DecorateStateGoto.cs" /> <Compile Include="ZDoom\DecorateStateGoto.cs" />
<Compile Include="ZDoom\DecorateStateStructure.cs" /> <Compile Include="ZDoom\DecorateStateStructure.cs" />
<Compile Include="ZDoom\Scripting\ZScriptParserSE.cs" />
<Compile Include="ZDoom\ZScriptActorStructure.cs" /> <Compile Include="ZDoom\ZScriptActorStructure.cs" />
<Compile Include="ZDoom\ZScriptParser.cs" /> <Compile Include="ZDoom\ZScriptParser.cs" />
<Compile Include="ZDoom\ZScriptStateGoto.cs" /> <Compile Include="ZDoom\ZScriptStateGoto.cs" />

View file

@ -212,7 +212,7 @@ namespace CodeImp.DoomBuilder.Config
terminator = cfg.ReadSetting("terminator", ""); terminator = cfg.ReadSetting("terminator", "");
extrawordchars = cfg.ReadSetting("extrawordchars", ""); //mxd extrawordchars = cfg.ReadSetting("extrawordchars", ""); //mxd
//mxd. Get script type... //mxd. Get script type...
string scripttypestr = cfg.ReadSetting("scripttype", string.Empty); string scripttypestr = cfg.ReadSetting("scripttype", string.Empty);
if(!string.IsNullOrEmpty(scripttypestr)) if(!string.IsNullOrEmpty(scripttypestr))
{ {
@ -233,8 +233,8 @@ namespace CodeImp.DoomBuilder.Config
scripttype = ScriptType.UNKNOWN; scripttype = ScriptType.UNKNOWN;
} }
//mxd. Make braces array //mxd. Make braces array
if(!string.IsNullOrEmpty(functionopen)) braces.Add(functionopen[0]); if (!string.IsNullOrEmpty(functionopen)) braces.Add(functionopen[0]);
if(!string.IsNullOrEmpty(functionclose)) braces.Add(functionclose[0]); if(!string.IsNullOrEmpty(functionclose)) braces.Add(functionclose[0]);
if(!string.IsNullOrEmpty(codeblockopen)) braces.Add(codeblockopen[0]); if(!string.IsNullOrEmpty(codeblockopen)) braces.Add(codeblockopen[0]);
if(!string.IsNullOrEmpty(codeblockclose)) braces.Add(codeblockclose[0]); if(!string.IsNullOrEmpty(codeblockclose)) braces.Add(codeblockclose[0]);

View file

@ -30,6 +30,6 @@ using CodeImp.DoomBuilder;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.3.0.2872")] [assembly: AssemblyVersion("2.3.0.2873")]
[assembly: NeutralResourcesLanguageAttribute("en")] [assembly: NeutralResourcesLanguageAttribute("en")]
[assembly: AssemblyHash("0d43a7b")] [assembly: AssemblyHash("1382d14")]

View file

@ -34,13 +34,13 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
// Continue until at the end of the stream // Continue until at the end of the stream
while(SkipWhitespace(true)) while(SkipWhitespace(true))
{ {
string token = ReadToken(); int startpos = (int)datastream.Position;
string token = ReadToken();
if(string.IsNullOrEmpty(token) || token.ToUpperInvariant() != "ACTOR") continue; if(string.IsNullOrEmpty(token) || token.ToUpperInvariant() != "ACTOR") continue;
SkipWhitespace(true); SkipWhitespace(true);
int startpos = (int)datastream.Position;
List<string> definition = new List<string>(); List<string> definition = new List<string>();
definition.Add(token); // actor ... ..., not just class name
do do
{ {

View file

@ -35,6 +35,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
while(SkipWhitespace(true)) while(SkipWhitespace(true))
{ {
string token = ReadToken(); string token = ReadToken();
long cpos = datastream.Position;
if(!string.IsNullOrEmpty(token)) if(!string.IsNullOrEmpty(token))
{ {
@ -70,7 +71,7 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
} }
} }
else if(token == "ACTOR") else if(token == "ACTOR") // [ZZ] note: by the looks of it, this doesn't handle the case when we write actor with DoomEdNum.
{ {
SkipWhitespace(true); SkipWhitespace(true);
ReadToken(); //should be actor name ReadToken(); //should be actor name
@ -78,7 +79,8 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
SkipWhitespace(true); SkipWhitespace(true);
token = ReadToken(); token = ReadToken();
if(token == ":" || token == "{" || token == "REPLACES") // [ZZ] note: original code compared token to REPLACES without doing ToUpper
if(token == ":" || token == "{" || (token != null && token.ToUpperInvariant() == "REPLACES"))
{ {
scripttype = ScriptType.DECORATE; scripttype = ScriptType.DECORATE;
return true; return true;
@ -87,13 +89,56 @@ namespace CodeImp.DoomBuilder.ZDoom.Scripting
SkipWhitespace(true); SkipWhitespace(true);
token = ReadToken(); //should be actor name token = ReadToken(); //should be actor name
// [ZZ]
if (token != "{") // actor bla : bla2 10666 {
{
SkipWhitespace(true);
token = ReadToken();
}
if(token == "{") if(token == "{")
{ {
scripttype = ScriptType.DECORATE; scripttype = ScriptType.DECORATE;
return true; return true;
} }
} }
else if(token == "CLASS" || token == "STRUCT" || token == "ENUM" || token == "EXTEND")
{
if (token == "EXTEND")
{
SkipWhitespace(true);
token = ReadToken();
if (!string.IsNullOrEmpty(token))
token = token.ToUpperInvariant();
}
string otoken = token; // original token
SkipWhitespace(true);
ReadToken(); //should be actor name
SkipWhitespace(true);
token = ReadToken();
if ((otoken != "ENUM" && token == ":") || token == "{" || (otoken == "CLASS" && (token != null && token.ToUpperInvariant() == "REPLACES")))
{
scripttype = ScriptType.ZSCRIPT;
return true;
}
SkipWhitespace(true);
token = ReadToken(); //should be actor name
if (token == "{")
{
scripttype = ScriptType.ZSCRIPT;
return true;
}
return true;
}
} }
datastream.Position = cpos; // [ZZ] read next token, not whatever is left after possibly unsuccessful parsing.
} }
return false; return false;

View file

@ -29,5 +29,5 @@ using System.Resources;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.3.0.2872")] [assembly: AssemblyVersion("2.3.0.2873")]
[assembly: NeutralResourcesLanguageAttribute("en")] [assembly: NeutralResourcesLanguageAttribute("en")]