notepad-plus-plus / userDefinedLanguages

Notepad++ User Defined Languages Collection
593 stars 380 forks source link

LSL - Linden Script Language #253

Closed Kimpa-Tammas closed 4 months ago

Kimpa-Tammas commented 4 months ago

LSL Portal: https://wiki.secondlife.com/wiki/LSL_Portal

pryrt commented 4 months ago

@MAPJe71,

Folder name should be autoCompletion.

It would probably make sense for me to rename the directory in this repo... but that rename has nothing to do with this PR. Specifically, the name of the directory is not why the tests fail. I'll create an issue for me to rename this.

The tests fail because the XML validation used assumes that the <?xml prolog will be the first text in the XML file, whereas this submission starts with a comment. (See this SO answer to show the references for why the prolog needs to go first.)

@Kimpa-Tammas , you will need to edit the auto-completion file to start the file with the prolog and put the comment after the prolog.

@MAPJe71,

Missing unit test for the function list.

I have never really looked into the function list unit tests that are performed when a function list is added to the main application -- do those unit tests require access to notepad++.exe? or are they run purely in the test framework? That is: can I easily replicate the test interface that's used in the app repo here in the UDL-specific repo? I'll create an issue for me to work on adding this unit-testing (assuming it can be easily replicated in this repo).

And thank you for the detailed point-by-point commentary for the fixes that need to go in the functionList definition -- I was gonig to be asking you whether those openSymbole/closeSymbole were really allowed. I had just taken the XSD for validating functionList from @swgmike and @vinsworldcom, and wasn't sure if those were just attributes they'd missed, or if they really weren't allowed. Looks like they're really not allowed.

update: actually, I'll ask for clarifications in the inline comments

chcg commented 4 months ago

See https://github.com/notepad-plus-plus/userDefinedLanguages/actions/runs/9487334246/job/26147370232


autoCompletions\LSL_byKimpaTammas.xml
{'category': 'error',
 'details': '',
 'message': 'autoCompletions\\LSL_byKimpaTammas.xml: '
            'autoCompletions/LSL_byKimpaTammas.xml:16:6:FATAL:PARSER:ERR_RESERVED_XML_NAME: '
            'XML declaration allowed only at the start of the document: '
            'XMLSyntaxError Invalid File'}

Furthermore there is a extra > in line 1494 at </KeyWord>>

pryrt commented 4 months ago

@Kimpa-Tammas ,

I grabbed On/Off Example Using States as my example file, and when I used your UDL and FunctionList for that example, I only see the touch_end from the state off section: image

Based solely on looking at the code, but not knowing anything about LSL other than the couple paragraphs I skimmed around that example code, my initial guess would have been that the FunctionList interpretation should have default as a class with functions state_entry and touch_end inside, and class state off with state_entry and touch_end inside. But that was just a guess.

If you've got a better example LSL file, which shows some functions that you think should end up in the FunctionList, could you add that example LSL file as UDL-samples\LSL_byKimpaTammas.lsl , and then after you have pushed that to this PR, could you paste a screenshot of how you expect it to render in the FunctionList panel, so that we can know what you consider a "good" interpretation of "functions" and "classes" for LSL.

Kimpa-Tammas commented 4 months ago

The color syntax is OK. default is the default state and required for all scripts. state off is a custom state (named 'off' in this case). state is a reserved keyword. state_entry or touch_end are events. state_entry is triggered when the script starts and touch_end is triggered at this end of a mouse click. The default state and one event at least are needed to compile a script. This is a preview with my editor:

LSL preview script

Also, I added a sample script in UDL-samples\LSL_byKimpaTammas.

pryrt commented 4 months ago

Also, I added a sample script in UDL-samples\LSL_byKimpaTammas

Thank you for that: I can see your FunctionList working now, so I'll accept your PR. I'll actually use yours to help implement the Unit Test in #255

MAPJe71 commented 4 months ago

@pryrt

My bad, I totally missed that this is not in the Notepad++ main repository.

do those unit tests require access to notepad++.exe?

Yes, Notepad++ is called with the appropriate/special command line arguments. It runs "headless" and creates a JSON file which contains a representation of the functionList-tree. This JSON output is then compared to the reference JSON to determine whether or not the applicable parser works as expected.

And thank you for the detailed point-by-point commentary for the fixes that need to go in the functionList definition

You're welcome.