├── .gitignore ├── README.md ├── functions ├── leap.js ├── manifest.js ├── preprocessResource.js └── utils.js ├── fxmanifest.lua ├── main.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Leap V3

2 | 3 | `Leap` (**L**ua **e**xtension **a**ccessibility **p**re-processor) is a fast pre-processor of a "modernized" and extended version of lua that pre-processes in pure executable lua. 4 | Think of it as an effective "modernity" leap into the future to make lua a feature-rich language. 5 | 6 | Leap is inspired by the functionality and syntax found in [JS](https://www.javascript.com) and is primarily intended for [**FiveM**](https://fivem.net), this however does not deny the possibility of extension to wider horizons. 7 | 8 | To assist with debugging and error reporting, Leap retains the original line numbers from the code. 9 | 10 | Leap features a caching system that processes only the files that have been modified, ensuring that the resource is only preprocessed when necessary; if no changes are detected, the resource will simply restart. 11 | You can find the files created by this system under the `cache` folder in the root folder of your server (near the `resources` folder) 12 | 13 | After preprocessing, Leap automatically adds the `build` subfolder (if needed) to all file declarations in the `fxmanifest.lua` under the `client`, `server`, `shared`, and `escrow_ignore` sections. 14 | Since it will modify the `fxmanifest.lua` it requires the permission to run the `refresh` command, you can allow this by adding `add_ace resource.leap command.refresh allow` in your `server.cfg` 15 | 16 | > The [vscode syntax highlight extension is available!](https://marketplace.visualstudio.com/items?itemName=XenoS.leap-lua), to contribute visit [leap_syntax_highlight_vscode](https://github.com/XenoS-ITA/leap_syntax_highlight_vscode). 17 | 18 | > **Note** To contribute to the grammar and/or preprocessor in general please visit [leap_preprocessor](https://github.com/XenoS-ITA/leap_preprocessor). 19 | 20 | ## Usage 21 | To use Leap, simply download it and start it as you would with any normal resource. You'll need to add Leap to your resource's dependencies, after which you can access any of its features. When the resource starts, Leap will handle the preprocessing of the necessary files automatically. 22 | 23 | Example: 24 | `your_resource_that_use_leap > fxmanifest.lua`: 25 | ```lua 26 | fx_version "cerulean" 27 | game "gta5" 28 | 29 | server_script "server.lua" 30 | 31 | dependency "leap" -- This is necessary to have the resource automatically preprocessed 32 | ``` 33 | 34 | You can also manually use the `leap restart your_resource_that_use_leap` command to preprocess the files and restart the resource. 35 | 36 | ### Escrow 37 | To use Leap under escrow or outside the Leap ecosystem, please deploy only the build folder, excluding the source as its not "standard" lua syntax 38 | 39 | ## Commands 40 | **TIP**: these commands can also be used in the cfg after the leap startup. 41 | 42 | ### leap restart 43 | `leap restart ` build and restarts the resource, manual version of the more classic `restart ` 44 | 45 | --- 46 | 47 | ### leap build 48 | `leap build ` pre-processes the resource by creating a subfolder named `build` that contains the pre-processed version of the resource (This will ignore the cache) 49 | 50 | resource structure tree after build: 51 | ``` 52 | │ fxmanifest.lua 53 | │ 54 | ├───build 55 | │ └───server 56 | │ main.lua 57 | │ 58 | └───server 59 | main.lua 60 | ``` 61 | 62 | --- 63 | 64 | ## Leap Library 65 | 66 | ### leap.deserialize 67 | Converts serialized class back into an instance of a specific class, restoring the object's structure and data 68 | All sub objects will also be deserialized recursively 69 | > **Note**: leap.deserialize will NOT call the constructor of the class 70 | 71 | Example: 72 | ```lua 73 | RegisterNetEvent("myEvent", function(myObject) 74 | local obj = leap.deserialize(myObject) 75 | print(obj.myVar) 76 | end) 77 | ``` 78 | 79 | Classes can expose the `deserialize` method to achieve custom serialization. 80 | 81 | ```lua 82 | class MyClass { 83 | myVar = vec3(1, 2, 3), 84 | 85 | deserialize = function(data) 86 | self.myVar = vector3(data.myVar[1], data.myVar[2], data.myVar[3]) -- Restore the vec3 from the array 87 | end 88 | } 89 | ``` 90 | 91 | ### leap.serialize 92 | Converts an object or an array of objects (typically an instance of a class) into a serializable table format. 93 | All sub objects will also be serialized recursively 94 | 95 | Example: 96 | ```lua 97 | local myObject = MyClass:new() 98 | myObject.myVar = "Hello" 99 | 100 | local serialized = leap.serialize(myObject) -- {myVar = "Hello"} 101 | TriggerServerEvent("myEvent", serialized) 102 | ``` 103 | 104 | Classes can expose the `serialize` method to achieve custom serialization. 105 | 106 | ```lua 107 | class MyClass { 108 | myVar = vec3(1, 2, 3), 109 | 110 | serialize = function() 111 | return { 112 | myVar = {math.round(self.myVar.x, 3), math.round(self.myVar.y, 3), math.round(self.myVar.z, 3)}, -- Save a vec3 to an array with rounded values 113 | } 114 | end 115 | } 116 | ``` 117 | 118 | The `skipSerialize` decorator can be used to prevent certain fields from being serialized. 119 | 120 | ```lua 121 | @skipSerialize({"transient"}) 122 | class MyClass { 123 | myVar = vec3(1, 2, 3), 124 | transient = false, 125 | } 126 | 127 | local obj = new MyClass() 128 | -- Need to change values to trigger serialization 129 | obj.myVar = vector3(2, 3, 4) 130 | obj.transient = true 131 | 132 | local serialized = leap.serialize(obj) -- {"__type":"MyClass","myVar":{"x":2.0,"y":3.0,"z":4.0}} 133 | ``` 134 | 135 | ### leap.fsignature 136 | Retrieves the function signature metadata of a given function, such as argument names and return status. 137 | 138 | > **Note** Useful for debugging, documentation generation, or developer tooling that needs to understand a function's structure. 139 | 140 | **Signature format example:** 141 | ```lua 142 | { 143 | args = { 144 | { name = "a" }, 145 | { name = "b" }, 146 | }, 147 | name = "myFunction", 148 | has_return = true, 149 | } 150 | ``` 151 | 152 | > **Note** `has_return = true` doesn't guarantee that the function *always* returns a value, it simply indicates that a `return` statement **with a value** was detected somewhere in the function body. 153 | 154 | Example: 155 | ```lua 156 | local function addNumbers(numA, numB) 157 | return numA + numB 158 | end 159 | 160 | local signature = leap.fsignature(addNumbers) 161 | 162 | if signature then 163 | print("Function name:", signature.name) 164 | print("Has return:", signature.has_return) 165 | 166 | print("Arguments:") 167 | for i, arg in ipairs(signature.args) do 168 | print(i.." = "..arg.name) 169 | end 170 | else 171 | print("No signature metadata found.") 172 | end 173 | 174 | -- OUTPUT: 175 | 176 | -- Function name: addNumbers 177 | -- Has return: true 178 | -- Arguments: 179 | -- 1 = numA 180 | -- 2 = numB 181 | ``` 182 | 183 | ### type (override) 184 | Overrides Lua's native `type` behavior. 185 | When `type(obj)` is called on an object created from a class, it will return the class name instead of `"table"`. 186 | 187 | > **Note** This checks and return the `__type` field inside the "table", classes are just tables with metatable 188 | 189 | ```lua 190 | local myDog = new Dog() 191 | print(type(myDog)) -- Output: "Dog" 192 | ``` 193 | 194 | ## Features 195 | 196 | ### Classes 197 | Classes are a model for creating objects (a particular data structure), providing initial values for state (member variables or attributes), and implementing behavior (member functions or methods). 198 | It is possible as well to extend already existing classes, each method of the class that extends the other class will have a variable named `super` which is an instantiated object of the original class, calling this variable as a function will call the constructor of the original class, otherwise the data of the original class can be accessed. 199 | Constructor parameters are those passed when a new object is instantiated. [Read more here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 200 | > **Note** Classes have their own type, so calling `type(obj)` with an instantiated class will return the class name 201 | > **Note** You can edit the class prototype after the definition using the `__prototype` attribute 202 | --- 203 | 204 | Syntax: 205 | > **Note** Methods automatically hold the `self` variable referring to the instantiated object 206 | ```lua 207 | class className { 208 | var1 = 1, 209 | constructor = function() 210 | print(self.var1) 211 | end 212 | } 213 | ``` 214 | 215 | Example: 216 | ```lua 217 | class BaseClass { 218 | someVariable = 100, 219 | constructor = function() 220 | print("instantiated base class") 221 | end 222 | } 223 | 224 | class AdvancedClass extends BaseClass { 225 | constructor = function() 226 | print("instantiated advanced class") 227 | self:super() 228 | 229 | -- right now they should printout the same value, since they have not been touched 230 | print(self.super.someVariable) 231 | print(self.someVariable) 232 | end 233 | } 234 | 235 | new AdvancedClass() 236 | -- output: 237 | --[[ 238 | instantiated advanced class 239 | instantiated base class 240 | 100 241 | 100 242 | ]] 243 | ``` 244 | 245 | ### Compact function 246 | An compact function expression is a compact alternative to a traditional function expression. 247 | Is simply an alternative to writing anonymous functions, similar to [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) 248 | 249 | Syntaxes: 250 | ```lua 251 | (param1, paramN) do 252 | -- code 253 | end 254 | ``` 255 | ```lua 256 | param do -- code (single expresion) 257 | ``` 258 | ```lua 259 | (param1, paramN) do -- code (single expresion) 260 | ``` 261 | 262 | Example: 263 | ```lua 264 | local tab = {3, 10, 50, 20, 5} 265 | 266 | -- Inline with multiple params 267 | table.sort(tab, (a, b) do a < b) 268 | 269 | -- Inline with single param 270 | AddEventHandler('onResourceStart', name do print("Resource ${name} started!")) 271 | 272 | -- Multiline with multiple params 273 | AddEventHandler('playerConnecting', (name, setKickReason, deferrals) do 274 | if name == "XenoS" then 275 | print("XenoS is connecting! WOW!") 276 | else 277 | print("Player ${name} is connecting!") 278 | end 279 | end) 280 | ``` 281 | 282 | ### Continue keyword 283 | Used to continue execution in a loop. It is useful when you want to skip the current iteration of a loop. 284 | 285 | Example: 286 | ```lua 287 | for i = 1, 10 do 288 | if i == 5 then 289 | continue 290 | end 291 | print(i) 292 | end 293 | 294 | -- output: 295 | -- 1 296 | -- 2 297 | -- 3 298 | -- 4 299 | 300 | -- 6 301 | -- 7 302 | -- 8 303 | -- 9 304 | -- 10 305 | ``` 306 | 307 | ### Cosmetic underscores for integers 308 | Are used to improve readability in large numeric literals by grouping digits without affecting the value. They allow you to visually separate groups, like thousands or millions, making long numbers easier to parse at a glance. The underscores are ignored during preprocessing. 309 | 310 | Syntax: 311 | ```lua 312 | 1_000_000 313 | ``` 314 | 315 | Example: 316 | ```lua 317 | local myBigNumber = 2_147_483_647 318 | ``` 319 | 320 | ### Decorators 321 | By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it. 322 | Its like [wrappers](https://en.wikipedia.org/wiki/Wrapper_function) 323 | You can also pass parameters to the decorators. 324 | 325 | [Read more here](https://realpython.com/primer-on-python-decorators/#simple-decorators) 326 | 327 | Syntax: 328 | ```lua 329 | function decoratorName(func, a, b) 330 | return function(c, d) 331 | func(c,d) 332 | end 333 | end 334 | 335 | @decoratorName(a, b) 336 | function fnName(c, d) 337 | -- code 338 | end 339 | ``` 340 | 341 | Example: 342 | ```lua 343 | function stopwatch(func) 344 | return function(...) 345 | local time = GetGameTimer() 346 | local data = func(...) 347 | print("taken "..(GetGameTimer() - time).."ms to execute") 348 | return data 349 | end 350 | end 351 | 352 | @stopwatch 353 | function someMathIntensiveFunction(a, b, pow) 354 | for i=1, 500000 do 355 | math.pow(a*b, pow) 356 | end 357 | 358 | return math.pow(a*b, pow) 359 | end 360 | 361 | someMathIntensiveFunction(10, 50, 100) 362 | -- output: 363 | --[[ 364 | someMathIntensiveFunction taken 2ms to execute 365 | ]] 366 | ``` 367 | 368 | ```lua 369 | function netevent(self, func, name) 370 | RegisterNetEvent(name) 371 | AddEventHandler(name, function(...) 372 | func(self, ...) -- Remember to call the function with the class instance! 373 | end) 374 | 375 | return func 376 | end 377 | 378 | class Events { 379 | @netevent("Utility:MyEvent") -- Decorators can also be used in classes fields (will pass self instance) 380 | eventHandler = function() 381 | print("Event triggered!") 382 | end 383 | } 384 | ``` 385 | 386 | ```lua 387 | function callInit(class) 388 | class.__prototype.init() -- This will call the init function without an instance so self will be nil 389 | class.__prototype.mySpecialFlag = true -- You can also modify the class prototype to inject custom data 390 | 391 | return class 392 | end 393 | 394 | @callInit -- Decorators can also be used in classes 395 | class MyClass { 396 | init = function() 397 | print("Class initialized!") 398 | end 399 | } 400 | ``` 401 | 402 | ### Default value 403 | Default function parameters allow named parameters to be initialized with default values if no value or nil is passed. 404 | 405 | Syntax: 406 | ```lua 407 | function fnName(param1 = defaultValue1, ..., paramN = defaultValueN) { 408 | -- code 409 | } 410 | ``` 411 | 412 | Example: 413 | ```lua 414 | function multiply(a, b = 1) 415 | return a * b 416 | end 417 | 418 | print(multiply(5, 2)) 419 | -- Expected output: 10 420 | 421 | print(multiply(5)) 422 | -- Expected output: 5 423 | ``` 424 | 425 | ### Filter 426 | A filter is a mechanism for validating specific conditions before a function is executed. It serves as a precondition gatekeeper, ensuring the function runs only if all criteria are satisfied. If any condition fails, the filter stops execution and returns an error message. 427 | Filters simplify code by centralizing validation logic and making it reusable across multiple functions. 428 | They can access local variables from their enclosing scope and are evaluated with the [`using`](#using-operator) operator. 429 | 430 | Syntax: 431 | ```lua 432 | filter Name(param1, param2, ...) 433 | condition1 else "Error message for condition1!", 434 | condition2 435 | end 436 | 437 | filter Name 438 | condition1 else "Error message for condition1!", 439 | ... 440 | end 441 | ``` 442 | 443 | Example: 444 | ```lua 445 | filter IsAuthorized(action) 446 | user.role == "admin" else "User is not an admin!", 447 | user.permissions[action] else "User lacks permission to perform ${action}!", 448 | end 449 | 450 | -- Check "using" for a usage example 451 | ``` 452 | 453 | ### In operator 454 | Checks whether a specified substring/element exists in an string/table. It returns true if the substring/element is found and false otherwise. 455 | 456 | In **arrays** checks if **value** is in table. 457 | In **hash maps** checks if the **key** is in table. 458 | For **mixed tables**, it checks if the **value** is in the table, or if the **key** is in the table. 459 | 460 | In **strings** checks if **substring** is in string. 461 | 462 | Syntax: 463 | ```lua 464 | value in table 465 | key in table 466 | substring in string 467 | ``` 468 | 469 | Example: 470 | ```lua 471 | local array = {3, 10, 50, 20, 5} 472 | 473 | if 10 in array then 474 | print("found 10") 475 | end 476 | ---- 477 | local hashmap = { 478 | ["key1"] = "value1", 479 | ["key2"] = "value2", 480 | ["key3"] = "value3" 481 | } 482 | 483 | if "key1" in hashmap then 484 | print("found key1") 485 | end 486 | ---- 487 | local mixed = { 488 | ["key1"] = "value1", 489 | 3, 490 | 10, 491 | 20 492 | } 493 | 494 | if 10 in mixed or "key1" in mixed then 495 | print("found 10 or key1") 496 | end 497 | ---- 498 | local string = "Hello World" 499 | 500 | if "World" in string then 501 | print("found World") 502 | end 503 | ``` 504 | 505 | ### Is operator 506 | The is operator checks whether an object is an instance of a specific class or one of its subclasses. It is a type-checking operator that supports inheritance-aware comparisons. 507 | 508 | Example: 509 | ```lua 510 | class Animal {} 511 | class Dog extends Animal {} 512 | 513 | local a = Animal() 514 | local d = Dog() 515 | 516 | print(d is Dog) -- true (exact class) 517 | print(d is Animal) -- true (subclass of Animal) 518 | print(a is Dog) -- false (not an instance of Dog or its subclasses) 519 | ``` 520 | 521 | ### Keyword Arguments 522 | Keyword arguments allow calling functions with named parameters, improving readability and flexibility. They also allow parameters to be passed in any order. 523 | 524 | Syntax: 525 | ```lua 526 | functionName(param1 = value1, param2 = value2, ...) 527 | ``` 528 | 529 | Example: 530 | ```lua 531 | function greet(name, age) 532 | print("Hello " .. name .. ", Age: " .. age) 533 | end 534 | 535 | greet(name = "John", 20) 536 | greet(age = 21, name = "Anna") 537 | greet("Will", 34) 538 | ``` 539 | 540 | ### New 541 | The new operator is used to create an instance of an object. 542 | During preprocessing it is skipped. 543 | Its utility is to make it clear in the code when you are instantiating an object or calling a function 544 | 545 | Syntax: 546 | ```lua 547 | new Class() 548 | ``` 549 | 550 | Example: 551 | ```lua 552 | class BaseClass { 553 | someVariable = 100, 554 | constructor = function() 555 | print("instantiated base class") 556 | end 557 | } 558 | 559 | local base = new BaseClass() 560 | ``` 561 | 562 | ### Not equal (!=) 563 | An alias of the not equal operator (~=) 564 | 565 | Syntax: 566 | ```lua 567 | if true != false then 568 | -- code 569 | end 570 | ``` 571 | 572 | Example: 573 | ```lua 574 | local a = 10 575 | local b = 20 576 | 577 | if a != b then 578 | print("not equal") 579 | end 580 | ``` 581 | 582 | ### Not in operator 583 | Inverse of the in operator. 584 | 585 | Syntax: 586 | ```lua 587 | value not in table 588 | key not in table 589 | substring not in string 590 | ``` 591 | 592 | ### String Interpolation 593 | allows to embed expressions within a string, making it easy to insert variable values or expressions directly into a string. Using ${expression} you can dynamically include content without needing to concatenate strings manually. 594 | 595 | Syntax: 596 | ```lua 597 | "... ${expression} ..." 598 | '...${expression}...' 599 | ``` 600 | 601 | Example: 602 | ```lua 603 | local example1 = "100+200 = ${100+200}" -- 100+200 = 300 604 | local example2 = "100+200 = ${addNumbers(100, 200)}" -- 100+200 = 300 (using an hypothetical function) 605 | ``` 606 | 607 | ### Table comprehension 608 | Is a concise syntax for creating and transforming tables in a single expression, typically by applying conditions or transformations to elements within a specified range. It allows for easy filtering, mapping, or generating values based on criteria, reducing the need for longer loops or conditional structures. 609 | 610 | Syntax: 611 | ```lua 612 | {expression for items in iterable if condition} 613 | ``` 614 | 615 | Example: 616 | ```lua 617 | -- Create a new table with every element multiplied by 2 618 | local mult2 = {v*2 for k, v in pairs(tab)} 619 | 620 | -- Create a new table with every element multiplied by 2 if it is greater than 2 621 | local mult2IfGreaterThan2 = {v*2 for k, v in pairs(tab) if v > 2} 622 | 623 | -- Create a new table with every element multiplied by 2 if it is greater than 2 and less than 50 624 | local mult2IfGreaterThan2AndLessThan50 = {v*2 for k, v in pairs(tab) if v > 2 and v < 50} 625 | 626 | -- Create a new table with every element as "element:k" 627 | local keyAsElement = {"element:${k}", v for k, v in pairs(tab)} 628 | ``` 629 | 630 | ### Ternary operator 631 | The ternary operator is a shorthand for conditional expressions, allowing for a quick inline if-else statement, return one of two values based on whether the condition is true or false. 632 | 633 | Syntax: 634 | ```lua 635 | condition ? value1 : value2 636 | ``` 637 | 638 | Example: 639 | ```lua 640 | local result = 10 641 | local isResultGreaterThan2 = result > 2 ? "Yes" : "No" 642 | ``` 643 | 644 | ### Throw 645 | Used to create custom exceptions in code, by using `throw`, you can specify an error as any value (generally a string or an object) that provides information about the issue, which can then be caught and handled by a try-catch block. 646 | the try-catch block can also return a value. 647 | 648 | Custom errors need to extend the `Error` class and can provide a `toString` to return a fully custom error message, by default the error message will be `: ` 649 | 650 | Example: 651 | ```lua 652 | try 653 | throw "Something went wrong" 654 | catch e then 655 | print("Error: "..e) 656 | end 657 | ``` 658 | 659 | ```lua 660 | class CustomError extends Error { 661 | constructor = function(importantInfo) 662 | self.info = importantInfo 663 | end 664 | } 665 | 666 | try 667 | throw new CustomError("Some important info here") 668 | catch e then 669 | if e is CustomError then 670 | print(e.info) 671 | end 672 | end 673 | ``` 674 | 675 | ```lua 676 | class AnotherTypeOfError extends Error {} 677 | 678 | throw new AnotherTypeOfError("This is the message") 679 | -- AnotherTypeOfError: This is the message 680 | ``` 681 | 682 | ```lua 683 | class CustomError2 extends Error { 684 | toString = function() 685 | print("Custom message: "..self.message) 686 | end 687 | } 688 | 689 | throw new CustomError2("Some important info here") 690 | -- Custom message: Some important info here 691 | ``` 692 | 693 | ### Try-catch 694 | Used for error handling, The `try` block contains code that may throw an error, while the `catch` block handles the error if one occurs, preventing the script from crashing and allowing for graceful error recovery. 695 | 696 | Syntax: 697 | ```lua 698 | try 699 | -- code 700 | catch errorVariable then 701 | -- code 702 | end 703 | ``` 704 | 705 | Example: 706 | ```lua 707 | try 708 | indexingTableThatDoesntExist[100] = true 709 | catch e then 710 | print("Error: "..e) 711 | end 712 | ``` 713 | 714 | ### Type checking 715 | Type checking is the process of verifying data types at runtime to prevent errors and ensure compatibility. It ensures that parameters are used with compatible types. This runtime checking helps catch type errors that could lead to unexpected behavior. 716 | > **Note** [Classes](#classes) can also be used as types 717 | 718 | Syntax: 719 | ```lua 720 | function funcName(param1: type1, ..., paramN: typeN) 721 | -- code 722 | end 723 | ``` 724 | 725 | Example: 726 | ```lua 727 | function DebugText(text: string) 728 | print("debug: "..text) 729 | end 730 | 731 | 732 | DebugText("test") -- debug: test 733 | DebugText(100) -- Error loading script *.lua in resource ****: @****/*.lua:7: text: string expected, got number 734 | ``` 735 | ```lua 736 | class Example { 737 | myVar = true 738 | } 739 | 740 | function FunctionThatAcceptOnlyExampleClass(example: Example) 741 | print("You passed the right variable!") 742 | end 743 | 744 | FunctionThatAcceptOnlyExampleClass("Test") -- Error since string is not of type Example 745 | ``` 746 | 747 | ### Using operator 748 | The `using` operator runs a [filter](#filter), validating the conditions defined within it. If any of the conditions fail, it throws an error, preventing the execution of the associated code. 749 | 750 | Syntax: 751 | ```lua 752 | using Filter(param1, param2, ...) 753 | 754 | using Filter 755 | ``` 756 | 757 | Example: 758 | ```lua 759 | function deletePost(user: User) using IsAuthorized("deletePost") -- Check "filter" to see the filter code 760 | print("Post deleted successfully!") 761 | end 762 | 763 | -- This is also valid! 764 | function deletePost(user: User) 765 | using IsAuthorized("deletePost") 766 | print("Post deleted successfully!") 767 | end 768 | ``` 769 | 770 | ## [Convars](https://docs.fivem.net/docs/scripting-reference/convars/) 771 | 772 | | Convar | Default | Type | 773 | |--------------|---------|---------| 774 | | leap_verbose | false | boolean | 775 | -------------------------------------------------------------------------------- /functions/leap.js: -------------------------------------------------------------------------------- 1 | var ee=Object.create;var tt=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var M=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports),ae=(u,e)=>{for(var t in e)tt(u,t,{get:e[t],enumerable:!0})},kt=(u,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of re(e))!se.call(u,s)&&s!==t&&tt(u,s,{get:()=>e[s],enumerable:!(i=ie(e,s))||i.enumerable});return u};var G=(u,e,t)=>(t=u!=null?ee(ne(u)):{},kt(e||!u||!u.__esModule?tt(t,"default",{value:u,enumerable:!0}):t,u)),le=u=>kt(tt({},"__esModule",{value:!0}),u);var Ht=M((Me,wt)=>{wt.exports=`if not leap then leap={}end;if not leap.deserialize then leap.deserialize=function(a)local b=_type(a)if b~="table"or not a.__type then if b=="table"then local c={}for d,e in pairs(a)do c[d]=leap.deserialize(e)end;return c else return a end end;local f=_G[a.__type]if not f then error("Class '"..a.__type.."' not found",2)end;f.__skipNextConstructor=true;local g=f()if g.deserialize then g:deserialize(a)else for d,e in pairs(a)do if d~="__type"then g[d]=leap.deserialize(e)end end end;return g end end;if not leap.serialize then leap.serialize=function(a)local b=_type(a)if b~="table"then return a end;if type(a)=="table"then local h={}for d,e in pairs(a)do h[d]=leap.serialize(e)end;return h end;if a.serialize then local i=a:serialize()if not i then return nil end;if type(i)~="table"then error("leap.serialize: custom serialize method must return a table",2)end;for d,e in pairs(i)do i[d]=leap.serialize(e)end;i.__type=a.__type;return i end;local c={}for d,e in pairs(a)do if d~="__stack"then local j=false;if a.__ignoreList then for k,l in pairs(a.__ignoreList)do if d==l then j=true;break end end end;if not j then c[d]=leap.serialize(e)end end end;return c end end;if not skipSerialize then skipSerialize=function(m,n)if _type(m)~="table"then error("skipSerialize: #1 passed argument must be a class, but got "..type(m),2)end;m.__prototype.__ignoreList=n end end;if not leap.fsignature then leap.fsignature=function(o)if _type(o)~="function"then error("leap.fsignature: passed argument must be a function, but got ".._type(o),2)end;if not __leap__introspection then return nil end;return __leap__introspection[o]end end;if not leap.registerfunc then leap.registerfunc=function(o,p)if not __leap__introspection then __leap__introspection={}end;__leap__introspection[o]=p;return o end end;if not _type then _type=type;type=function(q)local r=_type(q)if r=="table"and q.__type then return q.__type else return r end end end`});var Dt=M((Ge,Ut)=>{Ut.exports=`if not _leap_internal_classBuilder then local a=function(b)return b.__stack[#b.__stack]end;local c=function(b)local d=a(b)return d and d.__prototype end;local e=function(b)local d=a(b)return d and d.__type end;local f=function(b,g)if not g.__parent then table.insert(b.__stack,{})else table.insert(b.__stack,g.__parent)end end;local h=function(b)local i=table.remove(b.__stack)end;local deepcopy=function(j,k)if type(j)~="table"then return j end;if k and k[j]then return k[j]end;local l={}k=k or{}k[j]=l;for m,n in next,j do local o=type(m)=="table"and deepcopy(m,k)or m;local p=type(n)=="table"and deepcopy(n,k)or n;l[o]=p end;return l end;local q={__index=function(self,r)if r=="__type"then return e(self.obj)else local g=c(self.obj)if not g or next(g)==nil then return nil end;local s=g[r]if type(s)=="function"then return function(t,...)f(self.obj,g)local u=s(self.obj,...)h(self.obj)return u end else return s end end end,__call=function(self,...)local v=self.constructor;if v then return v(...)end end}function _leap_internal_class_makeSuper(b)return setmetatable({obj=b},q)end;_leap_internal_classBuilder=function(w,x,y)x._leap_internal_decorators={}if not y then error("ExtendingNotDefined: "..w.." tried to extend a class that is not defined",2)end;if y.__prototype then setmetatable(x,{__index=function(t,r)local z=y.__prototype[r]if type(z)=="function"then return function(self,...)local x=c(self)if not x or next(x)==nil then return nil end;f(self,x)local u=z(self,...)h(self)return u end else return z end end})x.__parent=y end;local A={}local B=1;for m,n in next,x do if _type(n)=="table"and m:sub(1,5)~="_leap"then A[B]=m;B=B+1 end end;local C={__index=x,__gc=function(self)if self.destructor then self:destructor()end end,__tostring=function(self)if self.toString then return self:toString()else local D=""for m,n in pairs(self)do if m~="super"and m:sub(1,5)~="_leap"and m:sub(1,2)~="__"then if _type(n)=="table"then if getmetatable(n)then n=tostring(n)else n=json.encode(n)end end;D=D..m..": "..tostring(n)..", "end end;D=D:sub(1,-3)return"<"..self.__type..":"..("%p"):format(self).."> "..D end end}_G[w]=setmetatable({__type=w,__prototype=x},{__newindex=function(self,m,n)if m:sub(1,2)=="__"then rawset(self,m,n)else error("attempt to assign class property '"..m.."' directly, please instantiate the class before assigning any properties",2)end end,__call=function(self,...)local b={__type=self.__type,__stack={}}for E=1,#A do local r=A[E]b[r]=deepcopy(self.__prototype[r])end;setmetatable(b,C)local F=self.__prototype.__parent;if F then b.super=_leap_internal_class_makeSuper(b)f(b,self.__prototype)end;for t,G in pairs(b._leap_internal_decorators)do local H=b[G.name]local I=function(...)return H(b,...)end;leap.registerfunc(I,leap.fsignature(H))b[G.name]=_G[G.decoratorName](b,I,table.unpack(G.args))or H end;if not self.__skipNextConstructor then if b.constructor then b:constructor(...)end end;self.__skipNextConstructor=nil;return b end})end;_leap_internal_classBuilder("Error",{constructor=function(self,J)self.message=J end,toString=function(self)return type(self)..": "..self.message end},{})end;if not _leap_internal_is_operator then _leap_internal_is_operator=function(b,K)if not b or not K then return false end;if _type(b)~="table"then error("leap.is_operator: #1 passed argument must be a class instance, but got ".._type(b),2)end;if _type(K)~="table"then error("leap.is_operator: #2 passed argument must be a class, but got ".._type(K),2)end;if b.__prototype then error("leap.is_operator: #1 passed argument must be a class instance, but got class",2)end;local L=b;while L and L.__type~=K.__type do if L.super then L=L.super.parent else return false end end;return true end end`});var Gt=M((Be,Mt)=>{Mt.exports='if not _leap_internal_in_operator then _leap_internal_in_operator=function(a,b)local c=type(b)if c=="table"then if table.type(b)=="array"then for d,e in pairs(b)do if e==a then return true end end elseif table.type(b)=="hash"then for d,e in pairs(b)do if d==a then return true end end else for d,e in pairs(b)do if e==a or d==a then return true end end end elseif c=="string"then return b:find(a)else error("in operator: unsupported type "..c)end;return false end end'});var jt=M((je,Bt)=>{Bt.exports='if not _leap_internal_using_operator then _leap_internal_using_operator=function(a,b,...)local c=a;a=_G[a]if type(a)~="string"then error("using operator expects a filter, got "..type(a),2)end;local d=b.ddd;b.ddd=nil;local e={...}local f,g=pcall(function()load(a,"@"..c,"t",setmetatable(b,{__index=_G}))()(table.unpack(e),d and table.unpack(d))end)if not f then error(g,2)end end end'});var Vt=M((Qe,Qt)=>{Qt.exports=`if not __leap_call_kargs then __leap_call_kargs=function(a,b,...)local c={...}local d=leap.fsignature(a)if not d then error("leap: "..a.." cant accept kargs as it has no metadata (probably not processed by leap)",2)end;for e,f in pairs(b)do for g,h in pairs(d.args)do if h.name==e then if c[g]then local i=string.format("leap: argument '%s' for function '%s' was provided both positionally (%s) and as a keyword (%s)",e,d.name,tostring(c[g]),tostring(f))error(i,2)end;c[g]=f;break end end end;return table.unpack(c)end end`});var ce={};ae(ce,{preprocessCode:()=>oe});module.exports=le(ce);var At=require("antlr4");var N=require("antlr4");var vt=require("antlr4"),B=class extends vt.Lexer{constructor(e){super(e)}HandleComment(){this.start_line=this.line,this.start_col=this.column-2;let e=this._input;if(e.LA(1)===91){let t=this.skip_sep(e);if(t>=2){this.read_long_string(e,t);return}}for(;!this.isNewLine(e.LA(1))&&e.LA(1)!==-1;)e.consume()}isNewLine(e){return e===10||e===13}read_long_string(e,t){let i=!1;for(e.consume();;){switch(e.LA(1)){case-1:i=!0;break;case 93:this.skip_sep(e)===t&&(e.consume(),i=!0);break;default:if(e.LA(1)===-1){i=!0;break}e.consume();break}if(i)break}}skip_sep(e){let t=0,i=e.LA(1);for(e.consume();e.LA(1)===61;)e.consume(),t++;return e.LA(1)===i?t+=2:t===0?t=1:t=0,t}IsLine1Col0(){return this._input.index===1}};var l=class l extends B{constructor(e){super(e),this._interp=new N.LexerATNSimulator(this,l._ATN,l.DecisionsToDFA,new N.PredictionContextCache)}get grammarFileName(){return"LuaLexer.g4"}get literalNames(){return l.literalNames}get symbolicNames(){return l.symbolicNames}get ruleNames(){return l.ruleNames}get serializedATN(){return l._serializedATN}get channelNames(){return l.channelNames}get modeNames(){return l.modeNames}action(e,t,i){switch(t){case 97:this.COMMENT_action(e,i);break}}COMMENT_action(e,t){switch(t){case 0:this.HandleComment();break}}sempred(e,t,i){switch(t){case 101:return this.SHEBANG_sempred(e,i)}return!0}SHEBANG_sempred(e,t){switch(t){case 0:return this.IsLine1Col0()}return!0}static get _ATN(){return l.__ATN||(l.__ATN=new N.ATNDeserializer().deserialize(l._serializedATN)),l.__ATN}};l.SEMI=1,l.EQ=2,l.NEW=3,l.CLASS=4,l.EXTENDS=5,l.USING=6,l.FILTER=7,l.IS=8,l.TRY=9,l.CATCH=10,l.THROW=11,l.QUESTMARK=12,l.COMPPLUS=13,l.COMPMINUS=14,l.COMPSTAR=15,l.COMPSLASH=16,l.COMPLL=17,l.COMPGG=18,l.COMPAMP=19,l.COMPPIPE=20,l.COMPCARET=21,l.DEFER=22,l.AT=23,l.BREAK=24,l.GOTO=25,l.DO=26,l.END=27,l.WHILE=28,l.REPEAT=29,l.UNTIL=30,l.IF=31,l.THEN=32,l.ELSEIF=33,l.ELSE=34,l.FOR=35,l.COMMA=36,l.IN=37,l.FUNCTION=38,l.LOCAL=39,l.LT=40,l.GT=41,l.RETURN=42,l.CONTINUE=43,l.CC=44,l.NIL=45,l.FALSE=46,l.TRUE=47,l.DOT=48,l.SQUIG=49,l.MINUS=50,l.POUND=51,l.OP=52,l.CP=53,l.NOT=54,l.LL=55,l.GG=56,l.AMP=57,l.SS=58,l.PER=59,l.COL=60,l.LE=61,l.GE=62,l.AND=63,l.OR=64,l.PLUS=65,l.STAR=66,l.OCU=67,l.CCU=68,l.OB=69,l.CB=70,l.EE=71,l.DD=72,l.PIPE=73,l.CARET=74,l.SLASH=75,l.DDD=76,l.SQEQ=77,l.NOTEQ_ALT=78,l.NAME=79,l.NORMALSTRING=80,l.CHARSTRING=81,l.JENKINSHASHSTRING=82,l.LONGSTRING=83,l.INT=84,l.HEX=85,l.FLOAT=86,l.HEX_FLOAT=87,l.COMMENT=88,l.C_COMMENT=89,l.WS=90,l.NL=91,l.SHEBANG=92,l.EOF=N.Token.EOF,l.channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"],l.literalNames=[null,"';'","'='","'new'","'class'","'extends'","'using'","'filter'","'is'","'try'","'catch'","'throw'","'?'","'+='","'-='","'*='","'/='","'<<='","'>>='","'&='","'|='","'^='","'defer'","'@'","'break'","'goto'","'do'","'end'","'while'","'repeat'","'until'","'if'","'then'","'elseif'","'else'","'for'","','","'in'","'function'","'local'","'<'","'>'","'return'","'continue'","'::'","'nil'","'false'","'true'","'.'","'~'","'-'","'#'","'('","')'","'not'","'<<'","'>>'","'&'","'//'","'%'","':'","'<='","'>='","'and'","'or'","'+'","'*'","'{'","'}'","'['","']'","'=='","'..'","'|'","'^'","'/'","'...'","'~='","'!='"],l.symbolicNames=[null,"SEMI","EQ","NEW","CLASS","EXTENDS","USING","FILTER","IS","TRY","CATCH","THROW","QUESTMARK","COMPPLUS","COMPMINUS","COMPSTAR","COMPSLASH","COMPLL","COMPGG","COMPAMP","COMPPIPE","COMPCARET","DEFER","AT","BREAK","GOTO","DO","END","WHILE","REPEAT","UNTIL","IF","THEN","ELSEIF","ELSE","FOR","COMMA","IN","FUNCTION","LOCAL","LT","GT","RETURN","CONTINUE","CC","NIL","FALSE","TRUE","DOT","SQUIG","MINUS","POUND","OP","CP","NOT","LL","GG","AMP","SS","PER","COL","LE","GE","AND","OR","PLUS","STAR","OCU","CCU","OB","CB","EE","DD","PIPE","CARET","SLASH","DDD","SQEQ","NOTEQ_ALT","NAME","NORMALSTRING","CHARSTRING","JENKINSHASHSTRING","LONGSTRING","INT","HEX","FLOAT","HEX_FLOAT","COMMENT","C_COMMENT","WS","NL","SHEBANG"],l.modeNames=["DEFAULT_MODE"],l.ruleNames=["SEMI","EQ","NEW","CLASS","EXTENDS","USING","FILTER","IS","TRY","CATCH","THROW","QUESTMARK","COMPPLUS","COMPMINUS","COMPSTAR","COMPSLASH","COMPLL","COMPGG","COMPAMP","COMPPIPE","COMPCARET","DEFER","AT","BREAK","GOTO","DO","END","WHILE","REPEAT","UNTIL","IF","THEN","ELSEIF","ELSE","FOR","COMMA","IN","FUNCTION","LOCAL","LT","GT","RETURN","CONTINUE","CC","NIL","FALSE","TRUE","DOT","SQUIG","MINUS","POUND","OP","CP","NOT","LL","GG","AMP","SS","PER","COL","LE","GE","AND","OR","PLUS","STAR","OCU","CCU","OB","CB","EE","DD","PIPE","CARET","SLASH","DDD","SQEQ","NOTEQ_ALT","NAME","NORMALSTRING","CHARSTRING","JENKINSHASHSTRING","LONGSTRING","NESTED_STR","INT","HEX","FLOAT","HEX_FLOAT","ExponentPart","HexExponentPart","EscapeSequence","DecimalEscape","HexEscape","UtfEscape","Digit","HexDigit","SingleLineInputCharacter","COMMENT","C_COMMENT","WS","NL","SHEBANG"],l._serializedATN=[4,0,92,748,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,2,89,7,89,2,90,7,90,2,91,7,91,2,92,7,92,2,93,7,93,2,94,7,94,2,95,7,95,2,96,7,96,2,97,7,97,2,98,7,98,2,99,7,99,2,100,7,100,2,101,7,101,1,0,1,0,1,1,1,1,1,2,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,14,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,24,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,34,1,35,1,35,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,40,1,40,1,41,1,41,1,41,1,41,1,41,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,45,1,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,1,47,1,47,1,48,1,48,1,49,1,49,1,50,1,50,1,51,1,51,1,52,1,52,1,53,1,53,1,53,1,53,1,54,1,54,1,54,1,55,1,55,1,55,1,56,1,56,1,57,1,57,1,57,1,58,1,58,1,59,1,59,1,60,1,60,1,60,1,61,1,61,1,61,1,62,1,62,1,62,1,62,1,63,1,63,1,63,1,64,1,64,1,65,1,65,1,66,1,66,1,67,1,67,1,68,1,68,1,69,1,69,1,70,1,70,1,70,1,71,1,71,1,71,1,72,1,72,1,73,1,73,1,74,1,74,1,75,1,75,1,75,1,75,1,76,1,76,1,76,1,77,1,77,1,77,1,78,1,78,5,78,498,8,78,10,78,12,78,501,9,78,1,79,1,79,1,79,5,79,506,8,79,10,79,12,79,509,9,79,1,79,1,79,1,80,1,80,1,80,5,80,516,8,80,10,80,12,80,519,9,80,1,80,1,80,1,81,1,81,5,81,525,8,81,10,81,12,81,528,9,81,1,81,1,81,1,82,1,82,1,82,1,82,1,83,1,83,1,83,1,83,1,83,1,83,5,83,542,8,83,10,83,12,83,545,9,83,1,83,3,83,548,8,83,1,84,4,84,551,8,84,11,84,12,84,552,1,84,3,84,556,8,84,1,85,1,85,1,85,4,85,561,8,85,11,85,12,85,562,1,86,4,86,566,8,86,11,86,12,86,567,1,86,1,86,5,86,572,8,86,10,86,12,86,575,9,86,1,86,3,86,578,8,86,1,86,1,86,4,86,582,8,86,11,86,12,86,583,1,86,3,86,587,8,86,1,86,4,86,590,8,86,11,86,12,86,591,1,86,1,86,3,86,596,8,86,1,87,1,87,1,87,4,87,601,8,87,11,87,12,87,602,1,87,1,87,5,87,607,8,87,10,87,12,87,610,9,87,1,87,3,87,613,8,87,1,87,1,87,1,87,1,87,4,87,619,8,87,11,87,12,87,620,1,87,3,87,624,8,87,1,87,1,87,1,87,4,87,629,8,87,11,87,12,87,630,1,87,1,87,3,87,635,8,87,1,88,1,88,3,88,639,8,88,1,88,4,88,642,8,88,11,88,12,88,643,1,89,1,89,3,89,648,8,89,1,89,4,89,651,8,89,11,89,12,89,652,1,90,1,90,1,90,1,90,3,90,659,8,90,1,90,1,90,1,90,1,90,3,90,665,8,90,1,91,1,91,1,91,1,91,1,91,1,91,1,91,1,91,1,91,1,91,1,91,3,91,678,8,91,1,92,1,92,1,92,1,92,1,92,1,93,1,93,1,93,1,93,1,93,4,93,690,8,93,11,93,12,93,691,1,93,1,93,1,94,1,94,1,95,1,95,1,96,1,96,1,97,1,97,1,97,1,97,1,97,1,97,1,97,1,98,1,98,1,98,1,98,5,98,713,8,98,10,98,12,98,716,9,98,1,98,1,98,1,98,3,98,721,8,98,1,98,1,98,1,99,4,99,726,8,99,11,99,12,99,727,1,99,1,99,1,100,1,100,1,100,1,100,1,101,1,101,1,101,3,101,739,8,101,1,101,5,101,742,8,101,10,101,12,101,745,9,101,1,101,1,101,3,526,543,714,0,102,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,93,47,95,48,97,49,99,50,101,51,103,52,105,53,107,54,109,55,111,56,113,57,115,58,117,59,119,60,121,61,123,62,125,63,127,64,129,65,131,66,133,67,135,68,137,69,139,70,141,71,143,72,145,73,147,74,149,75,151,76,153,77,155,78,157,79,159,80,161,81,163,82,165,83,167,0,169,84,171,85,173,86,175,87,177,0,179,0,181,0,183,0,185,0,187,0,189,0,191,0,193,0,195,88,197,89,199,90,201,91,203,92,1,0,15,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,2,0,34,34,92,92,2,0,39,39,92,92,2,0,88,88,120,120,2,0,69,69,101,101,2,0,43,43,45,45,2,0,80,80,112,112,11,0,34,36,39,39,92,92,97,98,102,102,110,110,114,114,116,116,118,118,122,122,124,124,1,0,48,50,1,0,48,57,3,0,48,57,65,70,97,102,4,0,10,10,13,13,133,133,8232,8233,3,0,9,9,12,13,32,32,1,0,10,10,781,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,0,117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,0,123,1,0,0,0,0,125,1,0,0,0,0,127,1,0,0,0,0,129,1,0,0,0,0,131,1,0,0,0,0,133,1,0,0,0,0,135,1,0,0,0,0,137,1,0,0,0,0,139,1,0,0,0,0,141,1,0,0,0,0,143,1,0,0,0,0,145,1,0,0,0,0,147,1,0,0,0,0,149,1,0,0,0,0,151,1,0,0,0,0,153,1,0,0,0,0,155,1,0,0,0,0,157,1,0,0,0,0,159,1,0,0,0,0,161,1,0,0,0,0,163,1,0,0,0,0,165,1,0,0,0,0,169,1,0,0,0,0,171,1,0,0,0,0,173,1,0,0,0,0,175,1,0,0,0,0,195,1,0,0,0,0,197,1,0,0,0,0,199,1,0,0,0,0,201,1,0,0,0,0,203,1,0,0,0,1,205,1,0,0,0,3,207,1,0,0,0,5,209,1,0,0,0,7,213,1,0,0,0,9,219,1,0,0,0,11,227,1,0,0,0,13,233,1,0,0,0,15,240,1,0,0,0,17,243,1,0,0,0,19,247,1,0,0,0,21,253,1,0,0,0,23,259,1,0,0,0,25,261,1,0,0,0,27,264,1,0,0,0,29,267,1,0,0,0,31,270,1,0,0,0,33,273,1,0,0,0,35,277,1,0,0,0,37,281,1,0,0,0,39,284,1,0,0,0,41,287,1,0,0,0,43,290,1,0,0,0,45,296,1,0,0,0,47,298,1,0,0,0,49,304,1,0,0,0,51,309,1,0,0,0,53,312,1,0,0,0,55,316,1,0,0,0,57,322,1,0,0,0,59,329,1,0,0,0,61,335,1,0,0,0,63,338,1,0,0,0,65,343,1,0,0,0,67,350,1,0,0,0,69,355,1,0,0,0,71,359,1,0,0,0,73,361,1,0,0,0,75,364,1,0,0,0,77,373,1,0,0,0,79,379,1,0,0,0,81,381,1,0,0,0,83,383,1,0,0,0,85,390,1,0,0,0,87,399,1,0,0,0,89,402,1,0,0,0,91,406,1,0,0,0,93,412,1,0,0,0,95,417,1,0,0,0,97,419,1,0,0,0,99,421,1,0,0,0,101,423,1,0,0,0,103,425,1,0,0,0,105,427,1,0,0,0,107,429,1,0,0,0,109,433,1,0,0,0,111,436,1,0,0,0,113,439,1,0,0,0,115,441,1,0,0,0,117,444,1,0,0,0,119,446,1,0,0,0,121,448,1,0,0,0,123,451,1,0,0,0,125,454,1,0,0,0,127,458,1,0,0,0,129,461,1,0,0,0,131,463,1,0,0,0,133,465,1,0,0,0,135,467,1,0,0,0,137,469,1,0,0,0,139,471,1,0,0,0,141,473,1,0,0,0,143,476,1,0,0,0,145,479,1,0,0,0,147,481,1,0,0,0,149,483,1,0,0,0,151,485,1,0,0,0,153,489,1,0,0,0,155,492,1,0,0,0,157,495,1,0,0,0,159,502,1,0,0,0,161,512,1,0,0,0,163,522,1,0,0,0,165,531,1,0,0,0,167,547,1,0,0,0,169,550,1,0,0,0,171,557,1,0,0,0,173,595,1,0,0,0,175,634,1,0,0,0,177,636,1,0,0,0,179,645,1,0,0,0,181,664,1,0,0,0,183,677,1,0,0,0,185,679,1,0,0,0,187,684,1,0,0,0,189,695,1,0,0,0,191,697,1,0,0,0,193,699,1,0,0,0,195,701,1,0,0,0,197,708,1,0,0,0,199,725,1,0,0,0,201,731,1,0,0,0,203,735,1,0,0,0,205,206,5,59,0,0,206,2,1,0,0,0,207,208,5,61,0,0,208,4,1,0,0,0,209,210,5,110,0,0,210,211,5,101,0,0,211,212,5,119,0,0,212,6,1,0,0,0,213,214,5,99,0,0,214,215,5,108,0,0,215,216,5,97,0,0,216,217,5,115,0,0,217,218,5,115,0,0,218,8,1,0,0,0,219,220,5,101,0,0,220,221,5,120,0,0,221,222,5,116,0,0,222,223,5,101,0,0,223,224,5,110,0,0,224,225,5,100,0,0,225,226,5,115,0,0,226,10,1,0,0,0,227,228,5,117,0,0,228,229,5,115,0,0,229,230,5,105,0,0,230,231,5,110,0,0,231,232,5,103,0,0,232,12,1,0,0,0,233,234,5,102,0,0,234,235,5,105,0,0,235,236,5,108,0,0,236,237,5,116,0,0,237,238,5,101,0,0,238,239,5,114,0,0,239,14,1,0,0,0,240,241,5,105,0,0,241,242,5,115,0,0,242,16,1,0,0,0,243,244,5,116,0,0,244,245,5,114,0,0,245,246,5,121,0,0,246,18,1,0,0,0,247,248,5,99,0,0,248,249,5,97,0,0,249,250,5,116,0,0,250,251,5,99,0,0,251,252,5,104,0,0,252,20,1,0,0,0,253,254,5,116,0,0,254,255,5,104,0,0,255,256,5,114,0,0,256,257,5,111,0,0,257,258,5,119,0,0,258,22,1,0,0,0,259,260,5,63,0,0,260,24,1,0,0,0,261,262,5,43,0,0,262,263,5,61,0,0,263,26,1,0,0,0,264,265,5,45,0,0,265,266,5,61,0,0,266,28,1,0,0,0,267,268,5,42,0,0,268,269,5,61,0,0,269,30,1,0,0,0,270,271,5,47,0,0,271,272,5,61,0,0,272,32,1,0,0,0,273,274,5,60,0,0,274,275,5,60,0,0,275,276,5,61,0,0,276,34,1,0,0,0,277,278,5,62,0,0,278,279,5,62,0,0,279,280,5,61,0,0,280,36,1,0,0,0,281,282,5,38,0,0,282,283,5,61,0,0,283,38,1,0,0,0,284,285,5,124,0,0,285,286,5,61,0,0,286,40,1,0,0,0,287,288,5,94,0,0,288,289,5,61,0,0,289,42,1,0,0,0,290,291,5,100,0,0,291,292,5,101,0,0,292,293,5,102,0,0,293,294,5,101,0,0,294,295,5,114,0,0,295,44,1,0,0,0,296,297,5,64,0,0,297,46,1,0,0,0,298,299,5,98,0,0,299,300,5,114,0,0,300,301,5,101,0,0,301,302,5,97,0,0,302,303,5,107,0,0,303,48,1,0,0,0,304,305,5,103,0,0,305,306,5,111,0,0,306,307,5,116,0,0,307,308,5,111,0,0,308,50,1,0,0,0,309,310,5,100,0,0,310,311,5,111,0,0,311,52,1,0,0,0,312,313,5,101,0,0,313,314,5,110,0,0,314,315,5,100,0,0,315,54,1,0,0,0,316,317,5,119,0,0,317,318,5,104,0,0,318,319,5,105,0,0,319,320,5,108,0,0,320,321,5,101,0,0,321,56,1,0,0,0,322,323,5,114,0,0,323,324,5,101,0,0,324,325,5,112,0,0,325,326,5,101,0,0,326,327,5,97,0,0,327,328,5,116,0,0,328,58,1,0,0,0,329,330,5,117,0,0,330,331,5,110,0,0,331,332,5,116,0,0,332,333,5,105,0,0,333,334,5,108,0,0,334,60,1,0,0,0,335,336,5,105,0,0,336,337,5,102,0,0,337,62,1,0,0,0,338,339,5,116,0,0,339,340,5,104,0,0,340,341,5,101,0,0,341,342,5,110,0,0,342,64,1,0,0,0,343,344,5,101,0,0,344,345,5,108,0,0,345,346,5,115,0,0,346,347,5,101,0,0,347,348,5,105,0,0,348,349,5,102,0,0,349,66,1,0,0,0,350,351,5,101,0,0,351,352,5,108,0,0,352,353,5,115,0,0,353,354,5,101,0,0,354,68,1,0,0,0,355,356,5,102,0,0,356,357,5,111,0,0,357,358,5,114,0,0,358,70,1,0,0,0,359,360,5,44,0,0,360,72,1,0,0,0,361,362,5,105,0,0,362,363,5,110,0,0,363,74,1,0,0,0,364,365,5,102,0,0,365,366,5,117,0,0,366,367,5,110,0,0,367,368,5,99,0,0,368,369,5,116,0,0,369,370,5,105,0,0,370,371,5,111,0,0,371,372,5,110,0,0,372,76,1,0,0,0,373,374,5,108,0,0,374,375,5,111,0,0,375,376,5,99,0,0,376,377,5,97,0,0,377,378,5,108,0,0,378,78,1,0,0,0,379,380,5,60,0,0,380,80,1,0,0,0,381,382,5,62,0,0,382,82,1,0,0,0,383,384,5,114,0,0,384,385,5,101,0,0,385,386,5,116,0,0,386,387,5,117,0,0,387,388,5,114,0,0,388,389,5,110,0,0,389,84,1,0,0,0,390,391,5,99,0,0,391,392,5,111,0,0,392,393,5,110,0,0,393,394,5,116,0,0,394,395,5,105,0,0,395,396,5,110,0,0,396,397,5,117,0,0,397,398,5,101,0,0,398,86,1,0,0,0,399,400,5,58,0,0,400,401,5,58,0,0,401,88,1,0,0,0,402,403,5,110,0,0,403,404,5,105,0,0,404,405,5,108,0,0,405,90,1,0,0,0,406,407,5,102,0,0,407,408,5,97,0,0,408,409,5,108,0,0,409,410,5,115,0,0,410,411,5,101,0,0,411,92,1,0,0,0,412,413,5,116,0,0,413,414,5,114,0,0,414,415,5,117,0,0,415,416,5,101,0,0,416,94,1,0,0,0,417,418,5,46,0,0,418,96,1,0,0,0,419,420,5,126,0,0,420,98,1,0,0,0,421,422,5,45,0,0,422,100,1,0,0,0,423,424,5,35,0,0,424,102,1,0,0,0,425,426,5,40,0,0,426,104,1,0,0,0,427,428,5,41,0,0,428,106,1,0,0,0,429,430,5,110,0,0,430,431,5,111,0,0,431,432,5,116,0,0,432,108,1,0,0,0,433,434,5,60,0,0,434,435,5,60,0,0,435,110,1,0,0,0,436,437,5,62,0,0,437,438,5,62,0,0,438,112,1,0,0,0,439,440,5,38,0,0,440,114,1,0,0,0,441,442,5,47,0,0,442,443,5,47,0,0,443,116,1,0,0,0,444,445,5,37,0,0,445,118,1,0,0,0,446,447,5,58,0,0,447,120,1,0,0,0,448,449,5,60,0,0,449,450,5,61,0,0,450,122,1,0,0,0,451,452,5,62,0,0,452,453,5,61,0,0,453,124,1,0,0,0,454,455,5,97,0,0,455,456,5,110,0,0,456,457,5,100,0,0,457,126,1,0,0,0,458,459,5,111,0,0,459,460,5,114,0,0,460,128,1,0,0,0,461,462,5,43,0,0,462,130,1,0,0,0,463,464,5,42,0,0,464,132,1,0,0,0,465,466,5,123,0,0,466,134,1,0,0,0,467,468,5,125,0,0,468,136,1,0,0,0,469,470,5,91,0,0,470,138,1,0,0,0,471,472,5,93,0,0,472,140,1,0,0,0,473,474,5,61,0,0,474,475,5,61,0,0,475,142,1,0,0,0,476,477,5,46,0,0,477,478,5,46,0,0,478,144,1,0,0,0,479,480,5,124,0,0,480,146,1,0,0,0,481,482,5,94,0,0,482,148,1,0,0,0,483,484,5,47,0,0,484,150,1,0,0,0,485,486,5,46,0,0,486,487,5,46,0,0,487,488,5,46,0,0,488,152,1,0,0,0,489,490,5,126,0,0,490,491,5,61,0,0,491,154,1,0,0,0,492,493,5,33,0,0,493,494,5,61,0,0,494,156,1,0,0,0,495,499,7,0,0,0,496,498,7,1,0,0,497,496,1,0,0,0,498,501,1,0,0,0,499,497,1,0,0,0,499,500,1,0,0,0,500,158,1,0,0,0,501,499,1,0,0,0,502,507,5,34,0,0,503,506,3,181,90,0,504,506,8,2,0,0,505,503,1,0,0,0,505,504,1,0,0,0,506,509,1,0,0,0,507,505,1,0,0,0,507,508,1,0,0,0,508,510,1,0,0,0,509,507,1,0,0,0,510,511,5,34,0,0,511,160,1,0,0,0,512,517,5,39,0,0,513,516,3,181,90,0,514,516,8,3,0,0,515,513,1,0,0,0,515,514,1,0,0,0,516,519,1,0,0,0,517,515,1,0,0,0,517,518,1,0,0,0,518,520,1,0,0,0,519,517,1,0,0,0,520,521,5,39,0,0,521,162,1,0,0,0,522,526,5,96,0,0,523,525,9,0,0,0,524,523,1,0,0,0,525,528,1,0,0,0,526,527,1,0,0,0,526,524,1,0,0,0,527,529,1,0,0,0,528,526,1,0,0,0,529,530,5,96,0,0,530,164,1,0,0,0,531,532,5,91,0,0,532,533,3,167,83,0,533,534,5,93,0,0,534,166,1,0,0,0,535,536,5,61,0,0,536,537,3,167,83,0,537,538,5,61,0,0,538,548,1,0,0,0,539,543,5,91,0,0,540,542,9,0,0,0,541,540,1,0,0,0,542,545,1,0,0,0,543,544,1,0,0,0,543,541,1,0,0,0,544,546,1,0,0,0,545,543,1,0,0,0,546,548,5,93,0,0,547,535,1,0,0,0,547,539,1,0,0,0,548,168,1,0,0,0,549,551,3,189,94,0,550,549,1,0,0,0,551,552,1,0,0,0,552,550,1,0,0,0,552,553,1,0,0,0,553,555,1,0,0,0,554,556,5,95,0,0,555,554,1,0,0,0,555,556,1,0,0,0,556,170,1,0,0,0,557,558,5,48,0,0,558,560,7,4,0,0,559,561,3,191,95,0,560,559,1,0,0,0,561,562,1,0,0,0,562,560,1,0,0,0,562,563,1,0,0,0,563,172,1,0,0,0,564,566,3,189,94,0,565,564,1,0,0,0,566,567,1,0,0,0,567,565,1,0,0,0,567,568,1,0,0,0,568,569,1,0,0,0,569,573,5,46,0,0,570,572,3,189,94,0,571,570,1,0,0,0,572,575,1,0,0,0,573,571,1,0,0,0,573,574,1,0,0,0,574,577,1,0,0,0,575,573,1,0,0,0,576,578,3,177,88,0,577,576,1,0,0,0,577,578,1,0,0,0,578,596,1,0,0,0,579,581,5,46,0,0,580,582,3,189,94,0,581,580,1,0,0,0,582,583,1,0,0,0,583,581,1,0,0,0,583,584,1,0,0,0,584,586,1,0,0,0,585,587,3,177,88,0,586,585,1,0,0,0,586,587,1,0,0,0,587,596,1,0,0,0,588,590,3,189,94,0,589,588,1,0,0,0,590,591,1,0,0,0,591,589,1,0,0,0,591,592,1,0,0,0,592,593,1,0,0,0,593,594,3,177,88,0,594,596,1,0,0,0,595,565,1,0,0,0,595,579,1,0,0,0,595,589,1,0,0,0,596,174,1,0,0,0,597,598,5,48,0,0,598,600,7,4,0,0,599,601,3,191,95,0,600,599,1,0,0,0,601,602,1,0,0,0,602,600,1,0,0,0,602,603,1,0,0,0,603,604,1,0,0,0,604,608,5,46,0,0,605,607,3,191,95,0,606,605,1,0,0,0,607,610,1,0,0,0,608,606,1,0,0,0,608,609,1,0,0,0,609,612,1,0,0,0,610,608,1,0,0,0,611,613,3,179,89,0,612,611,1,0,0,0,612,613,1,0,0,0,613,635,1,0,0,0,614,615,5,48,0,0,615,616,7,4,0,0,616,618,5,46,0,0,617,619,3,191,95,0,618,617,1,0,0,0,619,620,1,0,0,0,620,618,1,0,0,0,620,621,1,0,0,0,621,623,1,0,0,0,622,624,3,179,89,0,623,622,1,0,0,0,623,624,1,0,0,0,624,635,1,0,0,0,625,626,5,48,0,0,626,628,7,4,0,0,627,629,3,191,95,0,628,627,1,0,0,0,629,630,1,0,0,0,630,628,1,0,0,0,630,631,1,0,0,0,631,632,1,0,0,0,632,633,3,179,89,0,633,635,1,0,0,0,634,597,1,0,0,0,634,614,1,0,0,0,634,625,1,0,0,0,635,176,1,0,0,0,636,638,7,5,0,0,637,639,7,6,0,0,638,637,1,0,0,0,638,639,1,0,0,0,639,641,1,0,0,0,640,642,3,189,94,0,641,640,1,0,0,0,642,643,1,0,0,0,643,641,1,0,0,0,643,644,1,0,0,0,644,178,1,0,0,0,645,647,7,7,0,0,646,648,7,6,0,0,647,646,1,0,0,0,647,648,1,0,0,0,648,650,1,0,0,0,649,651,3,189,94,0,650,649,1,0,0,0,651,652,1,0,0,0,652,650,1,0,0,0,652,653,1,0,0,0,653,180,1,0,0,0,654,655,5,92,0,0,655,665,7,8,0,0,656,658,5,92,0,0,657,659,5,13,0,0,658,657,1,0,0,0,658,659,1,0,0,0,659,660,1,0,0,0,660,665,5,10,0,0,661,665,3,183,91,0,662,665,3,185,92,0,663,665,3,187,93,0,664,654,1,0,0,0,664,656,1,0,0,0,664,661,1,0,0,0,664,662,1,0,0,0,664,663,1,0,0,0,665,182,1,0,0,0,666,667,5,92,0,0,667,678,3,189,94,0,668,669,5,92,0,0,669,670,3,189,94,0,670,671,3,189,94,0,671,678,1,0,0,0,672,673,5,92,0,0,673,674,7,9,0,0,674,675,3,189,94,0,675,676,3,189,94,0,676,678,1,0,0,0,677,666,1,0,0,0,677,668,1,0,0,0,677,672,1,0,0,0,678,184,1,0,0,0,679,680,5,92,0,0,680,681,5,120,0,0,681,682,3,191,95,0,682,683,3,191,95,0,683,186,1,0,0,0,684,685,5,92,0,0,685,686,5,117,0,0,686,687,5,123,0,0,687,689,1,0,0,0,688,690,3,191,95,0,689,688,1,0,0,0,690,691,1,0,0,0,691,689,1,0,0,0,691,692,1,0,0,0,692,693,1,0,0,0,693,694,5,125,0,0,694,188,1,0,0,0,695,696,7,10,0,0,696,190,1,0,0,0,697,698,7,11,0,0,698,192,1,0,0,0,699,700,8,12,0,0,700,194,1,0,0,0,701,702,5,45,0,0,702,703,5,45,0,0,703,704,1,0,0,0,704,705,6,97,0,0,705,706,1,0,0,0,706,707,6,97,1,0,707,196,1,0,0,0,708,709,5,47,0,0,709,710,5,42,0,0,710,714,1,0,0,0,711,713,9,0,0,0,712,711,1,0,0,0,713,716,1,0,0,0,714,715,1,0,0,0,714,712,1,0,0,0,715,720,1,0,0,0,716,714,1,0,0,0,717,718,5,42,0,0,718,721,5,47,0,0,719,721,5,0,0,1,720,717,1,0,0,0,720,719,1,0,0,0,721,722,1,0,0,0,722,723,6,98,2,0,723,198,1,0,0,0,724,726,7,13,0,0,725,724,1,0,0,0,726,727,1,0,0,0,727,725,1,0,0,0,727,728,1,0,0,0,728,729,1,0,0,0,729,730,6,99,1,0,730,200,1,0,0,0,731,732,7,14,0,0,732,733,1,0,0,0,733,734,6,100,3,0,734,202,1,0,0,0,735,736,5,35,0,0,736,738,4,101,0,0,737,739,5,33,0,0,738,737,1,0,0,0,738,739,1,0,0,0,739,743,1,0,0,0,740,742,3,193,96,0,741,740,1,0,0,0,742,745,1,0,0,0,743,741,1,0,0,0,743,744,1,0,0,0,744,746,1,0,0,0,745,743,1,0,0,0,746,747,6,101,1,0,747,204,1,0,0,0,39,0,499,505,507,515,517,526,543,547,552,555,562,567,573,577,583,586,591,595,602,608,612,620,623,630,634,638,643,647,652,658,664,677,691,714,720,727,738,743,4,1,97,0,0,1,0,6,0,0,0,2,0],l.DecisionsToDFA=l._ATN.decisionToState.map((e,t)=>new N.DFA(e,t));var R=l;var a=require("antlr4"),r=class r extends a.Parser{get grammarFileName(){return"LuaParser.g4"}get literalNames(){return r.literalNames}get symbolicNames(){return r.symbolicNames}get ruleNames(){return r.ruleNames}get serializedATN(){return r._serializedATN}createFailedPredicateException(e,t){return new a.FailedPredicateException(this,e,t)}constructor(e){super(e),this._interp=new a.ParserATNSimulator(this,r._ATN,r.DecisionsToDFA,new a.PredictionContextCache)}start_(){let e=new Ot(this,this._ctx,this.state);this.enterRule(e,0,r.RULE_start_);try{this.enterOuterAlt(e,1),this.state=90,this.chunk(),this.state=91,this.match(r.EOF)}catch(t){if(t instanceof a.RecognitionException)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}chunk(){let e=new et(this,this._ctx,this.state);this.enterRule(e,2,r.RULE_chunk);try{this.enterOuterAlt(e,1),this.state=93,this.block()}catch(t){if(t instanceof a.RecognitionException)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}block(){let e=new k(this,this._ctx,this.state);this.enterRule(e,4,r.RULE_block);let t;try{let i;this.enterOuterAlt(e,1);{for(this.state=98,this._errHandler.sync(this),i=this._interp.adaptivePredict(this._input,0,this._ctx);i!==2&&i!==a.ATN.INVALID_ALT_NUMBER;)i===1&&(this.state=95,this.stat()),this.state=100,this._errHandler.sync(this),i=this._interp.adaptivePredict(this._input,0,this._ctx);this.state=102,this._errHandler.sync(this),t=this._input.LA(1),!(t-24&-32)&&1<>='","'&='","'|='","'^='","'defer'","'@'","'break'","'goto'","'do'","'end'","'while'","'repeat'","'until'","'if'","'then'","'elseif'","'else'","'for'","','","'in'","'function'","'local'","'<'","'>'","'return'","'continue'","'::'","'nil'","'false'","'true'","'.'","'~'","'-'","'#'","'('","')'","'not'","'<<'","'>>'","'&'","'//'","'%'","':'","'<='","'>='","'and'","'or'","'+'","'*'","'{'","'}'","'['","']'","'=='","'..'","'|'","'^'","'/'","'...'","'~='","'!='"],r.symbolicNames=[null,"SEMI","EQ","NEW","CLASS","EXTENDS","USING","FILTER","IS","TRY","CATCH","THROW","QUESTMARK","COMPPLUS","COMPMINUS","COMPSTAR","COMPSLASH","COMPLL","COMPGG","COMPAMP","COMPPIPE","COMPCARET","DEFER","AT","BREAK","GOTO","DO","END","WHILE","REPEAT","UNTIL","IF","THEN","ELSEIF","ELSE","FOR","COMMA","IN","FUNCTION","LOCAL","LT","GT","RETURN","CONTINUE","CC","NIL","FALSE","TRUE","DOT","SQUIG","MINUS","POUND","OP","CP","NOT","LL","GG","AMP","SS","PER","COL","LE","GE","AND","OR","PLUS","STAR","OCU","CCU","OB","CB","EE","DD","PIPE","CARET","SLASH","DDD","SQEQ","NOTEQ_ALT","NAME","NORMALSTRING","CHARSTRING","JENKINSHASHSTRING","LONGSTRING","INT","HEX","FLOAT","HEX_FLOAT","COMMENT","C_COMMENT","WS","NL","SHEBANG"],r.ruleNames=["start_","chunk","block","stat","attnamelist","attrib","retstat","label","funcname","varlist","namelist","decorator","decoratorbody","newcall","explist","exp","filterfield","filterfieldlist","tablecomprehension","compactfunc","indexed_member","var","prefixexp","functioncall","compound","argument","argumentlist","args","functiondef","funcbody","class","isop","type","partype","defaultvalue","extendedpar","extendedparlist","parlist","tableconstructor","fieldlist","field","fieldsep","identifier","number","string"],r._serializedATN=[4,1,92,724,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,1,0,1,0,1,0,1,1,1,1,1,2,5,2,97,8,2,10,2,12,2,100,9,2,1,2,3,2,103,8,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,112,8,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,5,3,139,8,3,10,3,12,3,142,9,3,1,3,1,3,3,3,146,8,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,158,8,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,5,3,177,8,3,10,3,12,3,180,9,3,1,3,1,3,1,3,1,3,1,3,5,3,187,8,3,10,3,12,3,190,9,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,203,8,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,212,8,3,1,3,3,3,215,8,3,1,3,1,3,1,3,1,3,3,3,221,8,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,237,8,3,3,3,239,8,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,247,8,3,1,4,1,4,1,4,1,4,1,4,1,4,5,4,255,8,4,10,4,12,4,258,9,4,1,5,1,5,1,5,1,5,3,5,264,8,5,1,6,1,6,3,6,268,8,6,1,6,1,6,3,6,272,8,6,1,6,3,6,275,8,6,1,7,1,7,1,7,1,7,1,8,1,8,1,8,5,8,284,8,8,10,8,12,8,287,9,8,1,8,1,8,3,8,291,8,8,1,9,1,9,1,9,5,9,296,8,9,10,9,12,9,299,9,9,1,10,1,10,1,10,5,10,304,8,10,10,10,12,10,307,9,10,1,11,1,11,1,11,1,11,1,12,1,12,3,12,315,8,12,1,12,3,12,318,8,12,1,13,1,13,1,13,1,14,1,14,1,14,5,14,326,8,14,10,14,12,14,329,9,14,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,3,15,347,8,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,5,15,383,8,15,10,15,12,15,386,9,15,1,16,1,16,1,16,3,16,391,8,16,1,17,1,17,1,17,1,17,5,17,397,8,17,10,17,12,17,400,9,17,1,17,3,17,403,8,17,1,18,1,18,1,18,1,18,3,18,409,8,18,1,18,1,18,1,18,1,18,1,18,1,18,3,18,417,8,18,1,18,1,18,1,19,3,19,422,8,19,1,19,1,19,3,19,426,8,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,3,19,444,8,19,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,3,20,455,8,20,1,21,1,21,1,21,1,21,3,21,461,8,21,1,22,1,22,5,22,465,8,22,10,22,12,22,468,9,22,1,22,1,22,5,22,472,8,22,10,22,12,22,475,9,22,1,22,1,22,1,22,1,22,5,22,481,8,22,10,22,12,22,484,9,22,3,22,486,8,22,1,23,1,23,1,23,5,23,491,8,23,10,23,12,23,494,9,23,1,23,1,23,1,23,1,23,1,23,1,23,5,23,502,8,23,10,23,12,23,505,9,23,1,23,1,23,1,23,1,23,5,23,511,8,23,10,23,12,23,514,9,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,5,23,524,8,23,10,23,12,23,527,9,23,1,23,1,23,1,23,1,23,3,23,533,8,23,1,23,1,23,5,23,537,8,23,10,23,12,23,540,9,23,1,23,1,23,1,23,5,23,545,8,23,10,23,12,23,548,9,23,1,23,1,23,1,23,1,23,5,23,554,8,23,10,23,12,23,557,9,23,1,24,1,24,1,24,1,24,1,25,1,25,1,25,3,25,566,8,25,1,25,1,25,1,26,1,26,1,26,5,26,573,8,26,10,26,12,26,576,9,26,1,27,1,27,3,27,580,8,27,1,27,1,27,1,27,3,27,585,8,27,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,30,5,30,597,8,30,10,30,12,30,600,9,30,1,30,1,30,1,30,1,30,3,30,606,8,30,1,30,1,30,1,31,1,31,1,31,1,31,1,32,1,32,3,32,616,8,32,1,33,1,33,1,33,1,33,5,33,622,8,33,10,33,12,33,625,9,33,3,33,627,8,33,1,34,1,34,1,34,3,34,632,8,34,1,35,1,35,1,35,1,35,1,36,1,36,1,36,5,36,641,8,36,10,36,12,36,644,9,36,1,37,1,37,1,37,3,37,649,8,37,1,37,1,37,3,37,653,8,37,1,38,1,38,3,38,657,8,38,1,38,1,38,1,39,1,39,1,39,1,39,5,39,665,8,39,10,39,12,39,668,9,39,1,39,3,39,671,8,39,1,40,4,40,674,8,40,11,40,12,40,675,1,40,1,40,1,40,1,40,1,40,1,40,1,40,4,40,685,8,40,11,40,12,40,686,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,3,40,706,8,40,1,41,1,41,1,42,1,42,1,43,4,43,713,8,43,11,43,12,43,714,1,43,1,43,1,43,3,43,720,8,43,1,44,1,44,1,44,0,2,30,46,45,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,0,10,2,0,49,51,54,54,3,0,58,59,66,66,75,75,2,0,50,50,65,65,4,0,40,41,61,62,71,71,77,78,1,0,63,64,3,0,49,49,55,57,73,73,1,0,13,21,2,0,1,1,36,36,3,0,3,10,22,22,79,79,1,0,80,83,807,0,90,1,0,0,0,2,93,1,0,0,0,4,98,1,0,0,0,6,246,1,0,0,0,8,248,1,0,0,0,10,263,1,0,0,0,12,271,1,0,0,0,14,276,1,0,0,0,16,280,1,0,0,0,18,292,1,0,0,0,20,300,1,0,0,0,22,308,1,0,0,0,24,317,1,0,0,0,26,319,1,0,0,0,28,322,1,0,0,0,30,346,1,0,0,0,32,387,1,0,0,0,34,392,1,0,0,0,36,404,1,0,0,0,38,443,1,0,0,0,40,454,1,0,0,0,42,460,1,0,0,0,44,485,1,0,0,0,46,532,1,0,0,0,48,558,1,0,0,0,50,565,1,0,0,0,52,569,1,0,0,0,54,584,1,0,0,0,56,586,1,0,0,0,58,589,1,0,0,0,60,598,1,0,0,0,62,609,1,0,0,0,64,615,1,0,0,0,66,626,1,0,0,0,68,631,1,0,0,0,70,633,1,0,0,0,72,637,1,0,0,0,74,652,1,0,0,0,76,654,1,0,0,0,78,660,1,0,0,0,80,705,1,0,0,0,82,707,1,0,0,0,84,709,1,0,0,0,86,719,1,0,0,0,88,721,1,0,0,0,90,91,3,2,1,0,91,92,5,0,0,1,92,1,1,0,0,0,93,94,3,4,2,0,94,3,1,0,0,0,95,97,3,6,3,0,96,95,1,0,0,0,97,100,1,0,0,0,98,96,1,0,0,0,98,99,1,0,0,0,99,102,1,0,0,0,100,98,1,0,0,0,101,103,3,12,6,0,102,101,1,0,0,0,102,103,1,0,0,0,103,5,1,0,0,0,104,247,5,1,0,0,105,106,3,18,9,0,106,107,5,2,0,0,107,108,3,28,14,0,108,247,1,0,0,0,109,247,3,48,24,0,110,112,5,3,0,0,111,110,1,0,0,0,111,112,1,0,0,0,112,113,1,0,0,0,113,247,3,46,23,0,114,247,3,14,7,0,115,247,5,24,0,0,116,117,5,25,0,0,117,247,3,84,42,0,118,119,5,28,0,0,119,120,3,30,15,0,120,121,5,26,0,0,121,122,3,4,2,0,122,123,5,27,0,0,123,247,1,0,0,0,124,125,5,29,0,0,125,126,3,4,2,0,126,127,5,30,0,0,127,128,3,30,15,0,128,247,1,0,0,0,129,130,5,31,0,0,130,131,3,30,15,0,131,132,5,32,0,0,132,140,3,4,2,0,133,134,5,33,0,0,134,135,3,30,15,0,135,136,5,32,0,0,136,137,3,4,2,0,137,139,1,0,0,0,138,133,1,0,0,0,139,142,1,0,0,0,140,138,1,0,0,0,140,141,1,0,0,0,141,145,1,0,0,0,142,140,1,0,0,0,143,144,5,34,0,0,144,146,3,4,2,0,145,143,1,0,0,0,145,146,1,0,0,0,146,147,1,0,0,0,147,148,5,27,0,0,148,247,1,0,0,0,149,150,5,35,0,0,150,151,3,84,42,0,151,152,5,2,0,0,152,153,3,30,15,0,153,154,5,36,0,0,154,157,3,30,15,0,155,156,5,36,0,0,156,158,3,30,15,0,157,155,1,0,0,0,157,158,1,0,0,0,158,159,1,0,0,0,159,160,5,26,0,0,160,161,3,4,2,0,161,162,5,27,0,0,162,247,1,0,0,0,163,164,5,35,0,0,164,165,3,20,10,0,165,166,5,37,0,0,166,167,3,28,14,0,167,168,5,26,0,0,168,169,3,4,2,0,169,170,5,27,0,0,170,247,1,0,0,0,171,172,5,26,0,0,172,173,3,4,2,0,173,174,5,27,0,0,174,247,1,0,0,0,175,177,3,22,11,0,176,175,1,0,0,0,177,180,1,0,0,0,178,176,1,0,0,0,178,179,1,0,0,0,179,181,1,0,0,0,180,178,1,0,0,0,181,182,5,38,0,0,182,183,3,16,8,0,183,184,3,58,29,0,184,247,1,0,0,0,185,187,3,22,11,0,186,185,1,0,0,0,187,190,1,0,0,0,188,186,1,0,0,0,188,189,1,0,0,0,189,191,1,0,0,0,190,188,1,0,0,0,191,192,5,39,0,0,192,193,5,38,0,0,193,194,3,84,42,0,194,195,3,58,29,0,195,247,1,0,0,0,196,197,5,7,0,0,197,202,3,16,8,0,198,199,5,52,0,0,199,200,3,74,37,0,200,201,5,53,0,0,201,203,1,0,0,0,202,198,1,0,0,0,202,203,1,0,0,0,203,204,1,0,0,0,204,205,3,34,17,0,205,206,5,27,0,0,206,247,1,0,0,0,207,208,5,6,0,0,208,214,3,84,42,0,209,211,5,52,0,0,210,212,3,28,14,0,211,210,1,0,0,0,211,212,1,0,0,0,212,213,1,0,0,0,213,215,5,53,0,0,214,209,1,0,0,0,214,215,1,0,0,0,215,247,1,0,0,0,216,217,5,39,0,0,217,220,3,8,4,0,218,219,5,2,0,0,219,221,3,28,14,0,220,218,1,0,0,0,220,221,1,0,0,0,221,247,1,0,0,0,222,223,5,39,0,0,223,224,3,8,4,0,224,225,5,37,0,0,225,226,3,44,22,0,226,247,1,0,0,0,227,228,5,22,0,0,228,229,3,4,2,0,229,230,5,27,0,0,230,247,1,0,0,0,231,232,5,9,0,0,232,233,3,4,2,0,233,238,5,10,0,0,234,236,3,84,42,0,235,237,5,32,0,0,236,235,1,0,0,0,236,237,1,0,0,0,237,239,1,0,0,0,238,234,1,0,0,0,238,239,1,0,0,0,239,240,1,0,0,0,240,241,3,4,2,0,241,242,5,27,0,0,242,247,1,0,0,0,243,244,5,11,0,0,244,247,3,30,15,0,245,247,3,60,30,0,246,104,1,0,0,0,246,105,1,0,0,0,246,109,1,0,0,0,246,111,1,0,0,0,246,114,1,0,0,0,246,115,1,0,0,0,246,116,1,0,0,0,246,118,1,0,0,0,246,124,1,0,0,0,246,129,1,0,0,0,246,149,1,0,0,0,246,163,1,0,0,0,246,171,1,0,0,0,246,178,1,0,0,0,246,188,1,0,0,0,246,196,1,0,0,0,246,207,1,0,0,0,246,216,1,0,0,0,246,222,1,0,0,0,246,227,1,0,0,0,246,231,1,0,0,0,246,243,1,0,0,0,246,245,1,0,0,0,247,7,1,0,0,0,248,249,3,84,42,0,249,256,3,10,5,0,250,251,5,36,0,0,251,252,3,84,42,0,252,253,3,10,5,0,253,255,1,0,0,0,254,250,1,0,0,0,255,258,1,0,0,0,256,254,1,0,0,0,256,257,1,0,0,0,257,9,1,0,0,0,258,256,1,0,0,0,259,260,5,40,0,0,260,261,3,84,42,0,261,262,5,41,0,0,262,264,1,0,0,0,263,259,1,0,0,0,263,264,1,0,0,0,264,11,1,0,0,0,265,267,5,42,0,0,266,268,3,28,14,0,267,266,1,0,0,0,267,268,1,0,0,0,268,272,1,0,0,0,269,272,5,24,0,0,270,272,5,43,0,0,271,265,1,0,0,0,271,269,1,0,0,0,271,270,1,0,0,0,272,274,1,0,0,0,273,275,5,1,0,0,274,273,1,0,0,0,274,275,1,0,0,0,275,13,1,0,0,0,276,277,5,44,0,0,277,278,3,84,42,0,278,279,5,44,0,0,279,15,1,0,0,0,280,285,3,84,42,0,281,282,5,48,0,0,282,284,3,84,42,0,283,281,1,0,0,0,284,287,1,0,0,0,285,283,1,0,0,0,285,286,1,0,0,0,286,290,1,0,0,0,287,285,1,0,0,0,288,289,5,60,0,0,289,291,3,84,42,0,290,288,1,0,0,0,290,291,1,0,0,0,291,17,1,0,0,0,292,297,3,42,21,0,293,294,5,36,0,0,294,296,3,42,21,0,295,293,1,0,0,0,296,299,1,0,0,0,297,295,1,0,0,0,297,298,1,0,0,0,298,19,1,0,0,0,299,297,1,0,0,0,300,305,3,84,42,0,301,302,5,36,0,0,302,304,3,84,42,0,303,301,1,0,0,0,304,307,1,0,0,0,305,303,1,0,0,0,305,306,1,0,0,0,306,21,1,0,0,0,307,305,1,0,0,0,308,309,5,23,0,0,309,310,3,42,21,0,310,311,3,24,12,0,311,23,1,0,0,0,312,314,5,52,0,0,313,315,3,28,14,0,314,313,1,0,0,0,314,315,1,0,0,0,315,316,1,0,0,0,316,318,5,53,0,0,317,312,1,0,0,0,317,318,1,0,0,0,318,25,1,0,0,0,319,320,5,3,0,0,320,321,3,46,23,0,321,27,1,0,0,0,322,327,3,30,15,0,323,324,5,36,0,0,324,326,3,30,15,0,325,323,1,0,0,0,326,329,1,0,0,0,327,325,1,0,0,0,327,328,1,0,0,0,328,29,1,0,0,0,329,327,1,0,0,0,330,331,6,15,-1,0,331,347,5,45,0,0,332,347,5,46,0,0,333,347,5,47,0,0,334,347,3,86,43,0,335,347,3,88,44,0,336,347,5,76,0,0,337,347,3,26,13,0,338,347,3,38,19,0,339,347,3,36,18,0,340,347,3,56,28,0,341,347,3,44,22,0,342,347,3,76,38,0,343,344,7,0,0,0,344,347,3,30,15,11,345,347,3,62,31,0,346,330,1,0,0,0,346,332,1,0,0,0,346,333,1,0,0,0,346,334,1,0,0,0,346,335,1,0,0,0,346,336,1,0,0,0,346,337,1,0,0,0,346,338,1,0,0,0,346,339,1,0,0,0,346,340,1,0,0,0,346,341,1,0,0,0,346,342,1,0,0,0,346,343,1,0,0,0,346,345,1,0,0,0,347,384,1,0,0,0,348,349,10,12,0,0,349,350,5,74,0,0,350,383,3,30,15,12,351,352,10,10,0,0,352,353,7,1,0,0,353,383,3,30,15,11,354,355,10,9,0,0,355,356,7,2,0,0,356,383,3,30,15,10,357,358,10,8,0,0,358,359,5,72,0,0,359,383,3,30,15,8,360,361,10,7,0,0,361,362,7,3,0,0,362,383,3,30,15,8,363,364,10,6,0,0,364,365,7,4,0,0,365,383,3,30,15,7,366,367,10,5,0,0,367,368,7,5,0,0,368,383,3,30,15,6,369,370,10,3,0,0,370,371,5,37,0,0,371,383,3,30,15,4,372,373,10,2,0,0,373,374,5,54,0,0,374,375,5,37,0,0,375,383,3,30,15,3,376,377,10,1,0,0,377,378,5,12,0,0,378,379,3,30,15,0,379,380,5,60,0,0,380,381,3,30,15,2,381,383,1,0,0,0,382,348,1,0,0,0,382,351,1,0,0,0,382,354,1,0,0,0,382,357,1,0,0,0,382,360,1,0,0,0,382,363,1,0,0,0,382,366,1,0,0,0,382,369,1,0,0,0,382,372,1,0,0,0,382,376,1,0,0,0,383,386,1,0,0,0,384,382,1,0,0,0,384,385,1,0,0,0,385,31,1,0,0,0,386,384,1,0,0,0,387,390,3,30,15,0,388,389,5,34,0,0,389,391,3,28,14,0,390,388,1,0,0,0,390,391,1,0,0,0,391,33,1,0,0,0,392,398,3,32,16,0,393,394,3,82,41,0,394,395,3,32,16,0,395,397,1,0,0,0,396,393,1,0,0,0,397,400,1,0,0,0,398,396,1,0,0,0,398,399,1,0,0,0,399,402,1,0,0,0,400,398,1,0,0,0,401,403,3,82,41,0,402,401,1,0,0,0,402,403,1,0,0,0,403,35,1,0,0,0,404,405,5,67,0,0,405,408,3,30,15,0,406,407,5,36,0,0,407,409,3,30,15,0,408,406,1,0,0,0,408,409,1,0,0,0,409,410,1,0,0,0,410,411,5,35,0,0,411,412,3,20,10,0,412,413,5,37,0,0,413,416,3,28,14,0,414,415,5,31,0,0,415,417,3,30,15,0,416,414,1,0,0,0,416,417,1,0,0,0,417,418,1,0,0,0,418,419,5,68,0,0,419,37,1,0,0,0,420,422,5,52,0,0,421,420,1,0,0,0,421,422,1,0,0,0,422,423,1,0,0,0,423,425,3,84,42,0,424,426,5,53,0,0,425,424,1,0,0,0,425,426,1,0,0,0,426,427,1,0,0,0,427,428,5,26,0,0,428,429,3,30,15,0,429,444,1,0,0,0,430,431,5,52,0,0,431,432,3,74,37,0,432,433,5,53,0,0,433,434,5,26,0,0,434,435,3,4,2,0,435,436,5,27,0,0,436,444,1,0,0,0,437,438,5,52,0,0,438,439,3,74,37,0,439,440,5,53,0,0,440,441,5,26,0,0,441,442,3,30,15,0,442,444,1,0,0,0,443,421,1,0,0,0,443,430,1,0,0,0,443,437,1,0,0,0,444,39,1,0,0,0,445,446,5,69,0,0,446,447,3,30,15,0,447,448,5,70,0,0,448,455,1,0,0,0,449,450,5,48,0,0,450,455,3,84,42,0,451,452,5,12,0,0,452,453,5,48,0,0,453,455,3,84,42,0,454,445,1,0,0,0,454,449,1,0,0,0,454,451,1,0,0,0,455,41,1,0,0,0,456,461,3,84,42,0,457,458,3,44,22,0,458,459,3,40,20,0,459,461,1,0,0,0,460,456,1,0,0,0,460,457,1,0,0,0,461,43,1,0,0,0,462,466,3,84,42,0,463,465,3,40,20,0,464,463,1,0,0,0,465,468,1,0,0,0,466,464,1,0,0,0,466,467,1,0,0,0,467,486,1,0,0,0,468,466,1,0,0,0,469,473,3,46,23,0,470,472,3,40,20,0,471,470,1,0,0,0,472,475,1,0,0,0,473,471,1,0,0,0,473,474,1,0,0,0,474,486,1,0,0,0,475,473,1,0,0,0,476,477,5,52,0,0,477,478,3,30,15,0,478,482,5,53,0,0,479,481,3,40,20,0,480,479,1,0,0,0,481,484,1,0,0,0,482,480,1,0,0,0,482,483,1,0,0,0,483,486,1,0,0,0,484,482,1,0,0,0,485,462,1,0,0,0,485,469,1,0,0,0,485,476,1,0,0,0,486,45,1,0,0,0,487,488,6,23,-1,0,488,492,3,84,42,0,489,491,3,40,20,0,490,489,1,0,0,0,491,494,1,0,0,0,492,490,1,0,0,0,492,493,1,0,0,0,493,495,1,0,0,0,494,492,1,0,0,0,495,496,3,54,27,0,496,533,1,0,0,0,497,498,5,52,0,0,498,499,3,30,15,0,499,503,5,53,0,0,500,502,3,40,20,0,501,500,1,0,0,0,502,505,1,0,0,0,503,501,1,0,0,0,503,504,1,0,0,0,504,506,1,0,0,0,505,503,1,0,0,0,506,507,3,54,27,0,507,533,1,0,0,0,508,512,3,84,42,0,509,511,3,40,20,0,510,509,1,0,0,0,511,514,1,0,0,0,512,510,1,0,0,0,512,513,1,0,0,0,513,515,1,0,0,0,514,512,1,0,0,0,515,516,5,60,0,0,516,517,3,84,42,0,517,518,3,54,27,0,518,533,1,0,0,0,519,520,5,52,0,0,520,521,3,30,15,0,521,525,5,53,0,0,522,524,3,40,20,0,523,522,1,0,0,0,524,527,1,0,0,0,525,523,1,0,0,0,525,526,1,0,0,0,526,528,1,0,0,0,527,525,1,0,0,0,528,529,5,60,0,0,529,530,3,84,42,0,530,531,3,54,27,0,531,533,1,0,0,0,532,487,1,0,0,0,532,497,1,0,0,0,532,508,1,0,0,0,532,519,1,0,0,0,533,555,1,0,0,0,534,538,10,5,0,0,535,537,3,40,20,0,536,535,1,0,0,0,537,540,1,0,0,0,538,536,1,0,0,0,538,539,1,0,0,0,539,541,1,0,0,0,540,538,1,0,0,0,541,554,3,54,27,0,542,546,10,2,0,0,543,545,3,40,20,0,544,543,1,0,0,0,545,548,1,0,0,0,546,544,1,0,0,0,546,547,1,0,0,0,547,549,1,0,0,0,548,546,1,0,0,0,549,550,5,60,0,0,550,551,3,84,42,0,551,552,3,54,27,0,552,554,1,0,0,0,553,534,1,0,0,0,553,542,1,0,0,0,554,557,1,0,0,0,555,553,1,0,0,0,555,556,1,0,0,0,556,47,1,0,0,0,557,555,1,0,0,0,558,559,3,42,21,0,559,560,7,6,0,0,560,561,3,30,15,0,561,49,1,0,0,0,562,563,3,84,42,0,563,564,5,2,0,0,564,566,1,0,0,0,565,562,1,0,0,0,565,566,1,0,0,0,566,567,1,0,0,0,567,568,3,30,15,0,568,51,1,0,0,0,569,574,3,50,25,0,570,571,5,36,0,0,571,573,3,50,25,0,572,570,1,0,0,0,573,576,1,0,0,0,574,572,1,0,0,0,574,575,1,0,0,0,575,53,1,0,0,0,576,574,1,0,0,0,577,579,5,52,0,0,578,580,3,52,26,0,579,578,1,0,0,0,579,580,1,0,0,0,580,581,1,0,0,0,581,585,5,53,0,0,582,585,3,76,38,0,583,585,3,88,44,0,584,577,1,0,0,0,584,582,1,0,0,0,584,583,1,0,0,0,585,55,1,0,0,0,586,587,5,38,0,0,587,588,3,58,29,0,588,57,1,0,0,0,589,590,5,52,0,0,590,591,3,74,37,0,591,592,5,53,0,0,592,593,3,4,2,0,593,594,5,27,0,0,594,59,1,0,0,0,595,597,3,22,11,0,596,595,1,0,0,0,597,600,1,0,0,0,598,596,1,0,0,0,598,599,1,0,0,0,599,601,1,0,0,0,600,598,1,0,0,0,601,602,5,4,0,0,602,605,3,84,42,0,603,604,5,5,0,0,604,606,3,84,42,0,605,603,1,0,0,0,605,606,1,0,0,0,606,607,1,0,0,0,607,608,3,76,38,0,608,61,1,0,0,0,609,610,3,42,21,0,610,611,5,8,0,0,611,612,3,42,21,0,612,63,1,0,0,0,613,616,3,84,42,0,614,616,5,45,0,0,615,613,1,0,0,0,615,614,1,0,0,0,616,65,1,0,0,0,617,618,5,60,0,0,618,623,3,64,32,0,619,620,5,73,0,0,620,622,3,64,32,0,621,619,1,0,0,0,622,625,1,0,0,0,623,621,1,0,0,0,623,624,1,0,0,0,624,627,1,0,0,0,625,623,1,0,0,0,626,617,1,0,0,0,626,627,1,0,0,0,627,67,1,0,0,0,628,629,5,2,0,0,629,632,3,30,15,0,630,632,1,0,0,0,631,628,1,0,0,0,631,630,1,0,0,0,632,69,1,0,0,0,633,634,3,84,42,0,634,635,3,66,33,0,635,636,3,68,34,0,636,71,1,0,0,0,637,642,3,70,35,0,638,639,5,36,0,0,639,641,3,70,35,0,640,638,1,0,0,0,641,644,1,0,0,0,642,640,1,0,0,0,642,643,1,0,0,0,643,73,1,0,0,0,644,642,1,0,0,0,645,648,3,72,36,0,646,647,5,36,0,0,647,649,5,76,0,0,648,646,1,0,0,0,648,649,1,0,0,0,649,653,1,0,0,0,650,653,5,76,0,0,651,653,1,0,0,0,652,645,1,0,0,0,652,650,1,0,0,0,652,651,1,0,0,0,653,75,1,0,0,0,654,656,5,67,0,0,655,657,3,78,39,0,656,655,1,0,0,0,656,657,1,0,0,0,657,658,1,0,0,0,658,659,5,68,0,0,659,77,1,0,0,0,660,666,3,80,40,0,661,662,3,82,41,0,662,663,3,80,40,0,663,665,1,0,0,0,664,661,1,0,0,0,665,668,1,0,0,0,666,664,1,0,0,0,666,667,1,0,0,0,667,670,1,0,0,0,668,666,1,0,0,0,669,671,3,82,41,0,670,669,1,0,0,0,670,671,1,0,0,0,671,79,1,0,0,0,672,674,3,22,11,0,673,672,1,0,0,0,674,675,1,0,0,0,675,673,1,0,0,0,675,676,1,0,0,0,676,677,1,0,0,0,677,678,5,69,0,0,678,679,3,30,15,0,679,680,5,70,0,0,680,681,5,2,0,0,681,682,3,56,28,0,682,706,1,0,0,0,683,685,3,22,11,0,684,683,1,0,0,0,685,686,1,0,0,0,686,684,1,0,0,0,686,687,1,0,0,0,687,688,1,0,0,0,688,689,3,84,42,0,689,690,5,2,0,0,690,691,3,56,28,0,691,706,1,0,0,0,692,693,5,69,0,0,693,694,3,30,15,0,694,695,5,70,0,0,695,696,5,2,0,0,696,697,3,30,15,0,697,706,1,0,0,0,698,699,5,48,0,0,699,706,3,84,42,0,700,701,3,84,42,0,701,702,5,2,0,0,702,703,3,30,15,0,703,706,1,0,0,0,704,706,3,30,15,0,705,673,1,0,0,0,705,684,1,0,0,0,705,692,1,0,0,0,705,698,1,0,0,0,705,700,1,0,0,0,705,704,1,0,0,0,706,81,1,0,0,0,707,708,7,7,0,0,708,83,1,0,0,0,709,710,7,8,0,0,710,85,1,0,0,0,711,713,5,84,0,0,712,711,1,0,0,0,713,714,1,0,0,0,714,712,1,0,0,0,714,715,1,0,0,0,715,720,1,0,0,0,716,720,5,85,0,0,717,720,5,86,0,0,718,720,5,87,0,0,719,712,1,0,0,0,719,716,1,0,0,0,719,717,1,0,0,0,719,718,1,0,0,0,720,87,1,0,0,0,721,722,7,9,0,0,722,89,1,0,0,0,74,98,102,111,140,145,157,178,188,202,211,214,220,236,238,246,256,263,267,271,274,285,290,297,305,314,317,327,346,382,384,390,398,402,408,416,421,425,443,454,460,466,473,482,485,492,503,512,525,532,538,546,553,555,565,574,579,584,598,605,615,623,626,631,642,648,652,656,666,670,675,686,705,714,719],r.DecisionsToDFA=r._ATN.decisionToState.map((e,t)=>new a.DFA(e,t));var n=r,Ot=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}chunk(){return this.getTypedRuleContext(et,0)}EOF(){return this.getToken(n.EOF,0)}get ruleIndex(){return n.RULE_start_}enterRule(e){e.enterStart_&&e.enterStart_(this)}exitRule(e){e.exitStart_&&e.exitStart_(this)}},et=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}block(){return this.getTypedRuleContext(k,0)}get ruleIndex(){return n.RULE_chunk}enterRule(e){e.enterChunk&&e.enterChunk(this)}exitRule(e){e.exitChunk&&e.exitChunk(this)}},k=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}stat_list(){return this.getTypedRuleContexts(j)}stat(e){return this.getTypedRuleContext(j,e)}retstat(){return this.getTypedRuleContext(rt,0)}get ruleIndex(){return n.RULE_block}enterRule(e){e.enterBlock&&e.enterBlock(this)}exitRule(e){e.exitBlock&&e.exitBlock(this)}},j=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}SEMI(){return this.getToken(n.SEMI,0)}varlist(){return this.getTypedRuleContext(at,0)}EQ(){return this.getToken(n.EQ,0)}explist(){return this.getTypedRuleContext(v,0)}compound(){return this.getTypedRuleContext(dt,0)}functioncall(){return this.getTypedRuleContext(I,0)}NEW(){return this.getToken(n.NEW,0)}label(){return this.getTypedRuleContext(nt,0)}BREAK(){return this.getToken(n.BREAK,0)}GOTO(){return this.getToken(n.GOTO,0)}identifier(){return this.getTypedRuleContext(f,0)}WHILE(){return this.getToken(n.WHILE,0)}exp_list(){return this.getTypedRuleContexts(x)}exp(e){return this.getTypedRuleContext(x,e)}DO(){return this.getToken(n.DO,0)}block_list(){return this.getTypedRuleContexts(k)}block(e){return this.getTypedRuleContext(k,e)}END(){return this.getToken(n.END,0)}REPEAT(){return this.getToken(n.REPEAT,0)}UNTIL(){return this.getToken(n.UNTIL,0)}IF(){return this.getToken(n.IF,0)}THEN_list(){return this.getTokens(n.THEN)}THEN(e){return this.getToken(n.THEN,e)}ELSEIF_list(){return this.getTokens(n.ELSEIF)}ELSEIF(e){return this.getToken(n.ELSEIF,e)}ELSE(){return this.getToken(n.ELSE,0)}FOR(){return this.getToken(n.FOR,0)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(e){return this.getToken(n.COMMA,e)}namelist(){return this.getTypedRuleContext(V,0)}IN(){return this.getToken(n.IN,0)}FUNCTION(){return this.getToken(n.FUNCTION,0)}funcname(){return this.getTypedRuleContext(st,0)}funcbody(){return this.getTypedRuleContext(z,0)}decorator_list(){return this.getTypedRuleContexts(O)}decorator(e){return this.getTypedRuleContext(O,e)}LOCAL(){return this.getToken(n.LOCAL,0)}FILTER(){return this.getToken(n.FILTER,0)}filterfieldlist(){return this.getTypedRuleContext(ct,0)}OP(){return this.getToken(n.OP,0)}parlist(){return this.getTypedRuleContext(w,0)}CP(){return this.getToken(n.CP,0)}USING(){return this.getToken(n.USING,0)}attnamelist(){return this.getTypedRuleContext(it,0)}prefixexp(){return this.getTypedRuleContext(P,0)}DEFER(){return this.getToken(n.DEFER,0)}TRY(){return this.getToken(n.TRY,0)}CATCH(){return this.getToken(n.CATCH,0)}THROW(){return this.getToken(n.THROW,0)}class_(){return this.getTypedRuleContext(bt,0)}get ruleIndex(){return n.RULE_stat}enterRule(e){e.enterStat&&e.enterStat(this)}exitRule(e){e.exitStat&&e.exitStat(this)}},it=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier_list(){return this.getTypedRuleContexts(f)}identifier(e){return this.getTypedRuleContext(f,e)}attrib_list(){return this.getTypedRuleContexts(Q)}attrib(e){return this.getTypedRuleContext(Q,e)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(e){return this.getToken(n.COMMA,e)}get ruleIndex(){return n.RULE_attnamelist}enterRule(e){e.enterAttnamelist&&e.enterAttnamelist(this)}exitRule(e){e.exitAttnamelist&&e.exitAttnamelist(this)}},Q=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}LT(){return this.getToken(n.LT,0)}identifier(){return this.getTypedRuleContext(f,0)}GT(){return this.getToken(n.GT,0)}get ruleIndex(){return n.RULE_attrib}enterRule(e){e.enterAttrib&&e.enterAttrib(this)}exitRule(e){e.exitAttrib&&e.exitAttrib(this)}},rt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}RETURN(){return this.getToken(n.RETURN,0)}BREAK(){return this.getToken(n.BREAK,0)}CONTINUE(){return this.getToken(n.CONTINUE,0)}SEMI(){return this.getToken(n.SEMI,0)}explist(){return this.getTypedRuleContext(v,0)}get ruleIndex(){return n.RULE_retstat}enterRule(e){e.enterRetstat&&e.enterRetstat(this)}exitRule(e){e.exitRetstat&&e.exitRetstat(this)}},nt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}CC_list(){return this.getTokens(n.CC)}CC(e){return this.getToken(n.CC,e)}identifier(){return this.getTypedRuleContext(f,0)}get ruleIndex(){return n.RULE_label}enterRule(e){e.enterLabel&&e.enterLabel(this)}exitRule(e){e.exitLabel&&e.exitLabel(this)}},st=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier_list(){return this.getTypedRuleContexts(f)}identifier(e){return this.getTypedRuleContext(f,e)}DOT_list(){return this.getTokens(n.DOT)}DOT(e){return this.getToken(n.DOT,e)}COL(){return this.getToken(n.COL,0)}get ruleIndex(){return n.RULE_funcname}enterRule(e){e.enterFuncname&&e.enterFuncname(this)}exitRule(e){e.exitFuncname&&e.exitFuncname(this)}},at=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}var__list(){return this.getTypedRuleContexts(_)}var_(e){return this.getTypedRuleContext(_,e)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(e){return this.getToken(n.COMMA,e)}get ruleIndex(){return n.RULE_varlist}enterRule(e){e.enterVarlist&&e.enterVarlist(this)}exitRule(e){e.exitVarlist&&e.exitVarlist(this)}},V=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier_list(){return this.getTypedRuleContexts(f)}identifier(e){return this.getTypedRuleContext(f,e)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(e){return this.getToken(n.COMMA,e)}get ruleIndex(){return n.RULE_namelist}enterRule(e){e.enterNamelist&&e.enterNamelist(this)}exitRule(e){e.exitNamelist&&e.exitNamelist(this)}},O=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}AT(){return this.getToken(n.AT,0)}var_(){return this.getTypedRuleContext(_,0)}decoratorbody(){return this.getTypedRuleContext(lt,0)}get ruleIndex(){return n.RULE_decorator}enterRule(e){e.enterDecorator&&e.enterDecorator(this)}exitRule(e){e.exitDecorator&&e.exitDecorator(this)}},lt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}OP(){return this.getToken(n.OP,0)}CP(){return this.getToken(n.CP,0)}explist(){return this.getTypedRuleContext(v,0)}get ruleIndex(){return n.RULE_decoratorbody}enterRule(e){e.enterDecoratorbody&&e.enterDecoratorbody(this)}exitRule(e){e.exitDecoratorbody&&e.exitDecoratorbody(this)}},ot=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}NEW(){return this.getToken(n.NEW,0)}functioncall(){return this.getTypedRuleContext(I,0)}get ruleIndex(){return n.RULE_newcall}enterRule(e){e.enterNewcall&&e.enterNewcall(this)}exitRule(e){e.exitNewcall&&e.exitNewcall(this)}},v=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}exp_list(){return this.getTypedRuleContexts(x)}exp(e){return this.getTypedRuleContext(x,e)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(e){return this.getToken(n.COMMA,e)}get ruleIndex(){return n.RULE_explist}enterRule(e){e.enterExplist&&e.enterExplist(this)}exitRule(e){e.exitExplist&&e.exitExplist(this)}},x=class u extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}NIL(){return this.getToken(n.NIL,0)}FALSE(){return this.getToken(n.FALSE,0)}TRUE(){return this.getToken(n.TRUE,0)}number_(){return this.getTypedRuleContext(gt,0)}string_(){return this.getTypedRuleContext(J,0)}DDD(){return this.getToken(n.DDD,0)}newcall(){return this.getTypedRuleContext(ot,0)}compactfunc(){return this.getTypedRuleContext(ut,0)}tablecomprehension(){return this.getTypedRuleContext(ht,0)}functiondef(){return this.getTypedRuleContext(W,0)}prefixexp(){return this.getTypedRuleContext(P,0)}tableconstructor(){return this.getTypedRuleContext(H,0)}exp_list(){return this.getTypedRuleContexts(u)}exp(e){return this.getTypedRuleContext(u,e)}NOT(){return this.getToken(n.NOT,0)}POUND(){return this.getToken(n.POUND,0)}MINUS(){return this.getToken(n.MINUS,0)}SQUIG(){return this.getToken(n.SQUIG,0)}isop(){return this.getTypedRuleContext(ft,0)}CARET(){return this.getToken(n.CARET,0)}STAR(){return this.getToken(n.STAR,0)}SLASH(){return this.getToken(n.SLASH,0)}PER(){return this.getToken(n.PER,0)}SS(){return this.getToken(n.SS,0)}PLUS(){return this.getToken(n.PLUS,0)}DD(){return this.getToken(n.DD,0)}LT(){return this.getToken(n.LT,0)}GT(){return this.getToken(n.GT,0)}LE(){return this.getToken(n.LE,0)}GE(){return this.getToken(n.GE,0)}SQEQ(){return this.getToken(n.SQEQ,0)}NOTEQ_ALT(){return this.getToken(n.NOTEQ_ALT,0)}EE(){return this.getToken(n.EE,0)}AND(){return this.getToken(n.AND,0)}OR(){return this.getToken(n.OR,0)}AMP(){return this.getToken(n.AMP,0)}PIPE(){return this.getToken(n.PIPE,0)}LL(){return this.getToken(n.LL,0)}GG(){return this.getToken(n.GG,0)}IN(){return this.getToken(n.IN,0)}QUESTMARK(){return this.getToken(n.QUESTMARK,0)}COL(){return this.getToken(n.COL,0)}get ruleIndex(){return n.RULE_exp}enterRule(e){e.enterExp&&e.enterExp(this)}exitRule(e){e.exitExp&&e.exitExp(this)}},$=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}exp(){return this.getTypedRuleContext(x,0)}ELSE(){return this.getToken(n.ELSE,0)}explist(){return this.getTypedRuleContext(v,0)}get ruleIndex(){return n.RULE_filterfield}enterRule(e){e.enterFilterfield&&e.enterFilterfield(this)}exitRule(e){e.exitFilterfield&&e.exitFilterfield(this)}},ct=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}filterfield_list(){return this.getTypedRuleContexts($)}filterfield(e){return this.getTypedRuleContext($,e)}fieldsep_list(){return this.getTypedRuleContexts(F)}fieldsep(e){return this.getTypedRuleContext(F,e)}get ruleIndex(){return n.RULE_filterfieldlist}enterRule(e){e.enterFilterfieldlist&&e.enterFilterfieldlist(this)}exitRule(e){e.exitFilterfieldlist&&e.exitFilterfieldlist(this)}},ht=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}OCU(){return this.getToken(n.OCU,0)}exp_list(){return this.getTypedRuleContexts(x)}exp(e){return this.getTypedRuleContext(x,e)}FOR(){return this.getToken(n.FOR,0)}namelist(){return this.getTypedRuleContext(V,0)}IN(){return this.getToken(n.IN,0)}explist(){return this.getTypedRuleContext(v,0)}CCU(){return this.getToken(n.CCU,0)}COMMA(){return this.getToken(n.COMMA,0)}IF(){return this.getToken(n.IF,0)}get ruleIndex(){return n.RULE_tablecomprehension}enterRule(e){e.enterTablecomprehension&&e.enterTablecomprehension(this)}exitRule(e){e.exitTablecomprehension&&e.exitTablecomprehension(this)}},ut=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier(){return this.getTypedRuleContext(f,0)}DO(){return this.getToken(n.DO,0)}exp(){return this.getTypedRuleContext(x,0)}OP(){return this.getToken(n.OP,0)}CP(){return this.getToken(n.CP,0)}parlist(){return this.getTypedRuleContext(w,0)}block(){return this.getTypedRuleContext(k,0)}END(){return this.getToken(n.END,0)}get ruleIndex(){return n.RULE_compactfunc}enterRule(e){e.enterCompactfunc&&e.enterCompactfunc(this)}exitRule(e){e.exitCompactfunc&&e.exitCompactfunc(this)}},S=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}OB(){return this.getToken(n.OB,0)}exp(){return this.getTypedRuleContext(x,0)}CB(){return this.getToken(n.CB,0)}DOT(){return this.getToken(n.DOT,0)}identifier(){return this.getTypedRuleContext(f,0)}QUESTMARK(){return this.getToken(n.QUESTMARK,0)}get ruleIndex(){return n.RULE_indexed_member}enterRule(e){e.enterIndexed_member&&e.enterIndexed_member(this)}exitRule(e){e.exitIndexed_member&&e.exitIndexed_member(this)}},_=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier(){return this.getTypedRuleContext(f,0)}prefixexp(){return this.getTypedRuleContext(P,0)}indexed_member(){return this.getTypedRuleContext(S,0)}get ruleIndex(){return n.RULE_var}enterRule(e){e.enterVar&&e.enterVar(this)}exitRule(e){e.exitVar&&e.exitVar(this)}},P=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier(){return this.getTypedRuleContext(f,0)}indexed_member_list(){return this.getTypedRuleContexts(S)}indexed_member(e){return this.getTypedRuleContext(S,e)}functioncall(){return this.getTypedRuleContext(I,0)}OP(){return this.getToken(n.OP,0)}exp(){return this.getTypedRuleContext(x,0)}CP(){return this.getToken(n.CP,0)}get ruleIndex(){return n.RULE_prefixexp}enterRule(e){e.enterPrefixexp&&e.enterPrefixexp(this)}exitRule(e){e.exitPrefixexp&&e.exitPrefixexp(this)}},I=class u extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier_list(){return this.getTypedRuleContexts(f)}identifier(e){return this.getTypedRuleContext(f,e)}args(){return this.getTypedRuleContext(xt,0)}indexed_member_list(){return this.getTypedRuleContexts(S)}indexed_member(e){return this.getTypedRuleContext(S,e)}OP(){return this.getToken(n.OP,0)}exp(){return this.getTypedRuleContext(x,0)}CP(){return this.getToken(n.CP,0)}COL(){return this.getToken(n.COL,0)}functioncall(){return this.getTypedRuleContext(u,0)}get ruleIndex(){return n.RULE_functioncall}enterRule(e){e.enterFunctioncall&&e.enterFunctioncall(this)}exitRule(e){e.exitFunctioncall&&e.exitFunctioncall(this)}},dt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}var_(){return this.getTypedRuleContext(_,0)}exp(){return this.getTypedRuleContext(x,0)}COMPPLUS(){return this.getToken(n.COMPPLUS,0)}COMPMINUS(){return this.getToken(n.COMPMINUS,0)}COMPSTAR(){return this.getToken(n.COMPSTAR,0)}COMPSLASH(){return this.getToken(n.COMPSLASH,0)}COMPLL(){return this.getToken(n.COMPLL,0)}COMPGG(){return this.getToken(n.COMPGG,0)}COMPAMP(){return this.getToken(n.COMPAMP,0)}COMPPIPE(){return this.getToken(n.COMPPIPE,0)}COMPCARET(){return this.getToken(n.COMPCARET,0)}get ruleIndex(){return n.RULE_compound}enterRule(e){e.enterCompound&&e.enterCompound(this)}exitRule(e){e.exitCompound&&e.exitCompound(this)}},K=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}exp(){return this.getTypedRuleContext(x,0)}identifier(){return this.getTypedRuleContext(f,0)}EQ(){return this.getToken(n.EQ,0)}get ruleIndex(){return n.RULE_argument}enterRule(e){e.enterArgument&&e.enterArgument(this)}exitRule(e){e.exitArgument&&e.exitArgument(this)}},pt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}argument_list(){return this.getTypedRuleContexts(K)}argument(e){return this.getTypedRuleContext(K,e)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(e){return this.getToken(n.COMMA,e)}get ruleIndex(){return n.RULE_argumentlist}enterRule(e){e.enterArgumentlist&&e.enterArgumentlist(this)}exitRule(e){e.exitArgumentlist&&e.exitArgumentlist(this)}},xt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}OP(){return this.getToken(n.OP,0)}CP(){return this.getToken(n.CP,0)}argumentlist(){return this.getTypedRuleContext(pt,0)}tableconstructor(){return this.getTypedRuleContext(H,0)}string_(){return this.getTypedRuleContext(J,0)}get ruleIndex(){return n.RULE_args}enterRule(e){e.enterArgs&&e.enterArgs(this)}exitRule(e){e.exitArgs&&e.exitArgs(this)}},W=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}FUNCTION(){return this.getToken(n.FUNCTION,0)}funcbody(){return this.getTypedRuleContext(z,0)}get ruleIndex(){return n.RULE_functiondef}enterRule(e){e.enterFunctiondef&&e.enterFunctiondef(this)}exitRule(e){e.exitFunctiondef&&e.exitFunctiondef(this)}},z=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}OP(){return this.getToken(n.OP,0)}parlist(){return this.getTypedRuleContext(w,0)}CP(){return this.getToken(n.CP,0)}block(){return this.getTypedRuleContext(k,0)}END(){return this.getToken(n.END,0)}get ruleIndex(){return n.RULE_funcbody}enterRule(e){e.enterFuncbody&&e.enterFuncbody(this)}exitRule(e){e.exitFuncbody&&e.exitFuncbody(this)}},bt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}CLASS(){return this.getToken(n.CLASS,0)}identifier_list(){return this.getTypedRuleContexts(f)}identifier(e){return this.getTypedRuleContext(f,e)}tableconstructor(){return this.getTypedRuleContext(H,0)}decorator_list(){return this.getTypedRuleContexts(O)}decorator(e){return this.getTypedRuleContext(O,e)}EXTENDS(){return this.getToken(n.EXTENDS,0)}get ruleIndex(){return n.RULE_class}enterRule(e){e.enterClass&&e.enterClass(this)}exitRule(e){e.exitClass&&e.exitClass(this)}},ft=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}var__list(){return this.getTypedRuleContexts(_)}var_(e){return this.getTypedRuleContext(_,e)}IS(){return this.getToken(n.IS,0)}get ruleIndex(){return n.RULE_isop}enterRule(e){e.enterIsop&&e.enterIsop(this)}exitRule(e){e.exitIsop&&e.exitIsop(this)}},X=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier(){return this.getTypedRuleContext(f,0)}NIL(){return this.getToken(n.NIL,0)}get ruleIndex(){return n.RULE_type}enterRule(e){e.enterType&&e.enterType(this)}exitRule(e){e.exitType&&e.exitType(this)}},mt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}COL(){return this.getToken(n.COL,0)}type__list(){return this.getTypedRuleContexts(X)}type_(e){return this.getTypedRuleContext(X,e)}PIPE_list(){return this.getTokens(n.PIPE)}PIPE(e){return this.getToken(n.PIPE,e)}get ruleIndex(){return n.RULE_partype}enterRule(e){e.enterPartype&&e.enterPartype(this)}exitRule(e){e.exitPartype&&e.exitPartype(this)}},Ct=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}EQ(){return this.getToken(n.EQ,0)}exp(){return this.getTypedRuleContext(x,0)}get ruleIndex(){return n.RULE_defaultvalue}enterRule(e){e.enterDefaultvalue&&e.enterDefaultvalue(this)}exitRule(e){e.exitDefaultvalue&&e.exitDefaultvalue(this)}},Y=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}identifier(){return this.getTypedRuleContext(f,0)}partype(){return this.getTypedRuleContext(mt,0)}defaultvalue(){return this.getTypedRuleContext(Ct,0)}get ruleIndex(){return n.RULE_extendedpar}enterRule(e){e.enterExtendedpar&&e.enterExtendedpar(this)}exitRule(e){e.exitExtendedpar&&e.exitExtendedpar(this)}},Tt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}extendedpar_list(){return this.getTypedRuleContexts(Y)}extendedpar(e){return this.getTypedRuleContext(Y,e)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(e){return this.getToken(n.COMMA,e)}get ruleIndex(){return n.RULE_extendedparlist}enterRule(e){e.enterExtendedparlist&&e.enterExtendedparlist(this)}exitRule(e){e.exitExtendedparlist&&e.exitExtendedparlist(this)}},w=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}extendedparlist(){return this.getTypedRuleContext(Tt,0)}COMMA(){return this.getToken(n.COMMA,0)}DDD(){return this.getToken(n.DDD,0)}get ruleIndex(){return n.RULE_parlist}enterRule(e){e.enterParlist&&e.enterParlist(this)}exitRule(e){e.exitParlist&&e.exitParlist(this)}},H=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}OCU(){return this.getToken(n.OCU,0)}CCU(){return this.getToken(n.CCU,0)}fieldlist(){return this.getTypedRuleContext(Et,0)}get ruleIndex(){return n.RULE_tableconstructor}enterRule(e){e.enterTableconstructor&&e.enterTableconstructor(this)}exitRule(e){e.exitTableconstructor&&e.exitTableconstructor(this)}},Et=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}field_list(){return this.getTypedRuleContexts(q)}field(e){return this.getTypedRuleContext(q,e)}fieldsep_list(){return this.getTypedRuleContexts(F)}fieldsep(e){return this.getTypedRuleContext(F,e)}get ruleIndex(){return n.RULE_fieldlist}enterRule(e){e.enterFieldlist&&e.enterFieldlist(this)}exitRule(e){e.exitFieldlist&&e.exitFieldlist(this)}},q=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}OB(){return this.getToken(n.OB,0)}exp_list(){return this.getTypedRuleContexts(x)}exp(e){return this.getTypedRuleContext(x,e)}CB(){return this.getToken(n.CB,0)}EQ(){return this.getToken(n.EQ,0)}functiondef(){return this.getTypedRuleContext(W,0)}decorator_list(){return this.getTypedRuleContexts(O)}decorator(e){return this.getTypedRuleContext(O,e)}identifier(){return this.getTypedRuleContext(f,0)}DOT(){return this.getToken(n.DOT,0)}get ruleIndex(){return n.RULE_field}enterRule(e){e.enterField&&e.enterField(this)}exitRule(e){e.exitField&&e.exitField(this)}},F=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}COMMA(){return this.getToken(n.COMMA,0)}SEMI(){return this.getToken(n.SEMI,0)}get ruleIndex(){return n.RULE_fieldsep}enterRule(e){e.enterFieldsep&&e.enterFieldsep(this)}exitRule(e){e.exitFieldsep&&e.exitFieldsep(this)}},f=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}NAME(){return this.getToken(n.NAME,0)}NEW(){return this.getToken(n.NEW,0)}CLASS(){return this.getToken(n.CLASS,0)}EXTENDS(){return this.getToken(n.EXTENDS,0)}USING(){return this.getToken(n.USING,0)}FILTER(){return this.getToken(n.FILTER,0)}TRY(){return this.getToken(n.TRY,0)}CATCH(){return this.getToken(n.CATCH,0)}DEFER(){return this.getToken(n.DEFER,0)}IS(){return this.getToken(n.IS,0)}get ruleIndex(){return n.RULE_identifier}enterRule(e){e.enterIdentifier&&e.enterIdentifier(this)}exitRule(e){e.exitIdentifier&&e.exitIdentifier(this)}},gt=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}INT_list(){return this.getTokens(n.INT)}INT(e){return this.getToken(n.INT,e)}HEX(){return this.getToken(n.HEX,0)}FLOAT(){return this.getToken(n.FLOAT,0)}HEX_FLOAT(){return this.getToken(n.HEX_FLOAT,0)}get ruleIndex(){return n.RULE_number}enterRule(e){e.enterNumber&&e.enterNumber(this)}exitRule(e){e.exitNumber&&e.exitNumber(this)}},J=class extends a.ParserRuleContext{constructor(e,t,i){super(t,i),this.parser=e}NORMALSTRING(){return this.getToken(n.NORMALSTRING,0)}CHARSTRING(){return this.getToken(n.CHARSTRING,0)}JENKINSHASHSTRING(){return this.getToken(n.JENKINSHASHSTRING,0)}LONGSTRING(){return this.getToken(n.LONGSTRING,0)}get ruleIndex(){return n.RULE_string}enterRule(e){e.enterString&&e.enterString(this)}exitRule(e){e.exitString&&e.exitString(this)}};var St=require("antlr4"),Z=class extends St.ParseTreeListener{};var Ft=require("antlr4");var Lt=class u{constructor(){this.code="";this.lastNode=null}static getTokenFromNode(e,t=!0){return e instanceof Ft.TerminalNode?e.symbol:t?e.start:e.stop}add(e,t,i){if(typeof e=="string"){this.code+=e;return}let s="";if(t){let c=t(e);if(!c)return;s+=c}else Array.isArray(e)?e.forEach(c=>{s+=c.getText()}):s+=e.getText();if(s.length!=0){if(!i)if(Array.isArray(e)){if(e.length==0)return;this.lastNode&&this.addSpaces(this.lastNode,e[0]),this.lastNode=e[e.length-1]}else this.lastNode&&this.addSpaces(this.lastNode,e),this.lastNode=e;return this.code+=s,!0}}addSpaces(e,t){let i=u.getTokenFromNode(e,!1),s=u.getTokenFromNode(t,!0),c=y.getSpacesBetweenTokens(i,s);this.code+=c}remove(e){this.code=this.code.slice(0,-e)}get(){return this.code}},U=Lt;var Pt;(c=>{function u(h,o,d=","){let b=new U;return h.forEach((m,T)=>{T>0&&d!=null&&b.add(d),b.add(m,o)||b.remove(d.length)}),b.get()}c.convertNodes=u;function e(h,o){let d=h.stop+1,b=o.start-1,m=h.getInputStream().getText(d,b);return m=m.replace(/\S/g,""),m}c.getSpacesBetweenTokens=e;function t(h,o=0){let d=o,b=h.start-1,m=h.getInputStream().getText(d,b);return m=m.replace(/\S/g,""),m}c.getSpacesUntilToken=t;function i(h,o){h.type=o,h.text=R.literalNames[o],h.text=h.text.substring(1,h.text.length-1)}c.convertToken=i;function s(h=1){var o;try{throw new Error}catch(d){let m=d.stack.split(` 2 | `)[h+1].match(/at (?:\w+\.)?(\w+)/);o=m?m[1]:"unknown"}return o}c.getCallerName=s})(Pt||={});var y=Pt;var Kt=G(Ht()),Wt=G(Dt()),zt=G(Gt()),Xt=G(jt()),Yt=G(Vt());var $t={string:!0,number:!0,boolean:!0,table:!0,function:!0,userdata:!0,thread:!0,nil:!0,vector2:!0,vector3:!0,vector4:!0,quat:!0},qt;(m=>{function u(T,A){let C=A.getText(),g=T.join(" | "),E=T.every(D=>$t[D]),It=T.map(D=>$t[D]?`type(${C}) ~= "${D}"`:`not _leap_internal_is_operator(${C}, ${D})`),Zt=E?It.join(" and "):`_type(${C}) ~= "table" and ${It.join(" and ")}`,te=E?`${C}: must be (${g}) but got '..type(${C})..'`:`${C}: must be (${g}) or a derived class but got '..type(${C})..'`;return`if ${Zt} then error('${te}', 2) end;`}m.typeCheck=u;function e(T,A){let C="";return C+=`if ${T.getText()} == nil then `,C+=`${T.getText()} = ${A}`,C+=" end;",C}m.defaultValue=e;function t(T,A,C){let g="";return g+=`;${T} = ${A}(${T}`,C&&(g+=`, ${C}`),g+=")",g+=` or ${T};`,g}m.decorator=t;function i(T,A,C,g){let E="";return E+=`table.insert(${T}.__prototype._leap_internal_decorators, {name = "${A}", decoratorName = "${C}", args = {${g||""}}});`,E}m.classDecorator=i;function s(T,A,C,g){let E=new U;return E.add("leap.registerfunc(function"),A(E),E.add(", {"),E.add("args={"),C(E),E.add("},"),T&&T.length>0&&E.add(`name=${T},`),g()&&E.add("has_return=true,"),E.add("})"),E.get()}m.functionIntrospection=s;function c(){return Kt.default}m.alwaysInjected=c;function h(){return Wt.default}m.classBuilder=h;function o(){return zt.default}m.inOperator=o;function d(){return Xt.default}m.usingOperator=d;function b(){return Yt.default}m.kargs=b})(qt||={});var L=qt;var yt=class{constructor(){this.injects=[];this.features=[]}inNext(e,t){this.injects.push({func:e,code:t})}cleanInjects(e){this.injects=this.injects.filter(t=>t.func!==e)}injectIfNeeded(e,t){t=t||y.getCallerName(2);for(let i=0;i{this.firstStat=!0;let i={code:this.enterStart_(t)};return this.injecter.injectGlobalFeatures(i),i.code};this.enterStart_=t=>this.enterChunk(t.chunk());this.enterChunk=t=>this.enterBlock(t.block());this.enterBlock=t=>{let i=new p(this),s=this.getFunctionName();return t.stat_list().forEach(c=>{this.firstStat&&(c.start.start>0&&(i.code+=y.getSpacesUntilToken(c.start)),this.firstStat=!1),i.add(c,this.enterStat)}),t.retstat()&&(s&&t.retstat().RETURN()&&t.retstat().explist()&&(this.functionReturn=!0),i.add(t.retstat(),this.enterRetstat)),i.get()};this.enterStat=t=>{if(t.SEMI())return";";if(t.varlist())return this.convertAssignment(t);if(t.compound())return this.enterCompound(t.compound());if(t.functioncall())return this.enterFunctioncall(t.functioncall());if(t.label())return this.enterLabel(t.label());if(t.BREAK())return"break";if(t.GOTO())return this.convertGoto(t);if(t.WHILE())return this.convertWhile(t);if(t.REPEAT())return this.convertRepeat(t);if(t.IF())return this.convertIf(t);if(t.FOR())return t.IN()?this.convertGenericFor(t):this.convertNumericFor(t);if(t.DO())return this.convertDo(t);if(t.DEFER())return this.convertDefer(t);if(t.TRY())return this.convertTry(t);if(t.THROW())return this.convertThrow(t);if(t.class_())return this.enterClass(t.class_());if(t.FUNCTION())return t.LOCAL()?this.convertLocalFunction(t):this.convertFunction(t);if(t.FILTER())return this.convertFilter(t);if(t.USING())return this.convertUsing(t);if(t.LOCAL())return this.convertLocal(t)};this.enterAttnamelist=t=>{let i=new p;return t.identifier_list().forEach((s,c)=>{c>0&&i.add(","),i.add(s),i.add(t.attrib(c),this.enterAttrib)}),i.get()};this.enterAttrib=t=>t.identifier()?t.LT()+t.identifier().getText()+t.GT():"";this.enterRetstat=t=>{let i=new p;return t.RETURN()?(i.add(t.RETURN()),t.explist()&&i.add(t.explist(),this.enterExplist)):t.BREAK()?i.add(t.BREAK()):t.CONTINUE()&&i.add(this.convertContinue(t.CONTINUE())),t.SEMI()&&i.add(t.SEMI()),i.get()};this.enterLabel=t=>"::"+t.identifier().getText()+"::";this.enterFuncname=t=>{let i=new p,s=t.identifier_list(),c=t.DOT_list();i.add(t.identifier(0));for(let h=0;hy.convertNodes(t.var__list(),this.enterVar);this.enterNamelist=t=>{let i=new p;return i.add(t.identifier_list(),y.convertNodes),i.get()};this.enterDecoratorbody=t=>{let i=new p;return t.explist()&&i.add(t.explist(),this.enterExplist),i.get()};this.enterNewcall=t=>{let i=new p;return i.add(t.functioncall(),this.enterFunctioncall),i.get()};this.enterExplist=t=>y.convertNodes(t.exp_list(),this.enterExp);this.enterExp=t=>{if(t.NIL())return"nil";if(t.FALSE())return"false";if(t.TRUE())return"true";if(t.number_())return this.enterNumber(t.number_());if(t.string_())return this.enterString(t.string_());if(t.DDD())return"...";if(t.newcall())return this.enterNewcall(t.newcall());if(t.QUESTMARK())return this.convertTernary(t);if(t.isop())return this.enterIsop(t.isop());if(t.functiondef()){if(this.assignment)return this.enterFunctiondef(t.functiondef());{let i=this.addFunctionName("",!0),s=this.enterFunctiondef(t.functiondef());return this.removeFunctionName(i),s}}else{if(t.prefixexp())return this.enterPrefixexp(t.prefixexp());if(t.compactfunc())return this.enterCompactfunc(t.compactfunc());if(t.tablecomprehension())return this.enterTablecomprehension(t.tablecomprehension());if(t.tableconstructor())return this.enterTableconstructor(t.tableconstructor());if(t.exp(0))return this.handleOperators(t)}};this.enterFilterfield=t=>{let i=new p;return i.add("assert("),i.add(t.exp(),this.enterExp),t.ELSE()&&(i.add(", "),i.add(t.explist(),this.enterExplist)),i.add(")"),i.get()};this.enterFilterfieldlist=t=>{let i=new p,s=t.filterfield_list(),c=t.fieldsep_list();i.add(s[0],this.enterFilterfield);for(let h=1;h{let i=new p,s=t.exp_list();return i.add("(function()local _t = {};"),i.add(t.FOR()),i.add(t.namelist(),this.enterNamelist),i.add(t.IN()),i.add(t.explist(),this.enterExplist),i.add(" do "),t.IF()&&(i.add(t.IF()),t.COMMA()?i.add(s[2],this.enterExp):i.add(s[1],this.enterExp),i.add(" then ")),t.COMMA()?(i.add("_t["),i.add(s[0],this.enterExp),i.add("]"),i.add(" = "),i.add(s[1],this.enterExp)):(i.add("table.insert(_t, "),i.add(s[0],this.enterExp),i.add(")")),i.add(";"),t.IF()&&i.add("end;"),i.add("end;"),i.add("return _t;"),i.add("end)()"),i.get()};this.enterCompactfunc=t=>{let i=new p;return i.add("function"),t.OP()?i.add(t.OP()):i.add("("),t.parlist()?i.add(t.parlist(),this.enterParlist):t.identifier()&&i.add(t.identifier(),this.enterIdentifier),t.OP()?i.add(t.CP()):i.add(")"),t.block()?(i.add(t.block(),this.enterBlock),i.add(t.END())):t.exp()&&(i.add("return "),i.add(t.exp(),this.enterExp),i.add(";"),i.add("end")),i.get()};this.enterIndexed_member=t=>{if(t.OB())return t.OB()+this.enterExp(t.exp())+t.CB();if(t.DOT())return t.QUESTMARK()?t.QUESTMARK().getText()+t.DOT().getText()+t.identifier().getText():t.DOT()+t.identifier().getText()};this.enterVar=t=>{if(t.identifier())return t.identifier().getText();if(t.indexed_member())return this.enterPrefixexp(t.prefixexp())+this.enterIndexed_member(t.indexed_member())};this.enterPrefixexp=t=>{let i=new p;return t.functioncall()?i.add(t.functioncall(),this.enterFunctioncall):t.exp()?(i.add("("),i.add(t.exp(),this.enterExp),i.add(")")):i.add(t.identifier(0)),i.add(t.indexed_member_list(),s=>y.convertNodes(s,this.enterIndexed_member,null)),i.get()};this.enterFunctioncall=t=>{let i=new p;if(i.add(t,this.enterPrefixexp),t.COL()){i.add(t.COL());let c=t.identifier_list();i.add(c[c.length-1])}let s=this.addFunctionName(i.get());return i.add(t.args(),this.enterArgs),this.removeFunctionName(s),i.get()};this.enterCompound=t=>{let i=new p,s=t.getChild(1);return i.add(t.var_(),this.enterVar),i.add(s),i.add(t.exp(),this.enterExp),i.get()};this.enterArgument=(t,i)=>{let s=new p,c=t.identifier();return c!=null&&t.exp()?(this.injecter.enableGlobalFeature("kargs"),this.kargsTable[i]+=`${this.enterIdentifier(c)} = ${this.enterExp(t.exp())},`,"nil"):(s.add(t.exp(),this.enterExp),s.get())};this.enterArgumentlist=(t,i)=>{let s=c=>this.enterArgument(c,i);return y.convertNodes(t.argument_list(),s)};this.enterArgs=t=>{if(t.string_())return this.enterString(t.string_());if(t.tableconstructor())return this.enterTableconstructor(t.tableconstructor());if(t.OP()){let i=new p,s=t.argumentlist();if(i.add(t.OP()),s){let c=s.start.start;this.kargsTable[c]="";let h=this.enterArgumentlist(s,c);i.addSpaces(i.lastNode,s),i.lastNode=s,this.kargsTable[c].length>0&&(i.add(`__leap_call_kargs(${this.getFunctionName(null,!0)}, {${this.kargsTable[c]}}`),h.length>0&&i.add(",")),i.add(h),this.kargsTable[c].length>0&&i.add(")"),delete this.kargsTable[c]}return i.add(t.CP()),i.get()}};this.enterFunctiondef=t=>{let i=new p,s=this.getFunctionName();if(!s)i.add(t.FUNCTION()),i.add(t.funcbody(),this.enterFuncbody);else{let c;typeof s=="string"?c=s:c=s[s.length-1];let h=m=>{m.add(t.funcbody(),this.enterFuncbody),Array.isArray(s)&&s.shift()},o=m=>{this.injecter.injectIfNeeded(m,"enterFunctiondef")},d=()=>{let m=this.functionReturn;return this.functionReturn&&(this.functionReturn=!1),m},b=L.functionIntrospection(c,h,o,d);i.add(b)}return i.get()};this.enterFuncbody=t=>{let i=new p;i.add(t.OP()),t.parlist()&&i.add(t.parlist(),this.enterParlist),i.add(t.CP()),this.injecter.injectIfNeeded(i);let s=this.insideClass;return s&&(this.insideClass=null),this.currentFunctionParList=t.parlist(),i.add(t.block(),this.enterBlock),i.add(t.END()),this.currentFunctionParList=null,s&&(this.insideClass=s),i.get()};this.enterClass=t=>{let i=new p,s=t.decorator_list(),c=this.enterIdentifier(t.identifier(0));return this.convertDecoratorList(s,i,c,"enterClass"),this.classBuildInjected=!0,this.injecter.enableGlobalFeature("classBuilder"),i.add("_leap_internal_classBuilder("),i.add('"'),i.add(t.identifier(0),this.enterIdentifier,!0),i.add('"'),i.add(","),this.insideClass=c,i.add(t.tableconstructor(),this.enterTableconstructor),this.insideClass=null,t.EXTENDS()?(i.add(", "),i.add(t.identifier(1),this.enterIdentifier)):i.add(", {}"),i.add(")"),this.injecter.injectIfNeeded(i),i.get()};this.enterIsop=t=>{let i=new p;return i.add("_leap_internal_is_operator("),i.add(t.var_(0),this.enterVar),i.add(","),i.add(t.var_(1),this.enterVar),i.add(")"),i.get()};this.enterType=t=>{if(t.identifier())return this.enterIdentifier(t.identifier());if(t.NIL())return t.NIL().getText()};this.enterExtendedpar=t=>{let i=new p,s="";i.add(t.identifier(),this.enterIdentifier);let h=t.partype().type__list();if(t.defaultvalue().getChildCount()>0&&(s+=L.defaultValue(t.identifier(),this.enterDefaultvalue(t.defaultvalue()))),h.length>0){let o=h.map(d=>this.enterType(d));s+=L.typeCheck(o,t.identifier())}return s!=""&&this.injecter.inNext("enterFuncbody",s),i.get()};this.enterExtendedparlist=t=>{let i=new p;this.insideClass&&i.add("self, ");let s=t.extendedpar_list();s.forEach((h,o)=>{o>0&&i.add(","),i.add(h,this.enterExtendedpar)});let c=s.map(h=>'{name = "'+this.enterIdentifier(h.identifier())+'"},');return this.injecter.cleanInjects("enterFunctiondef"),this.injecter.inNext("enterFunctiondef",c.join("")),i.get()};this.enterDefaultvalue=t=>this.enterExp(t.exp());this.enterParlist=t=>{let i=new p;return t.extendedparlist()?(i.add(t.extendedparlist(),this.enterExtendedparlist),t.COMMA()&&t.DDD()&&(i.add(t.COMMA()),i.add(t.DDD()))):t.DDD()?i.add(t.DDD()):this.insideClass&&i.add("self"),i.get()};this.enterTableconstructor=t=>{let i=new p;return i.add(t.OCU()),t.fieldlist()&&i.add(t.fieldlist(),this.enterFieldlist),i.add(t.CCU()),i.get()};this.enterFieldlist=t=>{let i=new p,s=t.field_list(),c=t.fieldsep_list();i.add(s[0],this.enterField);for(let h=1;h{let i=new p,s=t.decorator_list();if(s.length>0){let c="",h=null,o=t.functiondef();i.addSpaces(t.decorator_list()[0],o),t.OB()?(c=this.enterExp(t.exp(0)),i.add(t.OB()),i.add(t.exp(0),this.enterExp),i.add(t.CB()),i.add(t.EQ())):t.identifier()&&(c=this.enterIdentifier(t.identifier()),i.add(t.identifier()),i.add(t.EQ())),o&&(h=this.addFunctionName(c)),s.forEach(d=>{let b=this.enterVar(d.var_()),m=this.enterDecoratorbody(d.decoratorbody());this.injecter.inNext("enterClass",L.classDecorator(this.insideClass,c,b,m))}),i.add(o,this.enterFunctiondef),o&&h&&this.removeFunctionName(h)}else if(t.OB()){let c=t.exp(1).functiondef(),h=null;c&&(h=this.addFunctionName(this.enterExp(t.exp(0)))),i.add(t.OB()),i.add(t.exp(0),this.enterExp),i.add(t.CB()),this.assignment=!0,i.add(t.EQ()),i.add(t.exp(1),this.enterExp),this.assignment=!1,c&&h&&this.removeFunctionName(h)}else if(t.DOT())i.add(t.DOT()),i.add(t.identifier());else if(t.identifier()){let c=t.exp(0).functiondef(),h=null;c&&(h=this.addFunctionName(this.enterIdentifier(t.identifier()))),i.add(t.identifier()),this.assignment=!0,i.add(t.EQ()),i.add(t.exp(0),this.enterExp),this.assignment=!1,c&&h&&this.removeFunctionName(h)}else i.add(t.exp(0),this.enterExp);return i.get()};this.enterFieldsep=t=>{if(t.COMMA())return t.COMMA().getText();if(t.SEMI())return t.SEMI().getText()};this.enterIdentifier=t=>t.getText();this.enterNumber=t=>{if(t.INT_list().length>0){let i="";return t.INT_list().map(s=>{i+=s.getText().replace("_","")}),i}else return t.getText()};this.enterString=t=>{let i=t.getText(),s=t.NORMALSTRING(),c=t.CHARSTRING();if(s||c){let h=/\$\{([^}]*)\}/g,o=i.matchAll(h),d=c?"'":'"';for(let b of o)i=i.replace(b[0],`${d}..(${b[1]})..${d}`)}return i};this.handleOperators=t=>{let i=new p,s=t.exp_list();if(s.length==1)i.add(t.getChild(0)),i.add(s[0],this.enterExp);else{let c=t.getChild(1);c.symbol.type==R.NOT&&(i.add("not "),c=t.getChild(2)),c.symbol.type==R.IN?(this.injecter.enableGlobalFeature("inOperator"),i.add("_leap_internal_in_operator("),i.add(s[0],this.enterExp),i.add(","),i.add(s[1],this.enterExp),i.add(")")):(t.NOTEQ_ALT()&&y.convertToken(c.symbol,R.SQEQ),i.add(s[0],this.enterExp),i.add(c),i.add(s[1],this.enterExp))}return i.get()};this.convertGoto=t=>"goto "+t.identifier().getText();this.convertDecoratorList=(t,i,s,c)=>{if(t){let h=o=>this.convertDecorator(s,o,c);t.forEach(o=>{i.add(o,h)})}};this.convertDo=t=>{let i=new p;return i.add(t.DO()),i.add(t.block(0),this.enterBlock),i.add(t.END()),i.get()};this.convertDefer=t=>{let i=new p;return i.add(t.DEFER()),i.add(t.block(0),this.enterBlock),i.add(t.END()),i.get()};this.convertTry=t=>{let i=new p;return i.add("local _leap_internal_status, _leap_internal_result = pcall(function()"),this.insideTryCatch=!0,i.addSpaces(t.TRY(),t.block(0)),i.add(t.block(0),this.enterBlock),i.addSpaces(t.block(0),t.CATCH()),i.lastNode=t.CATCH(),this.insideTryCatch=!1,i.add("end) if not _leap_internal_status then "),t.identifier()&&(i.add("local "),i.add(t.identifier(),this.enterIdentifier),i.add(" = _leap_internal_result;")),i.add(t.block(1),this.enterBlock),i.addSpaces(t.block(1),t.END()),i.add(" elseif _leap_internal_result ~= nil then return _leap_internal_result end;"),i.get()};this.convertThrow=t=>this.insideTryCatch?`error(${this.enterExp(t.exp(0))})`:`error(tostring(${this.enterExp(t.exp(0))}))`;this.convertTernary=t=>{let i=new p;return i.add("(function()"),i.add("if "),i.add(t.exp(0),this.enterExp),i.add(" then "),i.add("return"),i.add(t.exp(1),this.enterExp),i.add(" else "),i.add("return"),i.add(t.exp(2),this.enterExp),i.add(" end;"),i.add("end"),i.add(")()"),i.get()};this.convertWhile=t=>{let i=new p;return i.add(t.WHILE()),i.add(t.exp(0),this.enterExp),i.add(t.DO()),i.add(t.block(0),this.enterBlock),i.add(t.END()),i.get()};this.convertRepeat=t=>{let i=new p;return i.add(t.REPEAT()),i.add(t.block(0),this.enterBlock),i.add(t.UNTIL()),i.add(t.exp(0),this.enterExp),i.get()};this.convertIf=t=>{let i=new p,s=t.block_list();return i.add(t.IF()),i.add(t.exp(0),this.enterExp),i.add(t.THEN(0)),i.add(s[0],this.enterBlock),t.ELSEIF_list()&&t.ELSEIF_list().forEach((c,h)=>{i.add(c),i.add(t.exp(h+1),this.enterExp),i.add(t.THEN(h+1)),i.add(s[h+1],this.enterBlock)}),t.ELSE()&&(i.add(t.ELSE()),i.add(s[s.length-1],this.enterBlock)),i.add(t.END()),i.get()};this.convertNumericFor=t=>{let i=new p,s=t.exp_list();return this.forDepth++,i.add(t.FOR()),i.add(t.identifier()),i.add(t.EQ()),i.add(s[0],this.enterExp),i.add(t.COMMA(0)),i.add(s[1],this.enterExp),t.COMMA(1)&&(i.add(t.COMMA(1)),i.add(s[2])),i.add(t.DO()),i.add(t.block(0),this.enterBlock),this.injecter.injectIfNeeded(i,"convertFor_"+this.forDepth),i.add(t.END()),this.forDepth--,i.get()};this.convertGenericFor=t=>{let i=new p;return this.forDepth++,i.add(t.FOR()),i.add(t.namelist(),this.enterNamelist),i.add(t.IN()),i.add(t.explist(),this.enterExplist),i.add(t.DO()),i.add(t.block(0),this.enterBlock),this.injecter.injectIfNeeded(i,"convertFor_"+this.forDepth),i.add(t.END()),this.forDepth--,i.get()};this.convertDecorator=(t,i,s)=>{let c=this.enterVar(i.var_()),h=this.enterDecoratorbody(i.decoratorbody());return this.injecter.inNext(s,L.decorator(t,c,h))," "};this.convertFunction=t=>{let i=new p,s=t.decorator_list(),c=this.enterFuncname(t.funcname());this.convertDecoratorList(s,i,c,"convertFunction"),t.funcname().COL()?(this.insideClass="true",i.add(t.funcname(),b=>this.enterFuncname(b).replace(":",".")),i.add(" = ")):(i.add(t.funcname(),this.enterFuncname),i.add(" = "));let h=t.funcname().identifier_list(),o=this.enterIdentifier(h[h.length-1]),d=this.addFunctionName(o);return i.add(this.enterFunctiondef(t)),this.removeFunctionName(d),this.insideClass=="true"&&(this.insideClass=null),this.injecter.injectIfNeeded(i),i.get()};this.convertFilter=t=>{let i=new p,s=t.filterfieldlist(),c=s.filterfield_list();return i.add(t.funcname(),this.enterFuncname),i.add(" = "),i.add("[["),i.addSpaces(t.funcname(),c.at(0)),i.add("return function("),t.parlist()?(i.add(t.parlist(),this.enterParlist),i.add(", ...) ")):i.add("...) "),i.add(this.enterFilterfieldlist(s)),i.addSpaces(c.at(-1),t.END()),i.add("end]]"),i.get()};this.convertUsing=t=>{let i=new p;this.injecter.enableGlobalFeature("usingOperator"),i.add('_leap_internal_using_operator("'),i.add(t.identifier(),this.enterIdentifier),i.add('"'),i.add(","),i.add("{"),i.add("self = self,"),this.currentFunctionParList.DDD()&&i.add("ddd = {...},");let s=this.currentFunctionParList.extendedparlist();if(s){let c=s.extendedpar_list();c.forEach((h,o)=>{i.add(this.enterIdentifier(h.identifier())),i.add(" = "),i.add(this.enterIdentifier(h.identifier())),o!=c.length-1&&i.add(",")})}return i.add("}"),t.explist()&&(i.add(","),i.add(t.explist(),this.enterExplist)),t.CP()?i.add(t.CP()):i.add(")"),i.get()};this.convertLocalFunction=t=>{let i=new p;i.add(t.LOCAL()),i.add(t.identifier(),this.enterIdentifier),i.add(" = ");let s=this.addFunctionName(this.enterIdentifier(t.identifier()));return i.add(this.enterFunctiondef(t)),this.removeFunctionName(s),i.get()};this.convertLocal=t=>{let i=new p,s=t.explist()?.exp_list(),c=t.attnamelist().identifier_list(),h=s?this.addFunctionName(this.getFunctionNames(s,c)):null;return i.add(t.LOCAL()),i.add(t.attnamelist(),this.enterAttnamelist),t.prefixexp()?(i.add(t.IN()),i.add(t.prefixexp(),this.enterPrefixexp)):t.EQ()&&(i.add(t.EQ()),this.assignment=!0,i.add(t.explist(),this.enterExplist),this.assignment=!1),h&&this.removeFunctionName(h),i.get()};this.convertContinue=t=>(this.injecter.inNext(`convertFor_${this.forDepth}`,` ::continue_${this.forDepth}::`),`goto continue_${this.forDepth}`);this.convertAssignment=t=>{let i=t.explist().exp_list(),s=t.varlist().var__list(),c=this.addFunctionName(this.getFunctionNames(i,s)),h=this.enterVarlist(t.varlist()),o=t.EQ().getText();this.assignment=!0;let d=this.enterExplist(t.explist());return this.assignment=!1,this.removeFunctionName(c),`${h} ${o} ${d}`};this.getFunctionNames=(t,i)=>{let s=[];for(let[c,h]of Object.entries(t)){let o=i[c];if(h.functiondef()&&o){let d=o.indexed_member&&o.indexed_member(),b;o instanceof f?b=this.enterIdentifier(o):o instanceof _&&(d?d.identifier()?b=this.enterIdentifier(d.identifier()):b=this.enterExp(d.exp()):b=this.enterIdentifier(o.identifier())),d?.exp()||(b='"'+b+'"'),s.push(b)}}return s};this.addFunctionName=(t,i=!1)=>(t=i||Array.isArray(t)?t:'"'+t+'"',this.functionsName.push(t)-1);this.removeFunctionName=t=>{this.functionsName.splice(t||this.functionsName.length-1,1)};this.getFunctionName=(t,i=!1)=>{let s=this.functionsName[t||this.functionsName.length-1];if(s?.length>0){if(i){if(typeof s=="string")return s.replace(/"/g,"");throw new Error("getFunctioName: raw is set to true, but the function name is not a string")}return s}};this.injecter=new yt,this.kargsTable={},this.functionsName=[]}};var Jt=require("antlr4"),_t=class extends Jt.ErrorListener{constructor(){super(),this.errors=[]}syntaxError(e,t,i,s,c,h){let o={line:i,column:s,message:c,offendingSymbol:t};this.errors.push(o)}getErrors(){return this.errors}};var Nt=class extends Error{constructor(e){super(),this.errors=e}};function oe(u){let e=new At.CharStream(u),t=new R(e),i=new At.CommonTokenStream(t),s=new n(i),c=new _t;s.removeErrorListeners(),s.addErrorListener(c);let h=s.start_(),o="";if(c.getErrors().length>0)throw new Nt(c.getErrors());try{o=new Rt().convert(h)}catch(d){throw Error("Internal error: "+d.stack)}return o}0&&(module.exports={preprocessCode}); 3 | //# sourceMappingURL=index.js.map 4 | -------------------------------------------------------------------------------- /functions/manifest.js: -------------------------------------------------------------------------------- 1 | const glob = require("glob") 2 | const path = require('path'); 3 | 4 | function GetAllScripts(resourceName) { 5 | let files = [] 6 | 7 | files = GetAllResourceMetadata(resourceName, "client_script") 8 | files.push(...GetAllResourceMetadata(resourceName, "server_script")) 9 | files.push(...GetAllResourceMetadata(resourceName, "shared_script")) 10 | files.push(...GetAllResourceMetadata(resourceName, "files")) 11 | 12 | for (let index in files) { 13 | let file = files[index] 14 | 15 | if (file.includes("build/")) { 16 | files[index] = file.replace(/build\//, "") 17 | } 18 | } 19 | 20 | return files 21 | } 22 | 23 | function GetIgnoredFiles(resourceName) { 24 | let files = GetAllResourceMetadata(resourceName, "leap_ignore") 25 | 26 | return files 27 | } 28 | 29 | function GetAllResourceMetadata(resourceName, key) { 30 | let metadataNum = GetNumResourceMetadata(resourceName, key) 31 | let result = [] 32 | 33 | for (let i=0; i < metadataNum; i++) { 34 | let metadata = GetResourceMetadata(resourceName, key, i) 35 | 36 | if (!metadata.includes("--") && (metadata.includes(".lua") || metadata.includes(".*"))) { 37 | if (metadata.includes("@")) { 38 | continue 39 | } 40 | 41 | result.push(metadata) 42 | } 43 | } 44 | 45 | return result 46 | } 47 | 48 | function ResolveFile(resourcePath, file) { 49 | if (file.includes("@")) { 50 | let regex = /@(.*?)\/(.*)/g 51 | let match = regex.exec(file) 52 | let resourceName = match[1] 53 | 54 | file = match[2] 55 | resourcePath = GetResourcePath(resourceName) 56 | } 57 | 58 | /* Check if the file being resolved uses globbing. */ 59 | if (file.includes("*")) { 60 | if (file.includes("**")) { 61 | /* Replace the FiveM recursive globbing pattern with the Node recursive globbing pattern. */ 62 | file = file.replace("**", "**/*") 63 | } 64 | 65 | let files = glob.sync(file, {cwd: resourcePath, absolute: true, windowsPathsNoEscape: true}) 66 | 67 | files = files.filter(file => { 68 | if (path.extname(file) == ".lua") { 69 | return file 70 | } 71 | }) 72 | 73 | return files 74 | } else { 75 | resourcePath = resourcePath.replace(/(\/\/|\/)/g, "\\") 76 | file = file.replaceAll("/", "\\") 77 | 78 | return resourcePath + "\\" + file 79 | } 80 | } 81 | 82 | module.exports = {GetAllScripts, GetIgnoredFiles, ResolveFile} -------------------------------------------------------------------------------- /functions/preprocessResource.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs") 2 | const path = require("path"); 3 | 4 | const {GetAllScripts, GetIgnoredFiles, ResolveFile} = require("./manifest") 5 | const {canFileBePreprocessed, absToRelative, loadCache, hasCachedFileBeenModified, getResourceProcessableFiles, relativeToAbs, cleanDeletedFilesFromBuild} = require("./utils") 6 | const {preprocessCode} = require("./leap"); 7 | 8 | const replaceLast = (str, pattern, replacement) => { 9 | const last = str.lastIndexOf(pattern); 10 | 11 | if (last !== -1) { 12 | return str.slice(0, last) + replacement + str.slice(last + pattern.length); 13 | } else { 14 | return str; 15 | } 16 | }; 17 | 18 | class PreProcessor { 19 | files = {} 20 | resourceName = "" 21 | 22 | constructor(resourceName) { 23 | this.resourceName = resourceName 24 | this.verbose = GetConvar("leap_verbose", "false") == "true" 25 | } 26 | 27 | getFilesToBuild() { 28 | const files = getResourceProcessableFiles(this.resourceName) 29 | const cache = loadCache(this.resourceName) 30 | const filesToBuild = [] 31 | 32 | files.map(file => { 33 | const cachedFile = cache.find(cacheFile => cacheFile.path == absToRelative(file, this.resourceName)) 34 | 35 | if (!cachedFile) { 36 | filesToBuild.push(file) 37 | return 38 | } 39 | 40 | if (hasCachedFileBeenModified(cachedFile, this.resourceName)) { 41 | filesToBuild.push(file) 42 | } 43 | }) 44 | 45 | return filesToBuild 46 | } 47 | 48 | async run(ignoreCache) { 49 | let files = ignoreCache ? getResourceProcessableFiles(this.resourceName) : this.getFilesToBuild() 50 | 51 | if (cleanDeletedFilesFromBuild(this.resourceName)) { 52 | await this.writeCache() 53 | 54 | if (files.length == 0) { 55 | return 56 | } 57 | } 58 | 59 | 60 | if (files.length == 0) { 61 | throw new Error(`No files provided by the resource (probably a typo), check the manifest of ${this.resourceName}`) 62 | } 63 | 64 | let promises = [] 65 | let start = Date.now() 66 | 67 | // Preprocess files content 68 | for (let filePath of files) { 69 | let promise = null 70 | 71 | if (canFileBePreprocessed(filePath)) { 72 | promise = new Promise((resolve, reject) => { 73 | try { 74 | let file = fs.readFileSync(filePath, "utf-8") 75 | let preprocessed = preprocessCode(file) 76 | 77 | let filePathBuild = replaceLast(filePath, this.resourceName, path.join(this.resourceName, "build/")) 78 | 79 | fs.mkdirSync(path.dirname(filePathBuild), {recursive: true}) 80 | fs.writeFileSync(filePathBuild, preprocessed) 81 | 82 | resolve() 83 | } catch (e) { 84 | if (e.errors) { 85 | for (let error of e.errors) { 86 | const relpath = absToRelative(filePath, this.resourceName) 87 | console.log(`^1Error parsing script @${this.resourceName}${relpath}:${error.line}: ${error.message}`) 88 | } 89 | } else { 90 | console.error(e.message) 91 | } 92 | reject(e) 93 | } 94 | }) 95 | } else { 96 | // Copy file as it is 97 | promise = new Promise((resolve, reject) => { 98 | let file = fs.readFileSync(filePath, "utf-8") 99 | 100 | let filePathBuild = replaceLast(filePath, this.resourceName, path.join(this.resourceName, "build/")) 101 | 102 | fs.mkdirSync(path.dirname(filePathBuild), {recursive: true}) 103 | fs.writeFileSync(filePathBuild, file) 104 | resolve() 105 | }) 106 | } 107 | 108 | promises.push(promise) 109 | } 110 | 111 | let preprocessed = await Promise.allSettled(promises) 112 | 113 | if (this.verbose) console.log(`^2preprocessing: ${Date.now() - start}ms^0`) 114 | 115 | preprocessed.map((file, index) => { 116 | if (file.status == "rejected") { 117 | throw new Error("Error detected when preprocessing") 118 | } 119 | }) 120 | } 121 | 122 | lineNeedToBeBuildRelative(line, ignoredFiles) { 123 | return ( 124 | !line.includes("build/") && !line.includes("@") // Not already build relative and not externally loaded 125 | ) && ( 126 | line.includes("\"") || line.includes("'") // Its a string 127 | ) && ( 128 | line.includes(".lua") || line.includes(".*") // Its a lua/any file 129 | ) && ( 130 | ignoredFiles.length == 0 || !ignoredFiles.some(file => line.includes(file)) // Skip building ignored files 131 | ) 132 | } 133 | 134 | async setPathsAsBuildRelative() { 135 | let resourcePath = GetResourcePath(this.resourceName) 136 | let fxmanifest = path.join(resourcePath, "fxmanifest.lua") 137 | let somethingChanged = false 138 | 139 | if (fs.existsSync(fxmanifest)) { 140 | let file = fs.readFileSync(fxmanifest, "utf-8") 141 | let lines = file.split("\n") 142 | let newLines = [] 143 | 144 | const ignored = GetIgnoredFiles(this.resourceName) 145 | let check = false 146 | let singleFile = false 147 | 148 | for (let line of lines) { 149 | if (!check) { 150 | // Start multiple files 151 | if (line.startsWith("client_scripts") || line.startsWith("server_scripts") || line.startsWith("shared_scripts") || line.startsWith("escrow_ignore")) { 152 | check = true 153 | 154 | // Start single file, dont skip 155 | } else if (line.startsWith("client_script") || line.startsWith("server_script") || line.startsWith("shared_script")) { 156 | check = true 157 | singleFile = true 158 | } 159 | } else { 160 | // End of multi file 161 | if (line.startsWith("}")) { 162 | check = false 163 | } 164 | } 165 | 166 | if (check) { 167 | //console.log(line, ignored, ignored.some(file => line.includes(file))) 168 | if (this.lineNeedToBeBuildRelative(line, ignored)) { 169 | line = line.replace(/(["'])/, "$1build/") 170 | somethingChanged = true 171 | } 172 | 173 | // Single file, reset check 174 | if (singleFile) { 175 | singleFile = false 176 | check = false 177 | } 178 | } 179 | 180 | newLines.push(line) 181 | } 182 | 183 | fs.writeFileSync(fxmanifest, newLines.join("\n")) 184 | 185 | if (somethingChanged) { 186 | ExecuteCommand("refresh") 187 | await new Promise((resolve, reject) => setTimeout(() => resolve(), 1000)) 188 | } 189 | } 190 | } 191 | 192 | async writeCache() { 193 | let cache = [] 194 | 195 | for (let filePath of getResourceProcessableFiles(this.resourceName)) { 196 | const stats = fs.statSync(filePath) 197 | 198 | cache.push({ 199 | path: absToRelative(filePath, this.resourceName), 200 | mtime: stats.mtimeMs, 201 | size: stats.size, 202 | inode: stats.ino 203 | }) 204 | } 205 | 206 | fs.mkdirSync("cache/leap/", {recursive: true}) 207 | fs.writeFileSync("cache/leap/" + this.resourceName + ".json", JSON.stringify(cache)) 208 | } 209 | } 210 | 211 | module.exports = { 212 | PreProcessor 213 | } -------------------------------------------------------------------------------- /functions/utils.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs") 2 | const {GetAllScripts, GetIgnoredFiles, ResolveFile} = require("./manifest") 3 | 4 | function getResourceProcessableFiles(resourceName) { 5 | let resourcePath = GetResourcePath(resourceName) 6 | let files = GetAllScripts(resourceName) 7 | let ignoredFiles = GetIgnoredFiles(resourceName) 8 | 9 | ignoredFiles = ignoredFiles.map(file => ResolveFile(resourcePath, file)) 10 | ignoredFiles = ignoredFiles.flat() 11 | 12 | files = files.map(file => ResolveFile(resourcePath, file)) 13 | files = files.flat() 14 | 15 | // Remove ignored files 16 | files = files.filter(file => !ignoredFiles.includes(file)) 17 | 18 | return files 19 | } 20 | 21 | function canFileBePreprocessed(filePath) { 22 | try { 23 | let itsEscrowed = /^FXAP/ 24 | let file = fs.readFileSync(filePath, "utf-8") 25 | 26 | return fs.existsSync(filePath) && 27 | fs.statSync(filePath).isFile() && 28 | itsEscrowed.exec(file) == null && 29 | file.length > 0 30 | } catch (e) { 31 | return false 32 | } 33 | } 34 | 35 | function isLeapDependency(res) { 36 | const nDependency = GetNumResourceMetadata(res, 'dependency'); 37 | 38 | if (nDependency > 0) { 39 | for (let i = 0; i < nDependency; i++) { 40 | const dependencyName = GetResourceMetadata(res, 'dependency'); 41 | 42 | if (dependencyName == GetCurrentResourceName()) { 43 | return true; 44 | } 45 | } 46 | } 47 | 48 | return false; 49 | } 50 | 51 | function loadCache(resourceName) { 52 | let file = "[]" 53 | 54 | try { 55 | file = fs.readFileSync("cache/leap/" + resourceName + ".json", "utf-8") 56 | } catch (e) {} 57 | 58 | return JSON.parse(file) 59 | } 60 | 61 | function hasCachedFileBeenModified(file, resourceName) { 62 | const filePath = relativeToAbs(file.path, resourceName) 63 | 64 | if (!fs.existsSync(filePath)) { 65 | return true 66 | } 67 | 68 | const stats = fs.statSync(filePath) 69 | 70 | if (stats.mtimeMs != file.mtime || stats.size != file.size || stats.ino != file.inode) { 71 | return true 72 | } 73 | } 74 | 75 | function hasAnyFileBeenModified(resourceName) { 76 | const files = getResourceProcessableFiles(resourceName) 77 | const cache = loadCache(resourceName) 78 | 79 | // No cache found 80 | if (cache.length == 0) { 81 | return true 82 | } 83 | 84 | if (cache.length < files.length) { 85 | return true 86 | } 87 | 88 | for (let file of cache) { 89 | if (hasCachedFileBeenModified(file, resourceName)) { 90 | return true 91 | } 92 | } 93 | 94 | return false 95 | } 96 | 97 | function cleanDeletedFilesFromBuild(resourceName) { 98 | const cache = loadCache(resourceName) 99 | let somethingDeleted = false 100 | 101 | for (let file of cache) { 102 | const _path = relativeToAbs(file.path, resourceName) 103 | if (!fs.existsSync(_path)) { 104 | const buildpath = relativeToAbs("build/"+file.path, resourceName) 105 | fs.rmSync(buildpath, {force: true}) 106 | somethingDeleted = true 107 | } 108 | } 109 | 110 | return somethingDeleted 111 | } 112 | 113 | function absToRelative(filePath, resourceName) { 114 | let resourcePath = GetResourcePath(resourceName) 115 | resourcePath = resourcePath.replace(/(\/\/|\/)/g, "\\") 116 | 117 | return filePath.replace(resourcePath, "") 118 | } 119 | 120 | function relativeToAbs(filePath, resourceName) { 121 | let resourcePath = GetResourcePath(resourceName) 122 | resourcePath = resourcePath.replace(/(\/\/|\/)/g, "\\") 123 | 124 | return path.join(resourcePath, filePath) 125 | } 126 | 127 | module.exports = { 128 | canFileBePreprocessed, 129 | absToRelative, 130 | relativeToAbs, 131 | isLeapDependency, 132 | loadCache, 133 | cleanDeletedFilesFromBuild, 134 | hasCachedFileBeenModified, 135 | hasAnyFileBeenModified, 136 | getResourceProcessableFiles 137 | } -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version "cerulean" 2 | game "gta5" 3 | authors "XenoS" 4 | github "https://github.com/utility-library/leap3" 5 | version "3.0.0" 6 | 7 | server_script "main.js" -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | //#region Imports 2 | const {PreProcessor} = require("./functions/preprocessResource") 3 | const {isLeapDependency, hasAnyFileBeenModified, relativeToAbs} = require("./functions/utils") 4 | const {rmSync} = require("fs") 5 | //#endregion 6 | 7 | //#region Build Task 8 | let leapBuildTask = { 9 | shouldBuild(res) { 10 | return isLeapDependency(res) && hasAnyFileBeenModified(res) 11 | }, 12 | build(res, cb) { 13 | // We need to use this trick as the build function cant be directly async 14 | let buildleap = async () => { 15 | try { 16 | const preprocessor = new PreProcessor(res) 17 | try { 18 | await preprocessor.run() 19 | await preprocessor.setPathsAsBuildRelative() 20 | await preprocessor.writeCache() 21 | } catch (e) { 22 | cb(false, e.message) 23 | return 24 | } 25 | 26 | cb(true) 27 | } catch (e) { 28 | cb(false, e.message) 29 | } 30 | } 31 | 32 | buildleap().then() 33 | } 34 | } 35 | 36 | // Register the build task after the server loaded (setImmediate runs immediately after the first tick in the main thread, that's started after the server loaded) 37 | setImmediate(() => { 38 | RegisterResourceBuildTaskFactory("leap", () => leapBuildTask) 39 | }) 40 | //#endregion 41 | 42 | //#region Command 43 | RegisterCommand("leap", async (source, args) => { 44 | if (source != 0) return // only server side can use the command 45 | 46 | let [type, resourceName] = args 47 | 48 | // No type or resource provided, display help 49 | if (!type || !resourceName) { 50 | console.log(`leap restart `) 51 | console.log(`leap build `) 52 | return 53 | } 54 | 55 | let preprocessor = new PreProcessor(resourceName) 56 | 57 | switch(type) { 58 | case "build": { 59 | const _path = relativeToAbs("build/", resourceName) 60 | rmSync(_path, {recursive: true, force: true}) 61 | 62 | await preprocessor.run(true) 63 | await preprocessor.setPathsAsBuildRelative() 64 | console.log(`^2Builded ${resourceName} successfully^0`) 65 | 66 | break; 67 | } 68 | case "restart": { 69 | StopResource(resourceName) 70 | 71 | await preprocessor.run() 72 | await preprocessor.setPathsAsBuildRelative() 73 | await preprocessor.writeCache() 74 | 75 | StartResource(resourceName) 76 | break; 77 | } 78 | } 79 | 80 | }, true) 81 | //#endregion -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "run": "node index.js" 4 | }, 5 | "dependencies": { 6 | "antlr4": "^4.13.2", 7 | "glob": "^10.3.10", 8 | "luamin": "^1.0.4" 9 | } 10 | } 11 | --------------------------------------------------------------------------------