MCPcopy Index your code
hub / github.com/react/react / parsePrimary

Function parsePrimary

scripts/babel/transform-test-gate-pragma.js:203–232  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

201 }
202
203 function parsePrimary() {
204 const token = tokens[i];
205 switch (token.type) {
206 case 'boolean': {
207 i++;
208 return t.booleanLiteral(token.value);
209 }
210 case 'name': {
211 i++;
212 return t.memberExpression(ctxIdentifier, t.identifier(token.name));
213 }
214 case 'string': {
215 i++;
216 return t.stringLiteral(token.value);
217 }
218 case '(': {
219 i++;
220 const expression = parseExpression();
221 const closingParen = tokens[i];
222 if (closingParen === undefined || closingParen.type !== ')') {
223 throw Error('Expected closing )');
224 }
225 i++;
226 return expression;
227 }
228 default: {
229 throw Error('Unexpected token: ' + token.type);
230 }
231 }
232 }
233
234 const program = parseExpression();
235 if (tokens[i] !== undefined) {

Callers 1

parseUnaryFunction · 0.85

Calls 1

parseExpressionFunction · 0.85

Tested by

no test coverage detected