Changeset 15697ff
- Timestamp:
- Sep 11, 2017, 5:11:40 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 7b1d5ec
- Parents:
- f4b77f2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rf4b77f2 r15697ff 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 10 10:07:10201713 // Update Count : 27 5212 // Last Modified On : Mon Sep 11 08:22:25 2017 13 // Update Count : 2783 14 14 // 15 15 … … 43 43 #define YYDEBUG_LEXER_TEXT (yylval) // lexer loads this up each time 44 44 #define YYDEBUG 1 // get the pretty debugging code to compile 45 #define YYERROR_VERBOSE 45 46 46 47 #undef __GNUC_MINOR__ … … 62 63 stack< LinkageSpec::Spec > linkageStack; 63 64 64 void appendStr( string *to, string *from ) { 65 // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string. 66 to->insert( to->length() - 1, from->substr( 1, from->length() - 2 ) ); 65 bool appendStr( string & to, string & from ) { 66 // 1. Multiple strings are concatenated into a single string but not combined internally. The reason is that 67 // "\x12" "3" is treated as 2 characters versus 3 because "escape sequences are converted into single members of 68 // the execution character set just prior to adjacent string literal concatenation" (C11, Section 6.4.5-8). It is 69 // easier to let the C compiler handle this case. 70 // 71 // 2. String encodings are transformed into canonical form (one encoding at start) so the encoding can be found 72 // without searching the string, e.g.: "abc" L"def" L"ghi" => L"abc" "def" "ghi". Multiple encodings must match, 73 // i.e., u"a" U"b" L"c" is disallowed. 74 75 if ( from[0] != '"' ) { // encoding ? 76 if ( to[0] != '"' ) { // encoding ? 77 if ( to[0] != from[0] ) { // different encodings ? 78 yyerror( "non-matching string encodings for string-literal concatenation" ); 79 return false; // parse error, must call YYERROR in action 80 } // if 81 } else { 82 to = from[0] + to; // move encoding to start 83 } // if 84 from.erase( 0, 1 ); // remove 2nd encoding 85 } // if 86 to += " " + from; // concatenated into single string 87 return true; 67 88 } // appendStr 68 89 … … 88 109 bool forall = false; // aggregate have one or more forall qualifiers ? 89 110 %} 111 112 %define parse.error verbose 90 113 91 114 // Types declaration … … 391 414 | string_literal_list STRINGliteral 392 415 { 393 appendStr( $1, $2 );// append 2nd juxtaposed string to 1st416 if ( ! appendStr( *$1, *$2 ) ) YYERROR; // append 2nd juxtaposed string to 1st 394 417 delete $2; // allocated by lexer 395 418 $$ = $1; // conversion from tok to str
Note: See TracChangeset
for help on using the changeset viewer.