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

Method mSTRING

output/java/1.4.14/STLexer.java:563–604  ·  view source on GitHub ↗

STRING : '"' ( '\\' '"' | '\\' ~'"' | ~('\\'|'"') ) '"' ;

()

Source from the content-addressed store, hash-verified

561 */
562
563 Token mSTRING() {
564 //{setText(getText().substring(1, getText().length()-1));}
565 boolean sawEscape = false;
566 StringBuilder buf = new StringBuilder();
567 buf.append(c);
568 consume();
569 while ( c!='"' ) {
570 if ( c=='\\' ) {
571 sawEscape = true;
572 consume();
573 switch ( c ) {
574 case 'n' :
575 buf.append('\n');
576 break;
577 case 'r' :
578 buf.append('\r');
579 break;
580 case 't' :
581 buf.append('\t');
582 break;
583 default:
584 buf.append(c);
585 break;
586 }
587 consume();
588 continue;
589 }
590 buf.append(c);
591 consume();
592 if ( c==EOF ) {
593 RecognitionException re = new MismatchedTokenException((int)'"', input);
594 re.line = input.getLine();
595 re.charPositionInLine = input.getCharPositionInLine();
596 errMgr.lexerError(input.getSourceName(), "EOF in string", templateToken, re);
597 break;
598 }
599 }
600 buf.append(c);
601 consume();
602 if ( sawEscape ) return newToken(STRING, buf.toString());
603 else return newToken(STRING);
604 }
605
606 void WS() {
607 while ( c==' ' || c=='\t' || c=='\n' || c=='\r' ) consume();

Callers 1

insideMethod · 0.95

Calls 8

consumeMethod · 0.95
newTokenMethod · 0.95
getCharPositionInLineMethod · 0.80
toStringMethod · 0.65
appendMethod · 0.45
getLineMethod · 0.45
lexerErrorMethod · 0.45
getSourceNameMethod · 0.45

Tested by

no test coverage detected