@plurnk/plurnk-mimetypes-text-lua 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/TextLua.d.ts +7 -0
- package/dist/TextLua.d.ts.map +1 -0
- package/dist/TextLua.js +130 -0
- package/dist/TextLua.js.map +1 -0
- package/dist/generated/LuaLexer.d.ts +95 -0
- package/dist/generated/LuaLexer.d.ts.map +1 -0
- package/dist/generated/LuaLexer.js +373 -0
- package/dist/generated/LuaLexer.js.map +1 -0
- package/dist/generated/LuaLexerBase.d.ts +12 -0
- package/dist/generated/LuaLexerBase.d.ts.map +1 -0
- package/dist/generated/LuaLexerBase.js +75 -0
- package/dist/generated/LuaLexerBase.js.map +1 -0
- package/dist/generated/LuaParser.d.ts +453 -0
- package/dist/generated/LuaParser.d.ts.map +1 -0
- package/dist/generated/LuaParser.js +3116 -0
- package/dist/generated/LuaParser.js.map +1 -0
- package/dist/generated/LuaParserBase.d.ts +6 -0
- package/dist/generated/LuaParserBase.d.ts.map +1 -0
- package/dist/generated/LuaParserBase.js +17 -0
- package/dist/generated/LuaParserBase.js.map +1 -0
- package/dist/generated/LuaParserVisitor.d.ts +193 -0
- package/dist/generated/LuaParserVisitor.d.ts.map +1 -0
- package/dist/generated/LuaParserVisitor.js +167 -0
- package/dist/generated/LuaParserVisitor.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/grammar/LuaLexer.g4 +122 -0
- package/grammar/LuaParser.g4 +178 -0
- package/package.json +55 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { AbstractParseTreeVisitor } from "antlr4ng";
|
|
2
|
+
/**
|
|
3
|
+
* This interface defines a complete generic visitor for a parse tree produced
|
|
4
|
+
* by `LuaParser`.
|
|
5
|
+
*
|
|
6
|
+
* @param <Result> The return type of the visit operation. Use `void` for
|
|
7
|
+
* operations with no return type.
|
|
8
|
+
*/
|
|
9
|
+
export class LuaParserVisitor extends AbstractParseTreeVisitor {
|
|
10
|
+
/**
|
|
11
|
+
* Visit a parse tree produced by `LuaParser.start_`.
|
|
12
|
+
* @param ctx the parse tree
|
|
13
|
+
* @return the visitor result
|
|
14
|
+
*/
|
|
15
|
+
visitStart_;
|
|
16
|
+
/**
|
|
17
|
+
* Visit a parse tree produced by `LuaParser.chunk`.
|
|
18
|
+
* @param ctx the parse tree
|
|
19
|
+
* @return the visitor result
|
|
20
|
+
*/
|
|
21
|
+
visitChunk;
|
|
22
|
+
/**
|
|
23
|
+
* Visit a parse tree produced by `LuaParser.block`.
|
|
24
|
+
* @param ctx the parse tree
|
|
25
|
+
* @return the visitor result
|
|
26
|
+
*/
|
|
27
|
+
visitBlock;
|
|
28
|
+
/**
|
|
29
|
+
* Visit a parse tree produced by `LuaParser.stat`.
|
|
30
|
+
* @param ctx the parse tree
|
|
31
|
+
* @return the visitor result
|
|
32
|
+
*/
|
|
33
|
+
visitStat;
|
|
34
|
+
/**
|
|
35
|
+
* Visit a parse tree produced by `LuaParser.attnamelist`.
|
|
36
|
+
* @param ctx the parse tree
|
|
37
|
+
* @return the visitor result
|
|
38
|
+
*/
|
|
39
|
+
visitAttnamelist;
|
|
40
|
+
/**
|
|
41
|
+
* Visit a parse tree produced by `LuaParser.attrib`.
|
|
42
|
+
* @param ctx the parse tree
|
|
43
|
+
* @return the visitor result
|
|
44
|
+
*/
|
|
45
|
+
visitAttrib;
|
|
46
|
+
/**
|
|
47
|
+
* Visit a parse tree produced by `LuaParser.retstat`.
|
|
48
|
+
* @param ctx the parse tree
|
|
49
|
+
* @return the visitor result
|
|
50
|
+
*/
|
|
51
|
+
visitRetstat;
|
|
52
|
+
/**
|
|
53
|
+
* Visit a parse tree produced by `LuaParser.label`.
|
|
54
|
+
* @param ctx the parse tree
|
|
55
|
+
* @return the visitor result
|
|
56
|
+
*/
|
|
57
|
+
visitLabel;
|
|
58
|
+
/**
|
|
59
|
+
* Visit a parse tree produced by `LuaParser.funcname`.
|
|
60
|
+
* @param ctx the parse tree
|
|
61
|
+
* @return the visitor result
|
|
62
|
+
*/
|
|
63
|
+
visitFuncname;
|
|
64
|
+
/**
|
|
65
|
+
* Visit a parse tree produced by `LuaParser.varlist`.
|
|
66
|
+
* @param ctx the parse tree
|
|
67
|
+
* @return the visitor result
|
|
68
|
+
*/
|
|
69
|
+
visitVarlist;
|
|
70
|
+
/**
|
|
71
|
+
* Visit a parse tree produced by `LuaParser.namelist`.
|
|
72
|
+
* @param ctx the parse tree
|
|
73
|
+
* @return the visitor result
|
|
74
|
+
*/
|
|
75
|
+
visitNamelist;
|
|
76
|
+
/**
|
|
77
|
+
* Visit a parse tree produced by `LuaParser.explist`.
|
|
78
|
+
* @param ctx the parse tree
|
|
79
|
+
* @return the visitor result
|
|
80
|
+
*/
|
|
81
|
+
visitExplist;
|
|
82
|
+
/**
|
|
83
|
+
* Visit a parse tree produced by `LuaParser.exp`.
|
|
84
|
+
* @param ctx the parse tree
|
|
85
|
+
* @return the visitor result
|
|
86
|
+
*/
|
|
87
|
+
visitExp;
|
|
88
|
+
/**
|
|
89
|
+
* Visit a parse tree produced by `LuaParser.var`.
|
|
90
|
+
* @param ctx the parse tree
|
|
91
|
+
* @return the visitor result
|
|
92
|
+
*/
|
|
93
|
+
visitVar;
|
|
94
|
+
/**
|
|
95
|
+
* Visit a parse tree produced by `LuaParser.prefixexp`.
|
|
96
|
+
* @param ctx the parse tree
|
|
97
|
+
* @return the visitor result
|
|
98
|
+
*/
|
|
99
|
+
visitPrefixexp;
|
|
100
|
+
/**
|
|
101
|
+
* Visit a parse tree produced by `LuaParser.functioncall`.
|
|
102
|
+
* @param ctx the parse tree
|
|
103
|
+
* @return the visitor result
|
|
104
|
+
*/
|
|
105
|
+
visitFunctioncall;
|
|
106
|
+
/**
|
|
107
|
+
* Visit a parse tree produced by `LuaParser.args`.
|
|
108
|
+
* @param ctx the parse tree
|
|
109
|
+
* @return the visitor result
|
|
110
|
+
*/
|
|
111
|
+
visitArgs;
|
|
112
|
+
/**
|
|
113
|
+
* Visit a parse tree produced by `LuaParser.functiondef`.
|
|
114
|
+
* @param ctx the parse tree
|
|
115
|
+
* @return the visitor result
|
|
116
|
+
*/
|
|
117
|
+
visitFunctiondef;
|
|
118
|
+
/**
|
|
119
|
+
* Visit a parse tree produced by `LuaParser.funcbody`.
|
|
120
|
+
* @param ctx the parse tree
|
|
121
|
+
* @return the visitor result
|
|
122
|
+
*/
|
|
123
|
+
visitFuncbody;
|
|
124
|
+
/**
|
|
125
|
+
* Visit a parse tree produced by `LuaParser.parlist`.
|
|
126
|
+
* @param ctx the parse tree
|
|
127
|
+
* @return the visitor result
|
|
128
|
+
*/
|
|
129
|
+
visitParlist;
|
|
130
|
+
/**
|
|
131
|
+
* Visit a parse tree produced by `LuaParser.tableconstructor`.
|
|
132
|
+
* @param ctx the parse tree
|
|
133
|
+
* @return the visitor result
|
|
134
|
+
*/
|
|
135
|
+
visitTableconstructor;
|
|
136
|
+
/**
|
|
137
|
+
* Visit a parse tree produced by `LuaParser.fieldlist`.
|
|
138
|
+
* @param ctx the parse tree
|
|
139
|
+
* @return the visitor result
|
|
140
|
+
*/
|
|
141
|
+
visitFieldlist;
|
|
142
|
+
/**
|
|
143
|
+
* Visit a parse tree produced by `LuaParser.field`.
|
|
144
|
+
* @param ctx the parse tree
|
|
145
|
+
* @return the visitor result
|
|
146
|
+
*/
|
|
147
|
+
visitField;
|
|
148
|
+
/**
|
|
149
|
+
* Visit a parse tree produced by `LuaParser.fieldsep`.
|
|
150
|
+
* @param ctx the parse tree
|
|
151
|
+
* @return the visitor result
|
|
152
|
+
*/
|
|
153
|
+
visitFieldsep;
|
|
154
|
+
/**
|
|
155
|
+
* Visit a parse tree produced by `LuaParser.number`.
|
|
156
|
+
* @param ctx the parse tree
|
|
157
|
+
* @return the visitor result
|
|
158
|
+
*/
|
|
159
|
+
visitNumber;
|
|
160
|
+
/**
|
|
161
|
+
* Visit a parse tree produced by `LuaParser.string`.
|
|
162
|
+
* @param ctx the parse tree
|
|
163
|
+
* @return the visitor result
|
|
164
|
+
*/
|
|
165
|
+
visitString;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=LuaParserVisitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LuaParserVisitor.js","sourceRoot":"","sources":["../../src/generated/LuaParserVisitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AA+BpD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAyB,SAAQ,wBAAgC;IAC1E;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,gBAAgB,CAAuC;IACvD;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,aAAa,CAAoC;IACjD;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,aAAa,CAAoC;IACjD;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,QAAQ,CAA+B;IACvC;;;;OAIG;IACH,QAAQ,CAA+B;IACvC;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,iBAAiB,CAAwC;IACzD;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,gBAAgB,CAAuC;IACvD;;;;OAIG;IACH,aAAa,CAAoC;IACjD;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,qBAAqB,CAA4C;IACjE;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,aAAa,CAAoC;IACjD;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,WAAW,CAAkC;CAChD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false
|
|
2
|
+
// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine
|
|
3
|
+
// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true
|
|
4
|
+
|
|
5
|
+
lexer grammar LuaLexer;
|
|
6
|
+
|
|
7
|
+
options {
|
|
8
|
+
superClass = LuaLexerBase;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Insert here @header for lexer.
|
|
12
|
+
|
|
13
|
+
SEMI : ';';
|
|
14
|
+
EQ : '=';
|
|
15
|
+
|
|
16
|
+
BREAK : 'break';
|
|
17
|
+
GOTO : 'goto';
|
|
18
|
+
DO : 'do';
|
|
19
|
+
END : 'end';
|
|
20
|
+
WHILE : 'while';
|
|
21
|
+
REPEAT : 'repeat';
|
|
22
|
+
UNTIL : 'until';
|
|
23
|
+
IF : 'if';
|
|
24
|
+
THEN : 'then';
|
|
25
|
+
ELSEIF : 'elseif';
|
|
26
|
+
ELSE : 'else';
|
|
27
|
+
FOR : 'for';
|
|
28
|
+
COMMA : ',';
|
|
29
|
+
IN : 'in';
|
|
30
|
+
FUNCTION : 'function';
|
|
31
|
+
LOCAL : 'local';
|
|
32
|
+
LT : '<';
|
|
33
|
+
GT : '>';
|
|
34
|
+
RETURN : 'return';
|
|
35
|
+
CC : '::';
|
|
36
|
+
NIL : 'nil';
|
|
37
|
+
FALSE : 'false';
|
|
38
|
+
TRUE : 'true';
|
|
39
|
+
DOT : '.';
|
|
40
|
+
SQUIG : '~';
|
|
41
|
+
MINUS : '-';
|
|
42
|
+
POUND : '#';
|
|
43
|
+
OP : '(';
|
|
44
|
+
CP : ')';
|
|
45
|
+
NOT : 'not';
|
|
46
|
+
LL : '<<';
|
|
47
|
+
GG : '>>';
|
|
48
|
+
AMP : '&';
|
|
49
|
+
SS : '//';
|
|
50
|
+
PER : '%';
|
|
51
|
+
COL : ':';
|
|
52
|
+
LE : '<=';
|
|
53
|
+
GE : '>=';
|
|
54
|
+
AND : 'and';
|
|
55
|
+
OR : 'or';
|
|
56
|
+
PLUS : '+';
|
|
57
|
+
STAR : '*';
|
|
58
|
+
OCU : '{';
|
|
59
|
+
CCU : '}';
|
|
60
|
+
OB : '[';
|
|
61
|
+
CB : ']';
|
|
62
|
+
EE : '==';
|
|
63
|
+
DD : '..';
|
|
64
|
+
PIPE : '|';
|
|
65
|
+
CARET : '^';
|
|
66
|
+
SLASH : '/';
|
|
67
|
+
DDD : '...';
|
|
68
|
+
SQEQ : '~=';
|
|
69
|
+
|
|
70
|
+
NAME: [a-zA-Z_][a-zA-Z_0-9]*;
|
|
71
|
+
|
|
72
|
+
NORMALSTRING: '"' ( EscapeSequence | ~('\\' | '"'))* '"';
|
|
73
|
+
|
|
74
|
+
CHARSTRING: '\'' ( EscapeSequence | ~('\'' | '\\'))* '\'';
|
|
75
|
+
|
|
76
|
+
LONGSTRING: '[' NESTED_STR ']';
|
|
77
|
+
|
|
78
|
+
fragment NESTED_STR: '=' NESTED_STR '=' | '[' .*? ']';
|
|
79
|
+
|
|
80
|
+
INT: Digit+;
|
|
81
|
+
|
|
82
|
+
HEX: '0' [xX] HexDigit+;
|
|
83
|
+
|
|
84
|
+
FLOAT: Digit+ '.' Digit* ExponentPart? | '.' Digit+ ExponentPart? | Digit+ ExponentPart;
|
|
85
|
+
|
|
86
|
+
HEX_FLOAT:
|
|
87
|
+
'0' [xX] HexDigit+ '.' HexDigit* HexExponentPart?
|
|
88
|
+
| '0' [xX] '.' HexDigit+ HexExponentPart?
|
|
89
|
+
| '0' [xX] HexDigit+ HexExponentPart
|
|
90
|
+
;
|
|
91
|
+
|
|
92
|
+
fragment ExponentPart: [eE] [+-]? Digit+;
|
|
93
|
+
|
|
94
|
+
fragment HexExponentPart: [pP] [+-]? Digit+;
|
|
95
|
+
|
|
96
|
+
fragment EscapeSequence:
|
|
97
|
+
'\\' [abfnrtvz"'|$#\\] // World of Warcraft Lua additionally escapes |$#
|
|
98
|
+
| '\\' '\r'? '\n'
|
|
99
|
+
| DecimalEscape
|
|
100
|
+
| HexEscape
|
|
101
|
+
| UtfEscape
|
|
102
|
+
;
|
|
103
|
+
|
|
104
|
+
fragment DecimalEscape: '\\' Digit | '\\' Digit Digit | '\\' [0-2] Digit Digit;
|
|
105
|
+
|
|
106
|
+
fragment HexEscape: '\\' 'x' HexDigit HexDigit;
|
|
107
|
+
|
|
108
|
+
fragment UtfEscape: '\\' 'u{' HexDigit+ '}';
|
|
109
|
+
|
|
110
|
+
fragment Digit: [0-9];
|
|
111
|
+
|
|
112
|
+
fragment HexDigit: [0-9a-fA-F];
|
|
113
|
+
|
|
114
|
+
fragment SingleLineInputCharacter: ~[\r\n\u0085\u2028\u2029];
|
|
115
|
+
|
|
116
|
+
COMMENT: '--' { this.HandleComment(); } -> channel(HIDDEN);
|
|
117
|
+
|
|
118
|
+
WS: [ \t\u000C\r]+ -> channel(HIDDEN);
|
|
119
|
+
|
|
120
|
+
NL: [\n] -> channel(2);
|
|
121
|
+
|
|
122
|
+
SHEBANG: '#' { this.IsLine1Col0() }? '!'? SingleLineInputCharacter* -> channel(HIDDEN);
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT license
|
|
4
|
+
|
|
5
|
+
Author: Ken Domino, October 2023
|
|
6
|
+
|
|
7
|
+
Based on previous work of: Kazunori Sakamoto, Alexander Alexeev
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
|
|
12
|
+
// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging
|
|
13
|
+
|
|
14
|
+
parser grammar LuaParser;
|
|
15
|
+
|
|
16
|
+
options {
|
|
17
|
+
tokenVocab = LuaLexer;
|
|
18
|
+
superClass = LuaParserBase;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Insert here @header for parser.
|
|
22
|
+
|
|
23
|
+
start_
|
|
24
|
+
: chunk EOF
|
|
25
|
+
;
|
|
26
|
+
|
|
27
|
+
chunk
|
|
28
|
+
: block
|
|
29
|
+
;
|
|
30
|
+
|
|
31
|
+
block
|
|
32
|
+
: stat* retstat?
|
|
33
|
+
;
|
|
34
|
+
|
|
35
|
+
stat
|
|
36
|
+
: ';'
|
|
37
|
+
| varlist '=' explist
|
|
38
|
+
| functioncall
|
|
39
|
+
| label
|
|
40
|
+
| 'break'
|
|
41
|
+
| 'goto' NAME
|
|
42
|
+
| 'do' block 'end'
|
|
43
|
+
| 'while' exp 'do' block 'end'
|
|
44
|
+
| 'repeat' block 'until' exp
|
|
45
|
+
| 'if' exp 'then' block ('elseif' exp 'then' block)* ('else' block)? 'end'
|
|
46
|
+
| 'for' NAME '=' exp ',' exp (',' exp)? 'do' block 'end'
|
|
47
|
+
| 'for' namelist 'in' explist 'do' block 'end'
|
|
48
|
+
| 'function' funcname funcbody
|
|
49
|
+
| 'local' 'function' NAME funcbody
|
|
50
|
+
| 'local' attnamelist ('=' explist)?
|
|
51
|
+
;
|
|
52
|
+
|
|
53
|
+
attnamelist
|
|
54
|
+
: NAME attrib (',' NAME attrib)*
|
|
55
|
+
;
|
|
56
|
+
|
|
57
|
+
attrib
|
|
58
|
+
: ('<' NAME '>')?
|
|
59
|
+
;
|
|
60
|
+
|
|
61
|
+
retstat
|
|
62
|
+
: 'return' explist? ';'?
|
|
63
|
+
;
|
|
64
|
+
|
|
65
|
+
label
|
|
66
|
+
: '::' NAME '::'
|
|
67
|
+
;
|
|
68
|
+
|
|
69
|
+
funcname
|
|
70
|
+
: NAME ('.' NAME)* (':' NAME)?
|
|
71
|
+
;
|
|
72
|
+
|
|
73
|
+
varlist
|
|
74
|
+
: var (',' var)*
|
|
75
|
+
;
|
|
76
|
+
|
|
77
|
+
namelist
|
|
78
|
+
: NAME (',' NAME)*
|
|
79
|
+
;
|
|
80
|
+
|
|
81
|
+
explist
|
|
82
|
+
: exp (',' exp)*
|
|
83
|
+
;
|
|
84
|
+
|
|
85
|
+
exp
|
|
86
|
+
: 'nil'
|
|
87
|
+
| 'false'
|
|
88
|
+
| 'true'
|
|
89
|
+
| number
|
|
90
|
+
| string
|
|
91
|
+
| '...'
|
|
92
|
+
| functiondef
|
|
93
|
+
| prefixexp
|
|
94
|
+
| tableconstructor
|
|
95
|
+
| <assoc = right> exp ('^') exp
|
|
96
|
+
| ('not' | '#' | '-' | '~') exp
|
|
97
|
+
| exp ('*' | '/' | '%' | '//') exp
|
|
98
|
+
| exp ('+' | '-') exp
|
|
99
|
+
| <assoc = right> exp ('..') exp
|
|
100
|
+
| exp ('<' | '>' | '<=' | '>=' | '~=' | '==') exp
|
|
101
|
+
| exp ('and') exp
|
|
102
|
+
| exp ('or') exp
|
|
103
|
+
| exp ('&' | '|' | '~' | '<<' | '>>') exp
|
|
104
|
+
;
|
|
105
|
+
|
|
106
|
+
// var ::= Name | prefixexp '[' exp ']' | prefixexp '.' Name
|
|
107
|
+
var
|
|
108
|
+
: NAME
|
|
109
|
+
| prefixexp ('[' exp ']' | '.' NAME)
|
|
110
|
+
;
|
|
111
|
+
|
|
112
|
+
// prefixexp ::= var | functioncall | '(' exp ')'
|
|
113
|
+
prefixexp
|
|
114
|
+
: { this.IsFunctionCall() }? NAME ( '[' exp ']' | '.' NAME )*
|
|
115
|
+
| functioncall ( '[' exp ']' | '.' NAME )*
|
|
116
|
+
| '(' exp ')' ( '[' exp ']' | '.' NAME )*
|
|
117
|
+
;
|
|
118
|
+
|
|
119
|
+
// functioncall ::= prefixexp args | prefixexp ':' Name args;
|
|
120
|
+
functioncall
|
|
121
|
+
: ( ( NAME | '(' exp ')' ) ( '[' exp ']' | '.' NAME )* ( args | ':' NAME args ) ) ( ( '[' exp ']' | '.' NAME )* ( args | ':' NAME args ) )*
|
|
122
|
+
;
|
|
123
|
+
|
|
124
|
+
args
|
|
125
|
+
: '(' explist? ')'
|
|
126
|
+
| tableconstructor
|
|
127
|
+
| string
|
|
128
|
+
;
|
|
129
|
+
|
|
130
|
+
functiondef
|
|
131
|
+
: 'function' funcbody
|
|
132
|
+
;
|
|
133
|
+
|
|
134
|
+
funcbody
|
|
135
|
+
: '(' parlist ')' block 'end'
|
|
136
|
+
;
|
|
137
|
+
|
|
138
|
+
/* lparser.c says "is 'parlist' not empty?"
|
|
139
|
+
* That code does so by checking la(1) == ')'.
|
|
140
|
+
* This means that parlist can derive empty.
|
|
141
|
+
*/
|
|
142
|
+
parlist
|
|
143
|
+
: namelist (',' '...')?
|
|
144
|
+
| '...'
|
|
145
|
+
|
|
|
146
|
+
;
|
|
147
|
+
|
|
148
|
+
tableconstructor
|
|
149
|
+
: '{' fieldlist? '}'
|
|
150
|
+
;
|
|
151
|
+
|
|
152
|
+
fieldlist
|
|
153
|
+
: field (fieldsep field)* fieldsep?
|
|
154
|
+
;
|
|
155
|
+
|
|
156
|
+
field
|
|
157
|
+
: '[' exp ']' '=' exp
|
|
158
|
+
| NAME '=' exp
|
|
159
|
+
| exp
|
|
160
|
+
;
|
|
161
|
+
|
|
162
|
+
fieldsep
|
|
163
|
+
: ','
|
|
164
|
+
| ';'
|
|
165
|
+
;
|
|
166
|
+
|
|
167
|
+
number
|
|
168
|
+
: INT
|
|
169
|
+
| HEX
|
|
170
|
+
| FLOAT
|
|
171
|
+
| HEX_FLOAT
|
|
172
|
+
;
|
|
173
|
+
|
|
174
|
+
string
|
|
175
|
+
: NORMALSTRING
|
|
176
|
+
| CHARSTRING
|
|
177
|
+
| LONGSTRING
|
|
178
|
+
;
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plurnk/plurnk-mimetypes-text-lua",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "text/x-lua mimetype handler for plurnk-service. ANTLR-backed extraction via grammars-v4.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=25"
|
|
12
|
+
},
|
|
13
|
+
"plurnk": {
|
|
14
|
+
"kind": "mimetype",
|
|
15
|
+
"handlers": [
|
|
16
|
+
{
|
|
17
|
+
"name": "text/x-lua",
|
|
18
|
+
"glyph": "\ud83c\udf19",
|
|
19
|
+
"extensions": [
|
|
20
|
+
".lua"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist/**/*",
|
|
34
|
+
"grammar/**/*",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test:lint": "tsc --noEmit",
|
|
39
|
+
"test:unit": "node --test src/**/*.test.ts",
|
|
40
|
+
"test": "npm run test:lint && npm run test:unit",
|
|
41
|
+
"build:grammar": "plurnk-mimetypes-compile",
|
|
42
|
+
"build:dist": "tsc -p tsconfig.build.json",
|
|
43
|
+
"build": "npm run build:grammar && npm run build:dist",
|
|
44
|
+
"prepare": "npm run build"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@plurnk/plurnk-mimetypes": "0.7.4",
|
|
48
|
+
"antlr4ng": "^3.0.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^25.8.0",
|
|
52
|
+
"antlr-ng": "^1.0.10",
|
|
53
|
+
"typescript": "^6.0.3"
|
|
54
|
+
}
|
|
55
|
+
}
|