Skip to content

Commit

Permalink
Update mcfunction lexer to support newer spec of commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kofuk authored and alecthomas committed Aug 19, 2022
1 parent 6538430 commit cde3818
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lexers/embedded/mcfunction.xml
Expand Up @@ -92,7 +92,7 @@
<rule pattern="#.*?\n">
<token type="CommentSingle"/>
</rule>
<rule pattern="/?(geteduclientinfo|clearspawnpoint|defaultgamemode|transferserver|toggledownfall|immutableworld|detectredstone|setidletimeout|playanimation|classroommode|spreadplayers|testforblocks|setmaxplayers|setworldspawn|testforblock|worldbuilder|createagent|worldborder|camerashake|advancement|raytracefog|locatebiome|tickingarea|replaceitem|attributes|spawnpoint|difficulty|experience|scoreboard|whitelist|structure|playsound|stopsound|forceload|spectate|gamerule|function|schedule|wsserver|teleport|position|save-off|particle|setblock|datapack|mobevent|transfer|gamemode|save-all|bossbar|enchant|trigger|collect|execute|weather|teammsg|tpagent|banlist|dropall|publish|tellraw|testfor|save-on|destroy|ability|locate|summon|remove|effect|reload|ban-ip|recipe|pardon|detect|music|clear|clone|event|mixer|debug|title|ride|stop|list|turn|data|team|kick|loot|tell|help|give|flog|fill|move|time|seed|kill|save|item|deop|code|tag|ban|msg|say|tp|me|op|xp|w)\b">
<rule pattern="/?(geteduclientinfo|clearspawnpoint|defaultgamemode|transferserver|toggledownfall|immutableworld|detectredstone|setidletimeout|playanimation|classroommode|spreadplayers|testforblocks|setmaxplayers|setworldspawn|testforblock|worldbuilder|createagent|worldborder|camerashake|advancement|raytracefog|locatebiome|tickingarea|replaceitem|attributes|spawnpoint|difficulty|experience|scoreboard|whitelist|structure|playsound|stopsound|forceload|spectate|gamerule|function|schedule|wsserver|teleport|position|save-off|particle|setblock|datapack|mobevent|transfer|gamemode|save-all|bossbar|enchant|trigger|collect|execute|weather|teammsg|tpagent|banlist|dropall|publish|tellraw|testfor|save-on|destroy|ability|locate|summon|remove|effect|reload|ban-ip|recipe|pardon|detect|music|clear|clone|event|mixer|debug|title|ride|stop|list|turn|data|team|kick|loot|tell|help|give|flog|fill|move|time|seed|kill|save|item|deop|code|tag|ban|msg|say|tp|me|op|xp|w|place)\b">
<token type="KeywordReserved"/>
</rule>
<rule pattern="(@p|@r|@a|@e|@s|@c|@v)">
Expand Down Expand Up @@ -179,4 +179,4 @@
</rule>
</state>
</rules>
</lexer>
</lexer>
6 changes: 5 additions & 1 deletion lexers/testdata/mcfunction.actual
Expand Up @@ -9,5 +9,9 @@ gamemode creative @a
# With argument
kill @e[type=chicken,nested={a0=0,a1=1}]

# Ragne
# Range
kill @e[y_rotation=0..180]

# Legacy and new style
placefeature minecraft:bonus_chest ~ ~ ~
place feature minecraft:bonus_chest ~ ~ ~
25 changes: 24 additions & 1 deletion lexers/testdata/mcfunction.expected
Expand Up @@ -63,7 +63,7 @@
{"type":"LiteralNumberInteger","value":"1"},
{"type":"Punctuation","value":"}]"},
{"type":"TextWhitespace","value":"\n\n"},
{"type":"CommentSingle","value":"# Ragne\n"},
{"type":"CommentSingle","value":"# Range\n"},
{"type":"KeywordReserved","value":"kill"},
{"type":"TextWhitespace","value":" "},
{"type":"KeywordConstant","value":"@e"},
Expand All @@ -74,5 +74,28 @@
{"type":"Punctuation","value":".."},
{"type":"LiteralNumberInteger","value":"180"},
{"type":"Punctuation","value":"]"},
{"type":"TextWhitespace","value":"\n\n"},
{"type":"CommentSingle","value":"# Legacy and new style\n"},
{"type":"Text","value":"placefeature"},
{"type":"TextWhitespace","value":" "},
{"type":"Text","value":"minecraft:bonus_chest"},
{"type":"TextWhitespace","value":" "},
{"type":"NameBuiltin","value":"~"},
{"type":"TextWhitespace","value":" "},
{"type":"NameBuiltin","value":"~"},
{"type":"TextWhitespace","value":" "},
{"type":"NameBuiltin","value":"~"},
{"type":"TextWhitespace","value":"\n"},
{"type":"KeywordReserved","value":"place"},
{"type":"TextWhitespace","value":" "},
{"type":"Text","value":"feature"},
{"type":"TextWhitespace","value":" "},
{"type":"Text","value":"minecraft:bonus_chest"},
{"type":"TextWhitespace","value":" "},
{"type":"NameBuiltin","value":"~"},
{"type":"TextWhitespace","value":" "},
{"type":"NameBuiltin","value":"~"},
{"type":"TextWhitespace","value":" "},
{"type":"NameBuiltin","value":"~"},
{"type":"TextWhitespace","value":"\n"}
]

0 comments on commit cde3818

Please sign in to comment.