forked from phoedos/pmd
Cleanups and minor tweaks for issues found in testing across 500KLOC of open source Lua code.
This commit is contained in:
@@ -62,6 +62,7 @@ Tested by Matt Hargett with:
|
|||||||
- Entire codebase and test suite for neovim v0.7.2: https://github.com/neovim/neovim/tree/v0.7.2
|
- Entire codebase and test suite for neovim v0.7.2: https://github.com/neovim/neovim/tree/v0.7.2
|
||||||
- Entire codebase for World of Warcraft Interface: https://github.com/tomrus88/BlizzardInterfaceCode
|
- Entire codebase for World of Warcraft Interface: https://github.com/tomrus88/BlizzardInterfaceCode
|
||||||
- Benchmarks and conformance test suite for Luau 0.537: https://github.com/Roblox/luau/tree/0.537
|
- Benchmarks and conformance test suite for Luau 0.537: https://github.com/Roblox/luau/tree/0.537
|
||||||
|
- Entire Lua codebase for nmap 7.92 : https://github.com/nmap/nmap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
grammar Lua;
|
grammar Lua;
|
||||||
@@ -115,7 +116,7 @@ funcname
|
|||||||
;
|
;
|
||||||
|
|
||||||
funcbody
|
funcbody
|
||||||
: ('<' genericTypeParameterList '>')? '(' parlist? ')' (':' '...'? returnType ) block 'end' // genericTypeParameterList and returnType
|
: ('<' genericTypeParameterList '>')? '(' parlist? ')' (':' '...'? returnType ) block 'end'
|
||||||
;
|
;
|
||||||
|
|
||||||
parlist
|
parlist
|
||||||
@@ -249,7 +250,7 @@ simpleType
|
|||||||
: NIL
|
: NIL
|
||||||
| singletonType
|
| singletonType
|
||||||
| NAME ('.' NAME)? ('<' typeParams '>')?
|
| NAME ('.' NAME)? ('<' typeParams '>')?
|
||||||
| 'typeof' '(' NAME ('(' ')')? | '...' ')' // can't use `exp`, manually handle common cases
|
| 'typeof' '(' exp ')'
|
||||||
| tableType
|
| tableType
|
||||||
| functionType
|
| functionType
|
||||||
;
|
;
|
||||||
@@ -260,25 +261,25 @@ singletonType
|
|||||||
|
|
||||||
type
|
type
|
||||||
: simpleType ('?')?
|
: simpleType ('?')?
|
||||||
| simpleType ('?')? ('|' type) // can't use type because it's mutually left-recursive
|
| type ('|' type)
|
||||||
| simpleType ('?')? ('&' type) // can't use type because it's mutually left-recursive
|
| type ('&' type)
|
||||||
;
|
;
|
||||||
|
|
||||||
genericTypePackParameter: NAME '...' ('=' (('(' (typeList)? ')') | variadicTypePack | genericTypePack))?; // typePack must be inlined here
|
genericTypePackParameter: NAME '...' ('=' (typePack | variadicTypePack | genericTypePack))?;
|
||||||
|
|
||||||
genericTypeParameterList: NAME ('=' type)? (',' genericTypeParameterList)? | genericTypePackParameter (',' genericTypePackParameter)*;
|
genericTypeParameterList: NAME ('=' type)? (',' genericTypeParameterList)? | genericTypePackParameter (',' genericTypePackParameter)*;
|
||||||
|
|
||||||
typeList: type (',' type)? | variadicTypePack;
|
typeList: type (',' typeList)? | variadicTypePack;
|
||||||
|
|
||||||
typeParams: (type | variadicTypePack | genericTypePack) (',' typeParams)?; // had to remove typePack
|
typeParams: (type | typePack | variadicTypePack | genericTypePack) (',' typeParams)?;
|
||||||
|
|
||||||
// typePack: inlined everywhere to avoid overly greedy match when out-of-context
|
typePack: '(' (typeList)? ')';
|
||||||
|
|
||||||
genericTypePack: NAME '...';
|
genericTypePack: NAME '...';
|
||||||
|
|
||||||
variadicTypePack: '...' type;
|
variadicTypePack: '...' type;
|
||||||
|
|
||||||
returnType: variadicTypePack | '(' typeList ')' | '(' ')'; // can't use typePack, inline common cases
|
returnType: type | typePack;
|
||||||
|
|
||||||
tableIndexer: '[' type ']' ':' type;
|
tableIndexer: '[' type ']' ':' type;
|
||||||
|
|
||||||
@@ -288,7 +289,7 @@ tablePropOrIndexer
|
|||||||
: tableProp | tableIndexer;
|
: tableProp | tableIndexer;
|
||||||
|
|
||||||
propList
|
propList
|
||||||
: tablePropOrIndexer ((','|';') tablePropOrIndexer)* (','|';')?;
|
: tablePropOrIndexer (fieldsep tablePropOrIndexer)* fieldsep?;
|
||||||
|
|
||||||
tableType
|
tableType
|
||||||
: '{' propList '}';
|
: '{' propList '}';
|
||||||
@@ -296,7 +297,7 @@ tableType
|
|||||||
functionType: ('<' genericTypeParameterList '>')? '(' (typeList)? ')' '->' returnType;
|
functionType: ('<' genericTypeParameterList '>')? '(' (typeList)? ')' '->' returnType;
|
||||||
|
|
||||||
require
|
require
|
||||||
: 'require' '(' (NAME ('.' NAME)*) | NORMALSTRING ')' ('::' type)?
|
: 'local'? bindinglist '=' 'require' '(' exp ')' ('.' NAME)* ('::' type)? ';'?
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ local _notVariable = not x
|
|||||||
local _length = #{x}
|
local _length = #{x}
|
||||||
export type Function<T... = ...any> = (...any) -> T...
|
export type Function<T... = ...any> = (...any) -> T...
|
||||||
local _PlatformService = nil
|
local _PlatformService = nil
|
||||||
local game = require(script.Parent.game) :: any
|
local game = require(script.Parent.game).default :: any
|
||||||
pcall(function() _PlatformService = game:GetService('PlatformService') end)
|
pcall(function() _PlatformService = game:GetService('PlatformService') end)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -84,8 +84,10 @@ L11
|
|||||||
[.] 35 35
|
[.] 35 35
|
||||||
[game] 36 39
|
[game] 36 39
|
||||||
[)] 40 40
|
[)] 40 40
|
||||||
[::] 42 43
|
[.] 41 41
|
||||||
[any] 45 47
|
[default] 42 48
|
||||||
|
[::] 50 51
|
||||||
|
[any] 53 55
|
||||||
L12
|
L12
|
||||||
[pcall] 1 5
|
[pcall] 1 5
|
||||||
[(] 6 6
|
[(] 6 6
|
||||||
|
Reference in New Issue
Block a user