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

Method subTemplate

output/java/1.4.17/STLexer.java:379–420  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

377 }
378
379 Token subTemplate() {
380 // look for "{ args ID (',' ID)* '|' ..."
381 subtemplateDepth++;
382 int m = input.mark();
383 int curlyStartChar = startCharIndex;
384 int curlyLine = startLine;
385 int curlyPos = startCharPositionInLine;
386 List<Token> argTokens = new ArrayList<Token>();
387 consume();
388 Token curly = newTokenFromPreviousChar(LCURLY);
389 WS();
390 argTokens.add(mID());
391 WS();
392 while ( c==',' ) {
393 consume();
394 argTokens.add(newTokenFromPreviousChar(COMMA));
395 WS();
396 argTokens.add(mID());
397 WS();
398 }
399 WS();
400 if ( c=='|' ) {
401 consume();
402 argTokens.add(newTokenFromPreviousChar(PIPE));
403 if ( isWS(c) ) consume(); // ignore a single whitespace after |
404 //System.out.println("matched args: "+argTokens);
405 for (Token t : argTokens) emit(t);
406 input.release(m);
407 scanningInsideExpr = false;
408 startCharIndex = curlyStartChar; // reset state
409 startLine = curlyLine;
410 startCharPositionInLine = curlyPos;
411 return curly;
412 }
413 input.rewind(m);
414 startCharIndex = curlyStartChar; // reset state
415 startLine = curlyLine;
416 startCharPositionInLine = curlyPos;
417 consume();
418 scanningInsideExpr = false;
419 return curly;
420 }
421
422 Token ESCAPE() {
423 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