MCPcopy Create free account
hub / github.com/GJDuck/e9patch / parseIndex

Function parseIndex

src/e9tool/e9action.cpp:60–77  ·  view source on GitHub ↗

* Parse and index. */

Source from the content-addressed store, hash-verified

58 * Parse and index.
59 */
60static intptr_t parseIndex(Parser &parser, intptr_t lb, intptr_t ub)
61{
62 parser.expectToken('[');
63 bool neg = false;
64 if (parser.peekToken() == '-')
65 {
66 neg = true;
67 parser.getToken();
68 }
69 parser.expectToken(TOKEN_INTEGER);
70 intptr_t idx = parser.i;
71 idx = (neg? -idx: idx);
72 parser.expectToken(']');
73 if (idx < lb || idx > ub)
74 error("failed to parse %s; expected index within the range "
75 "%ld..%ld, found %ld", parser.mode, lb, ub, idx);
76 return idx;
77}
78
79/*
80 * Parse a symbolic value.

Callers 2

parseMatchArgFunction · 0.85
parsePatchArgFunction · 0.85

Calls 4

errorFunction · 0.85
expectTokenMethod · 0.80
peekTokenMethod · 0.80
getTokenMethod · 0.80

Tested by

no test coverage detected