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

Added SQF language #2079

Merged
merged 12 commits into from
Oct 16, 2019
Merged

Added SQF language #2079

merged 12 commits into from
Oct 16, 2019

Conversation

RunDevelopment
Copy link
Member

This resolves #2067.

There is no spec for this language, but there is a wiki from the Amra 3 devs.
Here are the most relevant pages: syntax, numbers, strings, control structures, commands, functions, operators, data types, preprocessing, and examples.

I wasn't able to find any copyright-free SQF code and from my understanding, the entire wiki is owned by Bohemia Interactive. So if somebody has an example, I can use, please tell me.

Example

image

source

@jonpas
Copy link

jonpas commented Oct 2, 2019

You may use anything from https://github.com/CBATeam/CBA_A3 or https://github.com/acemod/ACE3 for examples. :)

In addition, GitHub's linguist syntax for SQF may be taken as a reference to keep it consistent. Source for it can be found at https://github.com/JonBons/Sublime-SQF-Language.

Very nice to see this! It was brought up in ACE Slack and I am sure some developers will comment on here and help out!

Should have read the doc instead of mindlessly copying every entry...
@RunDevelopment
Copy link
Member Author

@jonpas and @BaerMitUmlaut Thank you for reviewing my PR and given me such fine example code!

I actually used https://github.com/JonBons/Sublime-SQF-Language as reference, so this shouldn't stray too far from it.

components/prism-sqf.js Outdated Show resolved Hide resolved
components/prism-sqf.js Outdated Show resolved Hide resolved
@RunDevelopment
Copy link
Member Author

I have a few questions regarding keywords:

  1. Keywords are case-insensitive (?i:. Is that true?
  2. What are all these keywords of the form DIK(?:_[A-Z\d])+ like DIK_0|DIK_1|DIK_APPS|DIK_BACKSLASH|DIK_CAPITAL?
  3. I went through the whole keyword list and apart from point 2., these are the only ones not being keywords right now: forEachMember|forEachMemberAgent|forEachMemberTeam|spawn|preprocessFile|preprocessFileLineNumbers|execVM|execFSM. None of them seem to function as keywords, so we might as well let them be functions. Thoughts?

@BaerMitUmlaut
Copy link

  1. Yes, most of SQF is case insensitive. There are a couple exceptions with string comparisons, but that's irrelevant for highlighting.
  2. Keycode macros. DIK stands for direct input keycode.
  3. In reality, SQF only has one keyword, which is private. if, then, for etc. are actually commands just like setPos. However, commands that are used for control flow are usually highlighted as keywords for readability and because they're treated as keywords by most SQF scripters.

@jonpas
Copy link

jonpas commented Oct 3, 2019

  1. What @BaerMitUmlaut said, I think we should just keep consistent with https://github.com/JonBons/Sublime-SQF-Language on keywords/functions.

@RunDevelopment
Copy link
Member Author

  1. Ok. It wasn't specified in the wiki, so I assumed it's case-sensitive.
  2. Added as constant.
  3. @jonpas I would actually like to keep the current keyword list and I don't think we should have https://github.com/JonBons/Sublime-SQF-Language make the final decision here. It's not even sure whether execFSM should be a keyword or a function (it's included in both lists). (Also, if execVM and execFSM are keywords, then why isn't execEditorScript? Btw. exec is missing completely.)
    My point is that we should highlight functions as keywords because they function as keywords and not because they are included in this list.
    Also, some of them seem oddly specific to be keyword... preprocessFileLineNumbers.
    Then again, I never even wrote a single line of code in SQF, so maybe I shouldn't decide this.
    Further input would be very welcome.

@jonpas
Copy link

jonpas commented Oct 3, 2019

It is a grey area, neither of those are actually functions nor keywords (macros, which are all upper-case are), but are scripting commands, functions is something you can write with SQF, such as ace_common_fnc_banana or BIS_fnc_camera.

I agree that Sublime-SQF-Language is not perfect either, maybe @JonBons can pitch in and we can streamline both.

@BaerMitUmlaut
Copy link

BaerMitUmlaut commented Oct 3, 2019

Also, if execVM and execFSM are keywords, then why isn't execEditorScript?

Because that command doesn't do anything.

Btw. exec is missing completely.

That one is used to run SQS scripts, which are basically deprecated since 2002. That one does actually do something though.

I never even wrote a single line of code in SQF

You must think we're maniacs.

@RunDevelopment
Copy link
Member Author

Alright, I added the remaining "keywords".
Since, as @jonpas said, it's a grey area, so it shouldn't matter too much whether they are or not, so I'll just make them what you want.

@mharis001
Copy link

The current list looks good to me 👍.

@JonBons
Copy link

JonBons commented Oct 5, 2019

As for my repo, I generated the first version of it programmatically and I've never actually spent time cleaning it up but at the moment I don't have any time to take a look into it and I won't for the foreseeable future.

@RunDevelopment RunDevelopment merged commit cfac94e into PrismJS:master Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQF
5 participants