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

Method mSTRING

output/java/1.4.13/STLexer.java:552–593  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

550 */
551
552 Token mSTRING() {
553 //{setText(getText().substring(1, getText().length()-1));}
554 boolean sawEscape = false;
555 StringBuilder buf = new StringBuilder();
556 buf.append(c);
557 consume();
558 while ( c!='"' ) {
559 if ( c=='\\' ) {
560 sawEscape = true;
561 consume();
562 switch ( c ) {
563 case 'n' :
564 buf.append('\n');
565 break;
566 case 'r' :
567 buf.append('\r');
568 break;
569 case 't' :
570 buf.append('\t');
571 break;
572 default:
573 buf.append(c);
574 break;
575 }
576 consume();
577 continue;
578 }
579 buf.append(c);
580 consume();
581 if ( c==EOF ) {
582 RecognitionException re = new MismatchedTokenException((int)'"', input);
583 re.line = input.getLine();
584 re.charPositionInLine = input.getCharPositionInLine();
585 errMgr.lexerError(input.getSourceName(), "EOF in string", templateToken, re);
586 break;
587 }
588 }
589 buf.append(c);
590 consume();
591 if ( sawEscape ) return newToken(STRING, buf.toString());
592 else return newToken(STRING);
593 }
594
595 void WS() {
596 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