-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add Luau language #6612
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
Merged
Merged
Add Luau language #6612
Changes from 4 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
7febf72
Feature: Add `Luau` language.
robloxiandemo 912f57c
Featire: Add `Luau` code samples.
robloxiandemo 81be622
Feature: Add the grammar.
robloxiandemo 77339ab
Feature: Add `Luau` to grammar index.
robloxiandemo 428f5d2
Fix: Add comment block and change the interpreter.
robloxiandemo 1eced93
Feature: Add new samples in place of the old ones.
robloxiandemo c0dd82e
Patch: Slight typo in the header.
robloxiandemo a3a4286
Patch: Header typos again, I'm such a genius.
robloxiandemo ba342d6
Patch: Introduce the languageId.
robloxiandemo 7463c5f
Patch: Resolve grammar conflict.
robloxiandemo f55cbc5
Patch: Resolve grammar conflict.
robloxiandemo b99f319
Patch: Update the hex value.
robloxiandemo 92bed6f
Patch: Update the hex value.
robloxiandemo 3ae7360
Sort
lildude 5f21201
Patch: Update the submodule to the latest commit.
robloxiandemo 405f7e4
Patch: Resolve merge conflicts.
robloxiandemo f0db075
Patch: Resolve further conflicts.
robloxiandemo 3588fea
Patch: Remove conflict.
robloxiandemo f5eaf45
Patch: Reintroduce Luau into grammar index.
robloxiandemo 1173698
Revert "Patch: Reintroduce Luau into grammar index."
robloxiandemo ec33c7d
Merge branch 'github-linguist:master' into master
robloxiandemo 4d4b3eb
Patch: Retry resolving the conflict issue.
robloxiandemo afcdb27
Update vendor/licenses/git_submodule/Luau.tmLanguage.dep.yml
lildude d005379
Enhancement: Update old samples and their sources.
robloxiandemo 2f9a8a2
Patch: Update old samples and their sources.
robloxiandemo 6f5e853
Merge branch 'master' of https://github.com/robloxiandemo/linguist
robloxiandemo deb5f00
Patch: Update old samples and their sources.
robloxiandemo e3f8ba2
Merge branch 'master' of https://github.com/robloxiandemo/linguist
robloxiandemo f80ee08
Patch: Update old samples and their sources.
robloxiandemo 0c0382a
Merge branch 'master' of https://github.com/robloxiandemo/linguist
robloxiandemo 8fa4f1f
Patch: Update the samples further.
robloxiandemo 481ae46
Revert "Patch: Update old samples and their sources."
robloxiandemo 7bfe7ca
Test: New samples, sadly one source.
robloxiandemo b363c0c
Merge branch 'master' into master
lildude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --[[ | ||
| Simple signal/slot implementation | ||
| ]] | ||
| local signal_mt = { | ||
| __index = { | ||
| register = table.insert | ||
| } | ||
| } | ||
| function signal_mt.__index:emit(... --[[ Comment in params ]]) | ||
| for _: number, slot: any in ipairs(self) do | ||
| slot(self, ...) | ||
| end | ||
| end | ||
| local function create_signal(): typeof(signal_mt) | ||
| return setmetatable({}, signal_mt) | ||
| end | ||
|
|
||
| -- Signal test | ||
| local signal: typeof(signal_mt) = create_signal() | ||
| signal:register(function(_signal, ...) | ||
| print(...) | ||
| end) | ||
| signal:emit('Answer to Life, the Universe, and Everything:', 42) | ||
|
|
||
| -- Output test | ||
| local testNumber: number = 10 | ||
|
|
||
| print(`this is line, and "testNumber" equals to: {testNumber}.`) | ||
|
|
||
| --[==[ [=[ [[ | ||
| Nested ]] | ||
| multi-line ]=] | ||
| comment ]==] | ||
| [==[ Nested | ||
| [=[ multi-line | ||
| [[ string | ||
| ]] ]=] ]==] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| --// Vector | ||
| --// Written by Demo (R0BL0XIAN_D3M0) | ||
| --// [https://www.roblox.com/users/289025524/profile] | ||
| --// 11/09/2023 | ||
|
|
||
| --// Types | ||
| type TVector = Vector2 | Vector3 | ||
|
|
||
| --[=[ | ||
| @class Vector | ||
|
|
||
| A collection of very useful vector-related functions. | ||
| ]=] | ||
| local Vector = {} | ||
|
|
||
| --// Functions | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @param vector Vector2 -- The `Vector2` coordinate. | ||
|
|
||
| @return Vector3 -- Return the newly created `Vector3`. | ||
|
|
||
| Create a `Vector3` from a `Vector2` within the XY plane. | ||
| ]=] | ||
| function Vector.FromVector2XY(vector: Vector2): Vector3 | ||
| return (Vector3.new(vector.X, vector.Y, 0)) | ||
| end | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @param vector Vector2 -- The `Vector2` coordinate. | ||
|
|
||
| @return Vector3 -- Return the newly created `Vector3`. | ||
|
|
||
| Create a `Vector3` from a `Vector2` within the XZ plane, unlike `FromVector2XY`. | ||
| ]=] | ||
| function Vector.FromVector2XZ(vector: Vector2): Vector3 | ||
| return (Vector3.new(vector.X, 0, vector.Y)) | ||
| end | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @param vector Vector2 -- The initial `Vector2` coordinate. | ||
|
|
||
| @param _vector Vector2 -- The secondary `Vector2` coordinate. | ||
|
|
||
| @return number -- Return the computed angle in a numerical form or nil. | ||
|
|
||
| Compute the angle between two vectors in radians. | ||
| ]=] | ||
| function Vector.RetrieveAngleRadian(vector: Vector2, _vector: Vector2): number? | ||
| if vector.Magnitude == 0 then | ||
| return nil | ||
| end | ||
|
|
||
| return (math.acos(vector:Dot(_vector))) | ||
| end | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @param vector Vector2 -- The initial `Vector2` coordinate. | ||
|
|
||
| @param _vector Vector2 -- The secondary `Vector2` coordinate. | ||
|
|
||
| @return number -- Return the computed angle in a numerical form. | ||
|
|
||
| Compute the angle between two vectors. | ||
| ]=] | ||
| function Vector.AngleBetweenVectors(vector: Vector2, _vector: Vector2): number | ||
| local newVector: Vector2 = (_vector.Magnitude * vector) | ||
| local _newVector: Vector2 = (vector.Magnitude * _vector) | ||
|
|
||
| return (2 * (math.atan2((_newVector - newVector).Magnitude, (newVector + _newVector).Magnitude))) | ||
| end | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @param vector Vector3 -- The original `Vector3` coordinate. | ||
|
|
||
| @param amount number -- The primary amount. | ||
|
|
||
| @return Vector3 -- Return the rounded `Vector3`. | ||
|
|
||
| Round the specified `Vector3` to the nearest number. | ||
| ]=] | ||
| function Vector.Round(vector: Vector3, amount: number): Vector3 | ||
| return ( | ||
| Vector3.new( | ||
| ((math.round(vector.X / amount)) * amount), | ||
| ((math.round(vector.Y / amount)) * amount), | ||
| ((math.round(vector.Z / amount)) * amount) | ||
| ) | ||
| ) | ||
| end | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @param vector TVector -- The vector coordinate (`Vector2` or `Vector3`). | ||
|
|
||
| @param maxMagnitude number -- The maximum magnitude. | ||
|
|
||
| @return number -- Return the clamped magnitude. | ||
|
|
||
| Clamp the magnitude of a vector so it is only a certain length. | ||
| ]=] | ||
| function Vector.ClampMagnitude(vector: TVector, maxMagnitude: number): number | ||
| return ((vector.Magnitude > maxMagnitude) and (vector.Unit * maxMagnitude) or vector) | ||
| end | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @param vector TVector -- The initial vector coordinate (`Vector2` or `Vector3`). | ||
|
|
||
| @param _vector TVector -- The secondary vector coordinate (`Vector2` or `Vector3`). | ||
|
|
||
| @return number -- Return the radianed angle. | ||
|
|
||
| Finds the angle in radians between two vectors. | ||
| ]=] | ||
| function Vector.AngleBetween(vector: TVector, _vector: TVector): number | ||
| return (math.acos(math.clamp(vector.Unit:Dot(_vector.Unit), -1, 1))) | ||
| end | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @param vector TVector -- The initial vector coordinate (`Vector2` or `Vector3`). | ||
|
|
||
| @param _vector TVector -- The secondary vector coordinate (`Vector2` or `Vector3`). | ||
|
|
||
| @param axisVector Vector -- The axis vector coordinate (`Vector` or `Vector3`). | ||
|
|
||
| @return number -- Return the radianed angle. | ||
|
|
||
| Finds the angle in radians between two vectors and returns a signed value. | ||
| ]=] | ||
| function Vector.AngleBetweenSigned(vector: TVector, _vector: TVector, axisVector: TVector): number | ||
| local angle: number = Vector.AngleBetween(vector, _vector) | ||
|
|
||
| return (angle * (math.sign(axisVector:Dot(vector:Cross(_vector))))) | ||
| end | ||
|
|
||
| --[=[ | ||
| @within Vector | ||
|
|
||
| @return Vector3 -- Return the random `Vector3` coordinate. | ||
|
|
||
| Return a random unit vector (could be used for equal distribution around a sphere). | ||
| ]=] | ||
| function Vector.RetrieveRandomUnitVector(): Vector3 | ||
| local randomX: number = (2 * ((math.random()) - 0.5)) | ||
| local randomY: number = (6.2831853071796 * (math.random())) | ||
| local randomZ: number = ((1 - (randomX * randomX)) ^ 0.5) | ||
|
|
||
| local X: number = randomX | ||
| local Y: number = (randomZ * (math.cos(randomZ))) | ||
| local Z: number = (randomZ * (math.sin(randomY))) | ||
|
|
||
| return (Vector3.new(X, Y, Z)) | ||
| end | ||
|
|
||
| return Vector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule luau.tmLanguage
added at
9f320a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: Luau.tmLanguag | ||
| version: 9f320add6dd099f99897a03c5e2ce3ca5f176d7f | ||
| type: git_submodule | ||
| homepage: https://github.com/JohnnyMorganz/Luau.tmLanguage.git | ||
| license: mit | ||
| licenses: | ||
| - sources: LICENSE.md | ||
| text: |- | ||
| Copyright (c) JohnnyMorganz | ||
| All rights reserved. | ||
|
|
||
| MIT License | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
|
|
||
| === | ||
|
|
||
| Copyright (c) Microsoft Corporation | ||
| All rights reserved. | ||
|
|
||
| MIT License | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
| notices: [] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.