File tree Expand file tree Collapse file tree 5 files changed +43
-8
lines changed
test/kotlin/top/mcfpp/test Expand file tree Collapse file tree 5 files changed +43
-8
lines changed Original file line number Diff line number Diff line change 1
1
![ ] ( https://user-images.githubusercontent.com/90548686/236462051-b901f99c-bdef-435c-8ca2-0dda37b25285.png )
2
+ [ ![ Stargazers over time] ( https://starchart.cc/MinecraftFunctionPlusPlus/MCFPP.svg?variant=adaptive )] ( https://starchart.cc/MinecraftFunctionPlusPlus/MCFPP )
2
3
[ English] ( ./README.md )
3
4
------------
4
5
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ LCURL: '{' -> pushMode(DEFAULT_MODE);
14
14
RCURL : ' }' -> popMode;
15
15
MULT : ' *' ;
16
16
MOD : ' %' ;
17
- DIV : ' /' ;
17
+ DIV : ' /' -> pushMode(OrgCommand) ;
18
18
ADD : ' +' ;
19
19
SUB : ' -' ;
20
20
INCR : ' ++' ;
@@ -213,10 +213,6 @@ BooleanConstant
213
213
214
214
LineString : (' "' .*? ' "' )|( ' \' ' .*? ' \' ' );
215
215
216
- OrgCommand
217
- : ' /' [a-z]* ([ ][a-z:._ {} \\[0-9A-Z \]]*)+
218
- ;
219
-
220
216
WS : [ \t\r\n\u000C]+ -> skip
221
217
;
222
218
@@ -232,8 +228,19 @@ LINE_COMMENT
232
228
: ' #' ~[\r\n]* -> skip
233
229
;
234
230
231
+ mode OrgCommand ;
232
+
233
+ OrgCommandText
234
+ : ~(' $' |[\r\n])+ | ' $'
235
+ ;
235
236
237
+ OrgCommandExprStart
238
+ : ' ${' -> pushMode(DEFAULT_MODE )
239
+ ;
236
240
241
+ OrgCommandEnd
242
+ : (' \r\n ' | ' \n ' ) -> popMode
243
+ ;
237
244
238
245
mode MultiLineString ;
239
246
Original file line number Diff line number Diff line change @@ -477,7 +477,16 @@ executeExpression
477
477
;
478
478
479
479
orgCommand
480
- : OrgCommand
480
+ : DIV orgCommandContent+ OrgCommandEnd
481
+ ;
482
+
483
+ orgCommandContent
484
+ : orgCommandExpression
485
+ | OrgCommandText
486
+ ;
487
+
488
+ orgCommandExpression
489
+ : OrgCommandExprStart expression ' }'
481
490
;
482
491
483
492
controlStatement
Original file line number Diff line number Diff line change @@ -914,11 +914,26 @@ open class MCFPPImVisitor: mcfppParserBaseVisitor<Any?>() {
914
914
915
915
// endregion
916
916
917
-
917
+ /* *
918
+ * 使用原版命令
919
+ */
918
920
@InsertCommand
919
921
override fun visitOrgCommand (ctx : mcfppParser.OrgCommandContext ):Any? {
920
922
Project .ctx = ctx
921
- Function .addCommand(ctx.text.substring(1 ))
923
+ val sb = StringBuilder ()
924
+ for (content in ctx.orgCommandContent()){
925
+ if (content.OrgCommandText () != null ){
926
+ sb.append(content.OrgCommandText ().text)
927
+ }else {
928
+ val exp = MCFPPExprVisitor ().visit(content.orgCommandExpression().expression())
929
+ if (exp is MCFPPValue <* >){
930
+ sb.append(exp.value)
931
+ }else {
932
+ sb.append(exp)
933
+ }
934
+ }
935
+ }
936
+ Function .addCommand(sb.toString())
922
937
return null
923
938
}
924
939
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ class MNITest {
13
13
int qwq = 1;
14
14
print(qwq::jvm.identifier);
15
15
print(qwq::jvm.sbObject.toString());
16
+ /say ${' $' } {qwq}
17
+ /say ${' $' } {qwq::jvm.identifier}
18
+ /say ${' $' } {qwq::jvm.sbObject}
16
19
}
17
20
""" .trimIndent()
18
21
MCFPPStringTest .readFromString(test)
You can’t perform that action at this time.
0 commit comments