Merge branch 'master' into 7.0.x
This commit is contained in:
@ -1038,7 +1038,7 @@ ImplicitParameterName : '$' DecimalLiteral ; // TODO: don't allow '_' here
|
||||
// GRAMMAR OF A LITERAL
|
||||
|
||||
booleanLiteral: BooleanLiteral ;
|
||||
literal : numericLiteral | MultiStringLiteral | SingleStringLiteral | BooleanLiteral | NilLiteral ;
|
||||
literal : numericLiteral | MultiStringLiteral | SingleStringLiteral | BooleanLiteral | NilLiteral | RawMultiStringLiteral | RawSingleStringLiteral ;
|
||||
|
||||
// GRAMMAR OF AN INTEGER LITERAL
|
||||
|
||||
@ -1093,11 +1093,16 @@ TRIPLEDQUOTES : '"""' ;
|
||||
|
||||
MultiStringLiteral : TRIPLEDQUOTES '\n' .*? '\n' TRIPLEDQUOTES ;
|
||||
fragment MultiQuotedText : MultiQuotedTextItem+ ;
|
||||
fragment MultiQuotedTextItem : MultiInterpolatedString
|
||||
| ~[\\\u000A\u000D]
|
||||
;
|
||||
fragment MultiQuotedTextItem : MultiInterpolatedString | ~[\\\u000A\u000D] ;
|
||||
fragment MultiInterpolatedString: '\\(' (MultiQuotedTextItem | SingleStringLiteral)* ')';
|
||||
|
||||
// swift 5 extended delimiter, eg ##"abc"##
|
||||
RawSingleStringLiteral : '#"' RawSingleQuotedTextItem* '"#' | '#' RawSingleStringLiteral '#';
|
||||
fragment RawSingleQuotedTextItem : ~[\u000A\u000D] ;
|
||||
|
||||
RawMultiStringLiteral : '#"""' RawMultiQuotedTextItem* '"""#' | '#' RawMultiStringLiteral '#';
|
||||
fragment RawMultiQuotedTextItem : . ;
|
||||
|
||||
// StringLiteral : '"' QuotedText? '"' ;
|
||||
SingleStringLiteral : '"' QuotedText? '"' ;
|
||||
fragment SingleDoubleQuote : '"' | ~["] ;
|
||||
|
@ -38,3 +38,16 @@ var x = 2
|
||||
print(x[keyPath: id]) // prints 2
|
||||
x[keyPath: id] = 3
|
||||
print(x[keyPath: id]) // prints 3
|
||||
|
||||
// https://www.swiftbysundell.com/articles/string-literals-in-swift/
|
||||
let rawString = #"Press "Continue" to close this dialog."#
|
||||
extension URL {
|
||||
func html(withTitle title: String) -> String {
|
||||
return ##"<a \href="\#(absoluteString)">\#(title)</a>"##
|
||||
}
|
||||
}
|
||||
|
||||
let rawMultiString = ###"a\###"###
|
||||
let rawMultiString2 = ###"""a\###
|
||||
""hey""
|
||||
"""###
|
||||
|
@ -197,4 +197,42 @@ L40
|
||||
[id] 18 20
|
||||
[\]] 20 21
|
||||
[)] 21 22
|
||||
L43
|
||||
[let] 1 4
|
||||
[rawString] 5 14
|
||||
[=] 15 16
|
||||
[#"Press "Continue" to close this d[ 17 59
|
||||
L44
|
||||
[extension] 1 10
|
||||
[URL] 11 14
|
||||
[{] 15 16
|
||||
L45
|
||||
[func] 5 9
|
||||
[html] 10 14
|
||||
[(] 14 15
|
||||
[withTitle] 15 24
|
||||
[title] 25 30
|
||||
[:] 30 31
|
||||
[String] 32 38
|
||||
[)] 38 39
|
||||
[->] 40 42
|
||||
[String] 43 49
|
||||
[{] 50 51
|
||||
L46
|
||||
[return] 9 15
|
||||
[##"<a \\href="\\#(absoluteString)"[ 16 65
|
||||
L47
|
||||
[}] 5 6
|
||||
L48
|
||||
[}] 1 2
|
||||
L50
|
||||
[let] 1 4
|
||||
[rawMultiString] 5 19
|
||||
[=] 20 21
|
||||
[###"a\\###"###] 22 35
|
||||
L51
|
||||
[let] 1 4
|
||||
[rawMultiString2] 5 20
|
||||
[=] 21 22
|
||||
[###"""a\\###\n""hey""\n"""###] 23 7
|
||||
EOF
|
||||
|
Reference in New Issue
Block a user