Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSL - Linden Script Language #253

Merged
merged 7 commits into from
Jun 13, 2024
Merged

Conversation

Kimpa-Tammas
Copy link
Contributor

@Kimpa-Tammas Kimpa-Tammas commented Jun 12, 2024

Copy link

@MAPJe71 MAPJe71 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Folder name should be autoCompletion.

Copy link

@MAPJe71 MAPJe71 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing unit test for the function list.

</className>
<function
mainExpr="(?x)(?:\b(state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|experience_permissions(?:_denied)?|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|linkset_data|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b)\s*(?:\((?:\b(?:(?:float|integer|key|list|quaternion|rotation|string|vector)\s+(?:[A-Za-z_]\w*))\b(?:\s*,\s*(?:\b(?:(?:float|integer|key|list|quaternion|rotation|string|vector)\s+(?:[A-Za-z_]\w*))\b))*)?\))(?=\s*\{)"
openSymbole="\{"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attributes openSymbole and closeSymbole are not supported for function-nodes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these "not supported" (ie, it can be there, but Notepad++ does nothing with it), or "not allowed" (ie, it shouldn't be there at all)? Because if it's truly just "not supported but allowed-and-ignored", then I need to change the XSD to make it allowed.

</classRange>
<function
mainExpr="(?x)(?:\b(?:(?:float|integer|key|list|quaternion|rotation|string|vector)\s+)?([A-Za-z_]\w*)\b)\s*\((?:\b(?:(?:float|integer|key|list|quaternion|rotation|string|vector)\s+(?:[A-Za-z_]\w*))\b(?:\s*,\s*(?:\b(?:(?:float|integer|key|list|quaternion|rotation|string|vector)\s+(?:[A-Za-z_]\w*))\b))*)?\)(?=\s*\{)"
openSymbole="\{"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attributes openSymbole and closeSymbole are not supported for function-nodes.

mainExpr="(?x)(?:\b(?:(?:float|integer|key|list|quaternion|rotation|string|vector)\s+)?([A-Za-z_]\w*)\b)\s*\((?:\b(?:(?:float|integer|key|list|quaternion|rotation|string|vector)\s+(?:[A-Za-z_]\w*))\b(?:\s*,\s*(?:\b(?:(?:float|integer|key|list|quaternion|rotation|string|vector)\s+(?:[A-Za-z_]\w*))\b))*)?\)(?=\s*\{)"
openSymbole="\{"
closeSymbole="\}"
displayMode="$functionName"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The displayModeis not supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it "not supported" (ie, it can be there, but Notepad++ does nothing with it), or "not allowed" (ie, it shouldn't be there at all)? Because the User Manual says that the <function> and <classRange> elements both have that attribute, but it's "reserved for future use". And, for example, your vb-3.0.FL.xml

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be there, but Notepad++ does nothing with it.

And, for example, your vb-3.0.FL.xml

My Languages repository is far from up-to-date. I tend to remove the attributes, etc. that are not currently used, add comment and reformat the XML text to accommodate the comments.
The vb-3.0.FL.xml is an almost raw copy of a Notepad++ SourceForge topic. AFAICT I only added some comment (e.g. L_VB and vb_function).

>
<className>
<nameExpr expr="\b(?:(state)\s+(?:[A-Za-z_]\w*))\b" />
<nameExpr expr="\b(default)\b" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nameEpxr-nodes work as consecutive filters.
The first expr-pattern is used to find a match in any text that matched the mainExpr.
The second expr-pattern is used to find a match in the matched text of the first expression.

commentExpr="(?:(/\*.*?\*/)|(//.*?$))"
>
<classRange
mainExpr="(?x)(?:\b(?:(state)\s+(?:[A-Za-z_]\w*)|(default))\b)(?=\s*\{)"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous parentheses around state and around default.
Numbered and named capturing groups are not supported.

@pryrt
Copy link
Contributor

pryrt commented Jun 12, 2024

@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
Copy link
Contributor

chcg commented Jun 12, 2024

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>>

Kimpa-Tammas and others added 2 commits June 13, 2024 10:18
Comments on top removed, ending tag </keyword>> fixed.
- remove `openSymbole` and `closeSymbole` from the `<function>` elements
- remove `displayMode`
@pryrt
Copy link
Contributor

pryrt commented Jun 13, 2024

@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.

Pose ball LSL script sample
@Kimpa-Tammas
Copy link
Contributor Author

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
Copy link
Contributor

pryrt commented Jun 13, 2024

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

@pryrt pryrt merged commit 8900aad into notepad-plus-plus:master Jun 13, 2024
1 check passed
@MAPJe71
Copy link

MAPJe71 commented Jun 13, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants