---
# System prepended metadata

title: 指令解析器
tags: [' MCEA', content, ' technology']

---

---
title: 指令解析器
tags: content, MCEA, technology
---

# 指令解析器(Command Parser)

## Commands Register
/net/minecraft/command/Commands

### StringReader
指令會被轉存成StringReader，並經由Brigadier進行逐步解析，進而建立

一共具兩個變數：
string : 指令字串本身
cursor : 指標位置，代表分析到字串的哪裡了

以及一共有以下特殊與操作性質的method可使用：
```java
static boolean isAllowedNumber(char c)              // is 0-9 .-
static boolean isQuotedStringStart(char c)          // is " '
static boolean isAllowedInUnquotedString(char c)    // is 0-9 a-Z _-.+

boolean canRead(int length)
boolean canRead()
char peek()            // charAt(cursor)
char peek(int offset)  // charAt(cursor+offset)
char read()            // charAt(cursor++)
void skip()            // ++cursor
void skipWhitespace()  // skip all the white-space char
int readInt()
long readLong()
double readDouble()
float readFloat()
String readUnquotedString()    // string of isAllowedInUnquotedString
String readQuotedString()      // string of isQuotedStringStart
String readStringUntil(char terminator)
String readString()            // readUnquotedString or readQuotedString
boolean readBoolean()          // "true" or "false"
void expect(char c)            // skip if peek is 'c'
```

---

### handleCommand
input : source(CommandSource), command(String)
```
command(String) -> stringreader(StringReader)
```


---

## EntitySelectorParser

