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

Method mSTRING

output/java/1.4.19/STLexer.java:570–611  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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