MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / parse

Method parse

src/main/java/net/optifine/expr/TokenParser.java:12–43  ·  view source on GitHub ↗
(String str)

Source from the content-addressed store, hash-verified

10public class TokenParser
11{
12 public static Token[] parse(String str) throws IOException, ParseException
13 {
14 Reader reader = new StringReader(str);
15 PushbackReader pushbackreader = new PushbackReader(reader);
16 List<Token> list = new ArrayList();
17
18 while (true)
19 {
20 int i = pushbackreader.read();
21
22 if (i < 0)
23 {
24 Token[] atoken = (Token[])((Token[])list.toArray(new Token[list.size()]));
25 return atoken;
26 }
27
28 char c0 = (char)i;
29
30 if (!Character.isWhitespace(c0))
31 {
32 TokenType tokentype = TokenType.getTypeByFirstChar(c0);
33
34 if (tokentype == null)
35 {
36 throw new ParseException("Invalid character: \'" + c0 + "\', in: " + str);
37 }
38
39 Token token = readToken(c0, tokentype, pushbackreader);
40 list.add(token);
41 }
42 }
43 }
44
45 private static Token readToken(char chFirst, TokenType type, PushbackReader pr) throws IOException
46 {

Callers 1

parseMethod · 0.95

Calls 6

getTypeByFirstCharMethod · 0.95
readTokenMethod · 0.95
readMethod · 0.45
toArrayMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected