类 CharacterStream
java.lang.Object
org.ssssssss.script.parsing.CharacterStream
对字符串进行封装,提供匹配、跳过方法,方便词法解析。
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明charconsume()返回下一个字符endSpan()根据当前位置返回SpanendSpan(int offset) 根据当前位置 - offset 返回 SpanendSpan(int start, int end) int返回当前位置getSpan(int start, int end) 根据开始位置、结束位置返回SpanbooleanhasMore()是否有下一个字符boolean返回是否是以给定的字符串开头boolean匹配任意字符串booleanmatchDigit(boolean consume) 返回是否是数字booleanmatchIdentifierPart(boolean consume) 返回是否是标识符部分booleanmatchIdentifierStart(boolean consume) 返回是否以标识符开头voidreset(int position) 重置当前位置voidskipLine()跳过一行boolean直到给定的字符串之前全部跳过void跳过空白字符void记录当前位置为Span的开始位置substring(int startIndex, int endIndex) 截取字符串
-
构造器详细资料
-
CharacterStream
-
CharacterStream
-
-
方法详细资料
-
substring
截取字符串- 参数:
startIndex- 开始位置endIndex- 结束位置
-
hasMore
public boolean hasMore()是否有下一个字符 -
getSpan
根据开始位置、结束位置返回Span -
consume
public char consume()返回下一个字符 -
match
返回是否是以给定的字符串开头 -
matchAny
匹配任意字符串- 参数:
strs- 任意字符串- 返回:
-
matchDigit
public boolean matchDigit(boolean consume) 返回是否是数字 -
matchIdentifierStart
public boolean matchIdentifierStart(boolean consume) 返回是否以标识符开头 -
matchIdentifierPart
public boolean matchIdentifierPart(boolean consume) 返回是否是标识符部分- 参数:
consume- 是否消耗
-
skipLine
public void skipLine()跳过一行 -
skipUntil
直到给定的字符串之前全部跳过 -
skipWhiteSpace
public void skipWhiteSpace()跳过空白字符 -
startSpan
public void startSpan()记录当前位置为Span的开始位置 -
endSpan
根据当前位置返回Span -
endSpan
根据当前位置 - offset 返回 Span -
endSpan
-
getPosition
public int getPosition()返回当前位置 -
reset
public void reset(int position) 重置当前位置
-