MCPcopy Create free account
hub / github.com/antlr/codebuff / subTemplate

Method subTemplate

output/java8/1.4.13/STLexer.java:368–409  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

366 }
367
368 Token subTemplate() {
369 // look for "{ args ID (',' ID)* '|' ..."
370 subtemplateDepth++;
371 int m = input.mark();
372 int curlyStartChar = startCharIndex;
373 int curlyLine = startLine;
374 int curlyPos = startCharPositionInLine;
375 List<Token> argTokens = new ArrayList<Token>();
376 consume();
377 Token curly = newTokenFromPreviousChar(LCURLY);
378 WS();
379 argTokens.add(mID());
380 WS();
381 while ( c==',' ) {
382 consume();
383 argTokens.add(newTokenFromPreviousChar(COMMA));
384 WS();
385 argTokens.add(mID());
386 WS();
387 }
388 WS();
389 if ( c=='|' ) {
390 consume();
391 argTokens.add(newTokenFromPreviousChar(PIPE));
392 if ( isWS(c) ) consume(); // ignore a single whitespace after |
393 //System.out.println("matched args: "+argTokens);
394 for (Token t : argTokens) emit(t);
395 input.release(m);
396 scanningInsideExpr = false;
397 startCharIndex = curlyStartChar; // reset state
398 startLine = curlyLine;
399 startCharPositionInLine = curlyPos;
400 return curly;
401 }
402 input.rewind(m);
403 startCharIndex = curlyStartChar; // reset state
404 startLine = curlyLine;
405 startCharPositionInLine = curlyPos;
406 consume();
407 scanningInsideExpr = false;
408 return curly;
409 }
410
411 Token ESCAPE() {
412 startCharIndex = input.index();

Callers 1

insideMethod · 0.95

Calls 8

consumeMethod · 0.95
WSMethod · 0.95
mIDMethod · 0.95
isWSMethod · 0.95
emitMethod · 0.95
addMethod · 0.65
markMethod · 0.45

Tested by

no test coverage detected