Jump to content

Photo

ZScript Code Editor


  • Please log in to reply
123 replies to this topic

#31 bobby_light

bobby_light

    Experienced Forumer

  • Members

Posted 20 August 2012 - 10:56 PM

I've taken a stab at fixing the issues you both posted. Could you please re-download and try again?

QUOTE(LinktheMaster @ Aug 20 2012, 12:48 AM) View Post

1. You don't always have to specify the length of arrays.
While you can specify the length of arrays, you don't have to. This can work in two different ways. One is with a list of numbers, such as int x[] = {1, 6, 7, 9}. The next is with strings. int y[] = "hello world". Your code shows these as errors.

I think this is now fixed. I was also assuming giving an array size was an error if you initialized an array (i.e. "int x[8] = {1, 2, 3};"), but I found a script that actually did this on PureZC, so I assume that's OK syntax-wise as well.

QUOTE

2. Object functions seem to cause errors when in for loops.
You can grab the number of items, guys, weapons, etc. on the screen with the Screen->NumWhatever() methods. Your code seems to see these as errors, stating "missing update expression of for-loop". An example would be "for(int i = 1; i <= Screen->NumLWeapons(); i++)".

Fixed, at least for the use case you gave.

QUOTE

3. There are times when the script shows "Variable declaration shadows prior variable" incorrectly.
I'm assuming this error is supposed to signal when a variable has already been declared. However, in my situation, that's not really the case. The variables were used before, but in a different scope. In my situation, I had quite a bit of if statements and loops, so I'm guessing your detection to determine the scope is just slightly off.

This should be fixed for variables in functions. Using a global variable as the iterator in a for-loop is still incorrectly flagged as an error, I'll fix that next.

QUOTE

Also, there are a couple things I noticed.
  • There's no good way to find out if a closing brace has a partner or not. You do mark its partner with a box, but I'd suggest looking at Notepad++. In it, the braces change colors. Both of them change color. If it doesn't, then you know it doesn't have a partner brace.
  • Sometimes the popup when you hover over an error doesn't seem to want to come up.

I've updated the demos so that they highlight both the matching brace and the one at the caret position. This is not yet enabled in the RText download (though it has been updated for the other issues you pointed out).

As for the popup not showing up, I think that's related to uncaught parsing errors. It's always the last error in the file, right? I believe I've fixed this, in the common cases at least.

@King Harkinian, let me know if you still have problems. I have not yet verified whether you can omit semicolons for while-loops if they're at the end of a code block, so I didn't change that yet.

#32 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 20 August 2012 - 11:29 PM

QUOTE(bobby_light @ Aug 20 2012, 10:56 PM) View Post
@King Harkinian, let me know if you still have problems. I have not yet verified whether you can omit semicolons for while-loops if they're at the end of a code block, so I didn't change that yet.
I didn't think you could, but apparently you can omit the semi-colons after the while loops. You may want to have it be a warning rather than an error?

Speaking of warnings, if you can have warnings, you should probably change the "Variable declaration shadows prior variable" message to warnings rather than errors. ZScript (amazingly) seems okay with these, but they can cause problems and confusion for people who aren't good with coding.

Another thing you should have warnings for is for script-scope global variables. Basically...

CODE
ffc script test
{
    int x = 5;

    void run()
    {...}
}


That variable x technically is legal, but it's deprecated functionality. You currently have it listed as an error. It's not a big deal, but if you wanted to look into classifying things as warnings and errors separately, it's something to look into. icon_shrug.gif

Also something that I noticed is that you don't catch semi-colons at the end of import statements that are the end of a file. ZScript doesn't actually require imports to be at the beginning of the file (which I'm guessing you're banking on).

Ignoring those weird obscure situations, everything looks good. icon_smile.gif I'm not finding anything else that looks to be incorrect. Thanks again for your hard work. icon_smile.gif

#33 bobby_light

bobby_light

    Experienced Forumer

  • Members

Posted 24 August 2012 - 11:41 PM

The demos are all updated once again. I think I've fixed all the issues pointed out so far.
  • do-whiles without trailing semicolons are no longer flagged as errors.
  • Shadowed variable detection has been improved, and is now a warning rather than an error. If folks hate it, it could be made an option (whether they are considered errors, warnings, or ignored).
  • Script-scoped variables are parsed, but flagged as warnings with a message that that functionality is deprecated.
I've also made the gutter visually highlight the deepest-nested code block the caret is in. This gives a visual cue as to where you actually are in the file. Extra useful for folks who don't indent their code well, or are otherwise poor formatters. icon_smile.gif


IPB Image


Besides project support, what other features would folks want in a ZScript editor?

Edited by bobby_light, 24 August 2012 - 11:47 PM.


#34 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 25 August 2012 - 10:08 AM

That looks brilliant, actually. icon_smile.gif The project support is the only thing I can think of personally. Once this gets finished, I recommend you posting a new topic about this, and I'll pin it for you. icon_thumbsup.gif

#35 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 26 August 2012 - 08:36 PM

I've messed around a bit and really like what I'm seeing here. Scripters out there, definitely give this a whirl! I think it's very helpful and useful. Nicely done so far. I'll definitely let you know if I find anything or have any suggestions. :3

#36 bobby_light

bobby_light

    Experienced Forumer

  • Members

Posted 09 September 2012 - 02:36 PM

Not too much has changed in the past couple of weeks, but the web and win32 demos have been updated with the new stuff added in rc4. As suggested, I'm working on project support for RText; the next release of the full editor should include that as well as ZScript support, which will be nice. I'm taking LinkTheMaster's advice and mimicking pnotepad's project support for the most part; it's pretty robust without going as far as a "real" IDE project such as from VS or Eclipse. I hope to have something available by the end of next week.

#37 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 09 September 2012 - 05:30 PM

Out of curiosity, what does this have that a normal code editor like NP++ doesn't?

#38 SUCCESSOR

SUCCESSOR

    Apprentice

  • Banned
  • Real Name:TJ

Posted 09 September 2012 - 06:14 PM

I tried this but it didn't seem to have any of the features you mention and I didn't see a way to turn them on. Maybe I need to redownload?


QUOTE(MoscowModder @ Sep 9 2012, 04:30 PM) View Post

Out of curiosity, what does this have that a normal code editor like NP++ doesn't?


It support zscript pointers, variables, and auto completion among other stuff.

Edited by SUCCESSOR, 09 September 2012 - 06:32 PM.


#39 bobby_light

bobby_light

    Experienced Forumer

  • Members

Posted 09 September 2012 - 09:17 PM

Yes, benefits over using say C++ syntax highlighting in Notepad++ include:
  • Squiggle-underlining to identify compile errors and warnings.
  • ZScript-specific syntax highlighting (for example, keywords such as "Script", "Link", and "Game" are highlighted, as well as all of their valid function and variable members will be highlighted differently than unknown members such as typos).
  • Code completion; i.e. typing "Link->" displays a popup with all members of the Link global variable. Further typing filters the list to display only those members that match what you've typed. Navigating through the completion list, you'll see the documentation from std.txt for each item, so you won't have trouble with functions you aren't yet familiar with.
  • Ctrl+Space offers not just completions for global members, but in-scope local variables you've defined as well.
  • On code-completing a function, for each function argument, a list of variables that match the required data type are provided in a dropdown list.
Basically, a whole bunch of language-specific features, above and beyond syntax highlighting and code folding.

As an example of the stuff you can do if you are aware of the language you're working with and its semantics, below is a screenshot showing another feature that will be in the next release. If you hover the mouse over a global function or property, a tool tip will display with the documentation for it.


IPB Image


(Just pretend you can see the mouse hovering over "Item"). Though this property itself is pretty straightforward, features like this are real time-savers, as you don't have to flip back and forth between std.txt (for example) and your script as much when doing hot and heavy coding. The smarter the editor is, the more efficient you can be!

@SUCCESSOR, what specific features are missing from the demo you downloaded? I think everything should be up to date. Are you using the web demo or the win32 one?

Edited by bobby_light, 09 September 2012 - 10:10 PM.


#40 SUCCESSOR

SUCCESSOR

    Apprentice

  • Banned
  • Real Name:TJ

Posted 09 September 2012 - 10:04 PM

When I used the win32 one it was just like using Notepad. When I used the web demo it worked fine.

#41 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 10 September 2012 - 02:09 AM

Great! When 2.5 is done we will have to make this available on the main zc site. icon_smile.gif


Array pointers seem to be broken ala "int function(type arrayPtr)". This is the languages fault, it seems, since there is no possible way to differentiate between an array and a single variable in this case. ... I think the solution here is a simple preprocessor macro, although there likely won't be a preprocessor in ZScript until 2.6 - I already have one as an external tool (called it ZPP) because nobody wanted it integrated into 2.5 at that time. :\ Other solution is to put a keyword into the language.

..Easiest thing to do right now is ignore the fact that they /can/ be pointers I guess.

#42 bobby_light

bobby_light

    Experienced Forumer

  • Members

Posted 10 September 2012 - 10:08 PM

Yes, you're right. I can't determine if it's an array or not. What happens if you pass an eweapon (for example) as a function argument, but then the function treats it as an array? Does ZC gracefully recover?

I mentioned this in this other thread. My suggestion would be to allow syntax similar to Java. A method signature with an array argument would look like:

CODE

int doSomething(int buffer[]) {
  // ...
}


This makes it easy to determine whether it's a scalar or an array.

If it'd be possible to make the compiler accept this syntax in 2.5, I'd think it would be a great thing, since it removes ambiguity. Even if it still accepted the "old" syntax as well, at least you could document it and tell folks to use the more explicit syntax for array params.

#43 SUCCESSOR

SUCCESSOR

    Apprentice

  • Banned
  • Real Name:TJ

Posted 11 September 2012 - 05:44 PM

Okay what I meant to say is that the demo's are working fine but the full program with plugin does nothing. It acts like a normal text editor. As I said if there is a way to "turn on" the plugins I haven't found it.

#44 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 13 September 2012 - 10:31 AM

What file extension are your script files?

#45 bobby_light

bobby_light

    Experienced Forumer

  • Members

Posted 13 September 2012 - 10:16 PM

That's a good point; if you're using RText, you have to open a .zh file for ZScript highlighting and other features to be enabled. Opening other files will syntax highlight for C, Java, and many other languages based on file extension (configurable from the Options dialog).


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users