@@ -1173,54 +1173,32 @@ define method make-character-literal
1173
1173
end ));
1174
1174
end method make-character-literal;
1175
1175
1176
- define method make-string-literal
1177
- (lexer :: <lexer>, source-location :: <lexer-source-location>)
1176
+ define method %make-string-literal
1177
+ (lexer :: <lexer>, source-location :: <lexer-source-location>,
1178
+ start-offset :: <integer> , end-offset :: <integer> ,
1179
+ allow-escapes? :: <boolean> )
1178
1180
=> (res :: <string-fragment>)
1181
+ let bpos = source-location.start-posn + start-offset;
1182
+ let epos = source-location.end-posn - end-offset;
1183
+ let string = decode-string(source-location, bpos, epos, allow-escapes?);
1179
1184
make (<string-fragment>,
1180
1185
record: source-location.source-location-record,
1181
1186
source-position: source-location.source-location-source-position,
1182
1187
// kind: $string-token,
1183
- value: as-fragment-value(decode-string(source-location,
1184
- source-location.start-posn + 1 ,
1185
- source-location.end-posn - 1 ,
1186
- #t )));
1187
- end method make-string-literal;
1188
+ value: as-fragment-value(string))
1189
+ end method ;
1188
1190
1189
- define method make-multi-line-string-literal
1190
- (lexer :: <lexer>, source-location :: <lexer-source-location>)
1191
- => (res :: <string-fragment>)
1192
- let bpos = source-location.start-posn + 3 ; // """
1193
- let epos = source-location.end-posn - 3 ; // """
1194
- make (<string-fragment>,
1195
- record: source-location.source-location-record,
1196
- source-position: source-location.source-location-source-position,
1197
- // kind: $string-token,
1198
- value: as-fragment-value(decode-string(source-location, bpos, epos, #t )))
1199
- end method make-multi-line-string-literal;
1191
+ define constant make-string-literal // "..."
1192
+ = rcurry (%make-string-literal, 1 , 1 , #t );
1200
1193
1201
- define method make-multi-line-raw-string-literal
1202
- (lexer :: <lexer>, source-location :: <lexer-source-location>)
1203
- => (res :: <string-fragment>)
1204
- let bpos = source-location.start-posn + 5 ; // #r"""
1205
- let epos = source-location.end-posn - 3 ; // """
1206
- make (<string-fragment>,
1207
- record: source-location.source-location-record,
1208
- source-position: source-location.source-location-source-position,
1209
- // kind: $string-token,
1210
- value: as-fragment-value(decode-string(source-location, bpos, epos, #f )))
1211
- end method ;
1194
+ define constant make-multi-line-string-literal // """..."""
1195
+ = rcurry (%make-string-literal, 3 , 3 , #t );
1212
1196
1213
- define method make-one-line-raw-string-literal
1214
- (lexer :: <lexer>, source-location :: <lexer-source-location>)
1215
- => (res :: <string-fragment>)
1216
- let bpos = source-location.start-posn + 3 ; // #r"
1217
- let epos = source-location.end-posn - 1 ; // "
1218
- make (<string-fragment>,
1219
- record: source-location.source-location-record,
1220
- source-position: source-location.source-location-source-position,
1221
- // kind: $string-token,
1222
- value: as-fragment-value(decode-string(source-location, bpos, epos, #f )))
1223
- end method ;
1197
+ define constant make-raw-string-literal // #r"..."
1198
+ = rcurry (%make-string-literal, 3 , 1 , #f );
1199
+
1200
+ define constant make-multi-line-raw-string-literal // #r"""..."""
1201
+ = rcurry (%make-string-literal, 5 , 3 , #f );
1224
1202
1225
1203
define method parse-ratio-literal
1226
1204
(lexer :: <lexer>, source-location :: <lexer-source-location>)
0 commit comments