Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/Literals-String/00-META.yaml
Normal file
6
Task/Literals-String/00-META.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
category:
|
||||
- String manipulation
|
||||
- Syntax elements
|
||||
from: http://rosettacode.org/wiki/Literals/String
|
||||
note: Basic language learning
|
||||
19
Task/Literals-String/00-TASK.txt
Normal file
19
Task/Literals-String/00-TASK.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
;Task:
|
||||
Show literal specification of characters and strings.
|
||||
|
||||
If supported, show how the following work:
|
||||
:* ''verbatim strings'' (quotes where escape sequences are quoted literally)
|
||||
:* ''here-strings''
|
||||
|
||||
<br>
|
||||
Also, discuss which quotes expand variables.
|
||||
|
||||
|
||||
;Related tasks:
|
||||
* [[Special characters]]
|
||||
* [[Here document]]
|
||||
|
||||
|
||||
{{Template:Strings}}
|
||||
<br><br>
|
||||
|
||||
1
Task/Literals-String/11l/literals-string-1.11l
Normal file
1
Task/Literals-String/11l/literals-string-1.11l
Normal file
|
|
@ -0,0 +1 @@
|
|||
V c = Char(‘a’)
|
||||
1
Task/Literals-String/11l/literals-string-2.11l
Normal file
1
Task/Literals-String/11l/literals-string-2.11l
Normal file
|
|
@ -0,0 +1 @@
|
|||
"foo\nbar"
|
||||
2
Task/Literals-String/11l/literals-string-3.11l
Normal file
2
Task/Literals-String/11l/literals-string-3.11l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
‘foo
|
||||
bar’
|
||||
1
Task/Literals-String/11l/literals-string-4.11l
Normal file
1
Task/Literals-String/11l/literals-string-4.11l
Normal file
|
|
@ -0,0 +1 @@
|
|||
'‘‘don’t’ // the same as "don’t"
|
||||
|
|
@ -0,0 +1 @@
|
|||
db "Hello World"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
db "Hello World"
|
||||
db $48,$65,$6c,$6c,$6f,$20,$57,$6f,$72,$6c,$64
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
LDA #'A' ;load ascii code of "A" into the accumulator.
|
||||
LDA 'A' ;load the byte stored at memory address 0x41 into the accumulator.
|
||||
|
|
@ -0,0 +1 @@
|
|||
db "Hello World",13,10,0
|
||||
23
Task/Literals-String/6502-Assembly/literals-string-5.6502
Normal file
23
Task/Literals-String/6502-Assembly/literals-string-5.6502
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
PrintString:
|
||||
lda (StringPtr),y
|
||||
beq Terminated
|
||||
cmp #'\' ; a single ascii character is specified in single quotes.
|
||||
beq HandleSpecialChars
|
||||
jsr PrintChar ;unimplemented print routine
|
||||
iny ;next character
|
||||
jmp PrintString ;back to top
|
||||
|
||||
Terminated:
|
||||
rts ;exit
|
||||
|
||||
HandleSpecialChars:
|
||||
iny ;next char
|
||||
lda (StringPtr),y
|
||||
cmp #'n'
|
||||
beq NextLine ;unimplemented new line routine, it ends in "JMP DoneSpecialChar."
|
||||
;Typically this would reset the x cursor and increment the y cursor, which are software variables that
|
||||
;get converted to a VRAM address in some other routine.
|
||||
|
||||
DoneSpecialChar:
|
||||
iny
|
||||
jmp PrintString ;jump back to top. Notice that neither the backslash nor the character after it were actually printed.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
DC.B "Hello World",0
|
||||
EVEN
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
DC.B "Hello World",0
|
||||
EVEN
|
||||
|
||||
DC.B $48,$65,$6c,$6c,$6f,$20,$57,$6f,$72,$6c,$64,$00
|
||||
EVEN
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
MOVE.L #'SEGA',D0 ;load the string "SEGA" into D0
|
||||
MOVE.L '0000',D0 ;load the 32-bit value at address 0x00303030 (the most significant byte is always treated as zero,
|
||||
;because the 68000 only has a 24-bit address space.
|
||||
1
Task/Literals-String/ALGOL-68/literals-string-1.alg
Normal file
1
Task/Literals-String/ALGOL-68/literals-string-1.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
CHAR charx = "z";
|
||||
6
Task/Literals-String/ALGOL-68/literals-string-10.alg
Normal file
6
Task/Literals-String/ALGOL-68/literals-string-10.alg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
INT pages=100, lines=25, characters=80;
|
||||
FILE bookf; FLEX[pages]FLEX[lines]FLEX[characters]CHAR book;
|
||||
associate(bookf, book);
|
||||
|
||||
# following putf inserts the string " Line 4 indented 5" on page 3 #
|
||||
putf(bookf, $3p"Page 3"4l5x"Line 4 indented 5"$)
|
||||
3
Task/Literals-String/ALGOL-68/literals-string-2.alg
Normal file
3
Task/Literals-String/ALGOL-68/literals-string-2.alg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[]CHAR charxyz = "xyz";
|
||||
STRING stringxyz = "xyz";
|
||||
FORMAT twonewlines = $ll$, threenewpages=$ppp$, fourbackspaces=$bbbb$;
|
||||
2
Task/Literals-String/ALGOL-68/literals-string-3.alg
Normal file
2
Task/Literals-String/ALGOL-68/literals-string-3.alg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
.PR QUOTE .PR
|
||||
[]'CHAR' CHARXYZ = "XYZ";
|
||||
1
Task/Literals-String/ALGOL-68/literals-string-4.alg
Normal file
1
Task/Literals-String/ALGOL-68/literals-string-4.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
MODE STRING = FLEX[1:0]CHAR;
|
||||
1
Task/Literals-String/ALGOL-68/literals-string-5.alg
Normal file
1
Task/Literals-String/ALGOL-68/literals-string-5.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
BYTES bytesabc = bytes pack("abc");
|
||||
1
Task/Literals-String/ALGOL-68/literals-string-6.alg
Normal file
1
Task/Literals-String/ALGOL-68/literals-string-6.alg
Normal file
|
|
@ -0,0 +1 @@
|
|||
STRING stringquote = """I'll be back."" - The Terminator";
|
||||
3
Task/Literals-String/ALGOL-68/literals-string-7.alg
Normal file
3
Task/Literals-String/ALGOL-68/literals-string-7.alg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
STRING linexyz := "line X;" +
|
||||
"line Y;" +
|
||||
"line Z;";
|
||||
2
Task/Literals-String/ALGOL-68/literals-string-8.alg
Normal file
2
Task/Literals-String/ALGOL-68/literals-string-8.alg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
FILE linef; STRING line;
|
||||
associate(linef, line);
|
||||
3
Task/Literals-String/ALGOL-68/literals-string-9.alg
Normal file
3
Task/Literals-String/ALGOL-68/literals-string-9.alg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
FORMAT my_symbol = $"SYMBOL"$;
|
||||
FORMAT foo = $"prefix_"f(my_symbol)"_suffix"$;
|
||||
putf(linef ,foo);
|
||||
20
Task/Literals-String/ALGOL-W/literals-string.alg
Normal file
20
Task/Literals-String/ALGOL-W/literals-string.alg
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
begin
|
||||
% String literals are enclosed in double-quotes in Algol W. %
|
||||
% There isn't a separate character type but strings of lenghth one can %
|
||||
% be used instead. %
|
||||
% There are no escaping conventions used in string literals, except that %
|
||||
% in order to have a double-quote character in a string, two double %
|
||||
% quotes must be used. %
|
||||
% Examples: %
|
||||
|
||||
% write a single character %
|
||||
write( "a" );
|
||||
|
||||
% write a double-quote character %
|
||||
write( """" );
|
||||
|
||||
% write a multi-character string - note the "\" is not an escape %
|
||||
% and a\nb will appear on the output, not a and b on separate lines %
|
||||
write( "a\nb" );
|
||||
|
||||
end.
|
||||
78
Task/Literals-String/ARM-Assembly/literals-string.arm
Normal file
78
Task/Literals-String/ARM-Assembly/literals-string.arm
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program stringsEx.s */
|
||||
|
||||
/* Constantes */
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
|
||||
/* Initialized data */
|
||||
.data
|
||||
szMessString: .asciz "String with final zero \n"
|
||||
szMessString1: .string "Other string with final zero \n"
|
||||
sString: .ascii "String without final zero"
|
||||
.byte 0 @ add final zero for display
|
||||
sLineSpaces: .byte '>'
|
||||
.fill 10,1,' ' @ 10 spaces
|
||||
.asciz "<\n" @ add <, CR and final zero for display
|
||||
sSpaces1: .space 10,' ' @ other 10 spaces
|
||||
.byte 0 @ add final zero for display
|
||||
sCharA: .space 10,'A' @ curious !! 10 A with space instruction
|
||||
.asciz "\n" @ add CR and final zero for display
|
||||
|
||||
cChar1: .byte 'A' @ character A
|
||||
cChar2: .byte 0x41 @ character A
|
||||
|
||||
szCarriageReturn: .asciz "\n"
|
||||
|
||||
/* UnInitialized data */
|
||||
.bss
|
||||
|
||||
/* code section */
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
|
||||
ldr r0,iAdrszMessString
|
||||
bl affichageMess @ display message
|
||||
ldr r0,iAdrszMessString1
|
||||
bl affichageMess
|
||||
ldr r0,iAdrsString
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
ldr r0,iAdrsLineSpaces
|
||||
bl affichageMess
|
||||
ldr r0,iAdrsCharA
|
||||
bl affichageMess
|
||||
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc 0 @ perform system call
|
||||
iAdrszMessString: .int szMessString
|
||||
iAdrszMessString1: .int szMessString1
|
||||
iAdrsString: .int sString
|
||||
iAdrsLineSpaces: .int sLineSpaces
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
iAdrsCharA: .int sCharA
|
||||
|
||||
/******************************************************************/
|
||||
/* display text with size calculation */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the message */
|
||||
affichageMess:
|
||||
push {r0,r1,r2,r7,lr} @ save registers
|
||||
mov r2,#0 @ counter length */
|
||||
1: @ loop length calculation
|
||||
ldrb r1,[r0,r2] @ read octet start position + index
|
||||
cmp r1,#0 @ if 0 its over
|
||||
addne r2,r2,#1 @ else add 1 in the length
|
||||
bne 1b @ and loop
|
||||
@ so here r2 contains the length of the message
|
||||
mov r1,r0 @ address message in r1
|
||||
mov r0,#STDOUT @ code to write to the standard output Linux
|
||||
mov r7, #WRITE @ code call system "write"
|
||||
svc #0 @ call system
|
||||
pop {r0,r1,r2,r7,lr} @ restaur registers
|
||||
bx lr @ return
|
||||
6
Task/Literals-String/AWK/literals-string-1.awk
Normal file
6
Task/Literals-String/AWK/literals-string-1.awk
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
c = "x"
|
||||
str= "hello"
|
||||
s1 = "abcd" # simple string
|
||||
s2 = "ab\"cd" # string containing a double quote, escaped with backslash
|
||||
print s1
|
||||
print s2
|
||||
2
Task/Literals-String/AWK/literals-string-2.awk
Normal file
2
Task/Literals-String/AWK/literals-string-2.awk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ awk 'BEGIN{c="x"; s="hello";s1 = "abcd"; s2 = "ab\"cd"; s=s c; print s; print s1; print s2}'
|
||||
hellox
|
||||
1
Task/Literals-String/Ada/literals-string-1.ada
Normal file
1
Task/Literals-String/Ada/literals-string-1.ada
Normal file
|
|
@ -0,0 +1 @@
|
|||
ch : character := 'a';
|
||||
2
Task/Literals-String/Ada/literals-string-2.ada
Normal file
2
Task/Literals-String/Ada/literals-string-2.ada
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
msg : string := "hello world";
|
||||
empty : string := ""; -- an empty string
|
||||
2
Task/Literals-String/Aime/literals-string-1.aime
Normal file
2
Task/Literals-String/Aime/literals-string-1.aime
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
integer c;
|
||||
c = 'z';
|
||||
2
Task/Literals-String/Aime/literals-string-2.aime
Normal file
2
Task/Literals-String/Aime/literals-string-2.aime
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
text s;
|
||||
s = "z";
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
M$ = CHR$(13) : Q$ = CHR$(34)
|
||||
A$ = "THERE ARE" + M$
|
||||
A$ = A$ + "NO " + Q$ + "HERE" + Q$ + " STRINGS."
|
||||
? A$
|
||||
24
Task/Literals-String/Arturo/literals-string.arturo
Normal file
24
Task/Literals-String/Arturo/literals-string.arturo
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
str: "Hello world"
|
||||
|
||||
print [str "->" type str]
|
||||
|
||||
fullLineStr: « This is a full-line string
|
||||
|
||||
print [fullLineStr "->" type fullLineStr]
|
||||
|
||||
multiline: {
|
||||
This
|
||||
is a multi-line
|
||||
string
|
||||
}
|
||||
|
||||
print [multiline "->" type multiline]
|
||||
|
||||
verbatim: {:
|
||||
This is
|
||||
a verbatim
|
||||
multi-line
|
||||
string
|
||||
:}
|
||||
|
||||
print [verbatim "->" type verbatim]
|
||||
13
Task/Literals-String/AutoHotkey/literals-string.ahk
Normal file
13
Task/Literals-String/AutoHotkey/literals-string.ahk
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
"c" ; character
|
||||
"text" ; string
|
||||
hereString = ; with interpolation of %variables%
|
||||
(
|
||||
"<>"
|
||||
the time is %A_Now%
|
||||
\!
|
||||
)
|
||||
|
||||
hereString2 = ; with same line comments allowed, without interpolation of variables
|
||||
(Comments %
|
||||
literal %A_Now% ; no interpolation here
|
||||
)
|
||||
1
Task/Literals-String/Axe/literals-string-1.axe
Normal file
1
Task/Literals-String/Axe/literals-string-1.axe
Normal file
|
|
@ -0,0 +1 @@
|
|||
'A'
|
||||
1
Task/Literals-String/Axe/literals-string-2.axe
Normal file
1
Task/Literals-String/Axe/literals-string-2.axe
Normal file
|
|
@ -0,0 +1 @@
|
|||
"ABC"
|
||||
4
Task/Literals-String/BASIC/literals-string-1.basic
Normal file
4
Task/Literals-String/BASIC/literals-string-1.basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
10 LET Q$=CHR$(34): REM DOUBLEQUOTES
|
||||
20 LET D$=Q$+Q$: REM A PAIR OF DOUBLEQUOTES
|
||||
30 LET S$=Q$+"THIS IS A QUOTED STRING"+Q$
|
||||
40 PRINT Q$;"HELLO";Q$:REM ADD QUOTES DURING OUTPUT
|
||||
5
Task/Literals-String/BASIC/literals-string-2.basic
Normal file
5
Task/Literals-String/BASIC/literals-string-2.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
DIM c AS STRING * 1, s AS STRING
|
||||
|
||||
c = "char" 'everything after the first character is silently discarded
|
||||
s = "string"
|
||||
PRINT CHR$(34); s; " data "; c; CHR$(34)
|
||||
3
Task/Literals-String/BASIC256/literals-string.basic
Normal file
3
Task/Literals-String/BASIC256/literals-string.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
print "Hello, World."
|
||||
print chr(34); "Hello, World." & chr(34)
|
||||
print "Tom said," + "'The fox ran away.'"
|
||||
1
Task/Literals-String/BBC-BASIC/literals-string.basic
Normal file
1
Task/Literals-String/BBC-BASIC/literals-string.basic
Normal file
|
|
@ -0,0 +1 @@
|
|||
PRINT "This is a ""quoted string"""
|
||||
1
Task/Literals-String/Befunge/literals-string.bf
Normal file
1
Task/Literals-String/Befunge/literals-string.bf
Normal file
|
|
@ -0,0 +1 @@
|
|||
"gnirts">:#,_@
|
||||
3
Task/Literals-String/C++/literals-string.cpp
Normal file
3
Task/Literals-String/C++/literals-string.cpp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
auto strA = R"(this is
|
||||
a newline-separated
|
||||
raw string)";
|
||||
4
Task/Literals-String/C-sharp/literals-string.cs
Normal file
4
Task/Literals-String/C-sharp/literals-string.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
string path = @"C:\Windows\System32";
|
||||
string multiline = @"Line 1.
|
||||
Line 2.
|
||||
Line 3.";
|
||||
1
Task/Literals-String/C/literals-string-1.c
Normal file
1
Task/Literals-String/C/literals-string-1.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
char ch = 'z';
|
||||
1
Task/Literals-String/C/literals-string-2.c
Normal file
1
Task/Literals-String/C/literals-string-2.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
char str[] = "z";
|
||||
3
Task/Literals-String/C/literals-string-3.c
Normal file
3
Task/Literals-String/C/literals-string-3.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
char lines[] = "line 1\n"
|
||||
"line 2\n"
|
||||
"line 3\n";
|
||||
1
Task/Literals-String/C/literals-string-4.c
Normal file
1
Task/Literals-String/C/literals-string-4.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define FOO "prefix_"##MY_SYMBOL##"_suffix"
|
||||
2
Task/Literals-String/COBOL/literals-string-1.cobol
Normal file
2
Task/Literals-String/COBOL/literals-string-1.cobol
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"This is a valid string."
|
||||
'As is this.'
|
||||
2
Task/Literals-String/COBOL/literals-string-2.cobol
Normal file
2
Task/Literals-String/COBOL/literals-string-2.cobol
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
X"00" *> Null character
|
||||
X"48656C6C6F21" *> "Hello!"
|
||||
6
Task/Literals-String/COBOL/literals-string-3.cobol
Normal file
6
Task/Literals-String/COBOL/literals-string-3.cobol
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
HIGH-VALUE HIGH-VALUES *> Equivalent to (a string of) X"FF".
|
||||
LOW-VALUE LOW-VALUES *> " " X"00".
|
||||
NULL *> " " X"00".
|
||||
QUOTE QUOTES *> " " double-quote character.
|
||||
SPACE SPACES *> " " space.
|
||||
ZERO ZEROS ZEROES *> " " zero.
|
||||
3
Task/Literals-String/Clojure/literals-string-1.clj
Normal file
3
Task/Literals-String/Clojure/literals-string-1.clj
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[\h \e \l \l \o] ; a vector of characters
|
||||
\uXXXX ; where XXXX is some hex Unicode code point
|
||||
\\ ; the backslash character literal
|
||||
6
Task/Literals-String/Clojure/literals-string-2.clj
Normal file
6
Task/Literals-String/Clojure/literals-string-2.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
\space
|
||||
\newline
|
||||
\tab
|
||||
\formfeed
|
||||
\return
|
||||
\backspace
|
||||
1
Task/Literals-String/Clojure/literals-string-3.clj
Normal file
1
Task/Literals-String/Clojure/literals-string-3.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
"hello world\r\n"
|
||||
3
Task/Literals-String/Common-Lisp/literals-string.lisp
Normal file
3
Task/Literals-String/Common-Lisp/literals-string.lisp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(let ((colon #\:)
|
||||
(str "http://www.rosettacode.com/"))
|
||||
(format t "colon found at position ~d~%" (position colon str)))
|
||||
1
Task/Literals-String/D/literals-string-1.d
Normal file
1
Task/Literals-String/D/literals-string-1.d
Normal file
|
|
@ -0,0 +1 @@
|
|||
char c = 'a';
|
||||
4
Task/Literals-String/D/literals-string-2.d
Normal file
4
Task/Literals-String/D/literals-string-2.d
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
auto str = "hello"; // UTF-8
|
||||
auto str2 = "hello"c; // UTF-8
|
||||
auto str3 = "hello"w; // UTF-16
|
||||
auto str4 = "hello"d; // UTF-32
|
||||
2
Task/Literals-String/D/literals-string-3.d
Normal file
2
Task/Literals-String/D/literals-string-3.d
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
auto str = `"Hello," he said.`;
|
||||
auto str2 = r"\n is slash-n";
|
||||
4
Task/Literals-String/D/literals-string-4.d
Normal file
4
Task/Literals-String/D/literals-string-4.d
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// Any character is allowed after the first quote;
|
||||
// the string ends with that same character followed
|
||||
// by a quote.
|
||||
auto str = q"$"Hello?" he enquired.$";
|
||||
5
Task/Literals-String/D/literals-string-5.d
Normal file
5
Task/Literals-String/D/literals-string-5.d
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// If you include a newline, you get a heredoc string:
|
||||
auto otherStr = q"EOS
|
||||
This is part of the string.
|
||||
So is this.
|
||||
EOS";
|
||||
4
Task/Literals-String/D/literals-string-6.d
Normal file
4
Task/Literals-String/D/literals-string-6.d
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// The contents of a token string must be valid code fragments.
|
||||
auto str = q{int i = 5;};
|
||||
// The contents here isn't a legal token in D, so it's an error:
|
||||
auto illegal = q{@?};
|
||||
2
Task/Literals-String/D/literals-string-7.d
Normal file
2
Task/Literals-String/D/literals-string-7.d
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
// assigns value 'hello' to str
|
||||
auto str = x"68 65 6c 6c 6f";
|
||||
3
Task/Literals-String/DWScript/literals-string.dw
Normal file
3
Task/Literals-String/DWScript/literals-string.dw
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
const s1 := 'quoted "word" in string';
|
||||
const s2 := "quoted ""word"" in string"; // sames as s1, shows the doubling of the delimiter
|
||||
const s2 := 'first line'#13#10'second line'; // CR+LF in the middle
|
||||
8
Task/Literals-String/Delphi/literals-string.delphi
Normal file
8
Task/Literals-String/Delphi/literals-string.delphi
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
var
|
||||
lChar: Char;
|
||||
lLine: string;
|
||||
lMultiLine: string;
|
||||
begin
|
||||
lChar := 'a';
|
||||
lLine := 'some text';
|
||||
lMultiLine := 'some text' + #13#10 + 'on two lines';
|
||||
2
Task/Literals-String/Dyalect/literals-string-1.dyalect
Normal file
2
Task/Literals-String/Dyalect/literals-string-1.dyalect
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let c = '\u0020' //a character
|
||||
let str = "A string\non several lines!\sAnd you can incorporate expressions: \(c)!"
|
||||
3
Task/Literals-String/Dyalect/literals-string-2.dyalect
Normal file
3
Task/Literals-String/Dyalect/literals-string-2.dyalect
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
let long_str = <[first line
|
||||
second line
|
||||
third line]>
|
||||
4
Task/Literals-String/E/literals-string-1.e
Normal file
4
Task/Literals-String/E/literals-string-1.e
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
'T' # character
|
||||
"The quick brown fox" # string
|
||||
`The $kind brown fox` # "simple" quasiliteral
|
||||
term`the($adjectives*, fox)` # "term" quasiliteral
|
||||
5
Task/Literals-String/E/literals-string-2.e
Normal file
5
Task/Literals-String/E/literals-string-2.e
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
? if ("<abc,def>" =~ `<@a,@b>`) { [a, b] } else { null }
|
||||
# value: ["abc", "def"]
|
||||
|
||||
? if (" >abc, def< " =~ rx`\W*(@a\w+)\W+(@b\w+)\W*`) { [a, b] } else { null }
|
||||
# value: ["abc", "def"]
|
||||
2
Task/Literals-String/EasyLang/literals-string.easy
Normal file
2
Task/Literals-String/EasyLang/literals-string.easy
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print "EasyLang"
|
||||
print "简"
|
||||
1
Task/Literals-String/Ela/literals-string-1.ela
Normal file
1
Task/Literals-String/Ela/literals-string-1.ela
Normal file
|
|
@ -0,0 +1 @@
|
|||
c = 'c'
|
||||
1
Task/Literals-String/Ela/literals-string-2.ela
Normal file
1
Task/Literals-String/Ela/literals-string-2.ela
Normal file
|
|
@ -0,0 +1 @@
|
|||
str = "Hello, world!"
|
||||
2
Task/Literals-String/Ela/literals-string-3.ela
Normal file
2
Task/Literals-String/Ela/literals-string-3.ela
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
c = '\t'
|
||||
str = "first line\nsecond line\nthird line"
|
||||
2
Task/Literals-String/Ela/literals-string-4.ela
Normal file
2
Task/Literals-String/Ela/literals-string-4.ela
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
vs = <[This is a
|
||||
verbatim string]>
|
||||
5
Task/Literals-String/Elena/literals-string.elena
Normal file
5
Task/Literals-String/Elena/literals-string.elena
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var c := $65; // character
|
||||
var s := "some text"; // UTF-8 literal
|
||||
var w := "some wide text"w; // UTF-16 literal
|
||||
var s2 := "text with ""quotes"" and
|
||||
two lines";
|
||||
3
Task/Literals-String/Elixir/literals-string-1.elixir
Normal file
3
Task/Literals-String/Elixir/literals-string-1.elixir
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
IO.puts "Begin String \n============"
|
||||
str = "string"
|
||||
str |> is_binary # true
|
||||
1
Task/Literals-String/Elixir/literals-string-2.elixir
Normal file
1
Task/Literals-String/Elixir/literals-string-2.elixir
Normal file
|
|
@ -0,0 +1 @@
|
|||
str |> String.codepoints
|
||||
1
Task/Literals-String/Elixir/literals-string-3.elixir
Normal file
1
Task/Literals-String/Elixir/literals-string-3.elixir
Normal file
|
|
@ -0,0 +1 @@
|
|||
str <> <<0>>
|
||||
3
Task/Literals-String/Elixir/literals-string-4.elixir
Normal file
3
Task/Literals-String/Elixir/literals-string-4.elixir
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
?a # 97
|
||||
Code.eval_string("?b") # 98
|
||||
Code.eval_string("?ł") # 322
|
||||
4
Task/Literals-String/Elixir/literals-string-5.elixir
Normal file
4
Task/Literals-String/Elixir/literals-string-5.elixir
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
IO.inspect "Begin Char List \n============="
|
||||
[115, 116, 114, 105, 110, 103]
|
||||
ch = "hi"
|
||||
'string #{ch}'
|
||||
1
Task/Literals-String/Elixir/literals-string-6.elixir
Normal file
1
Task/Literals-String/Elixir/literals-string-6.elixir
Normal file
|
|
@ -0,0 +1 @@
|
|||
'string #{ch}'++[0]
|
||||
1
Task/Literals-String/Emacs-Lisp/literals-string-1.l
Normal file
1
Task/Literals-String/Emacs-Lisp/literals-string-1.l
Normal file
|
|
@ -0,0 +1 @@
|
|||
"This is a string."
|
||||
2
Task/Literals-String/Emacs-Lisp/literals-string-2.l
Normal file
2
Task/Literals-String/Emacs-Lisp/literals-string-2.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
?z ;=> 122
|
||||
?\n ;=> 10
|
||||
2
Task/Literals-String/Erlang/literals-string-1.erl
Normal file
2
Task/Literals-String/Erlang/literals-string-1.erl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"This is a string".
|
||||
[$T,$h,$i,$s,$ ,$a,$ ,$s,$t,$r,$i,$n,$g,$,,$ ,$t,$o,$o].
|
||||
1
Task/Literals-String/Erlang/literals-string-2.erl
Normal file
1
Task/Literals-String/Erlang/literals-string-2.erl
Normal file
|
|
@ -0,0 +1 @@
|
|||
97 == $a. % => true
|
||||
1
Task/Literals-String/Erlang/literals-string-3.erl
Normal file
1
Task/Literals-String/Erlang/literals-string-3.erl
Normal file
|
|
@ -0,0 +1 @@
|
|||
"\"The quick brown fox jumps over the lazy dog.\"".
|
||||
7
Task/Literals-String/F-Sharp/literals-string.fs
Normal file
7
Task/Literals-String/F-Sharp/literals-string.fs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
let n= 'N'
|
||||
let i="Name=\"Nigel Galloway\"\n"
|
||||
let g= @"Name=""Nigel Galloway""\n"
|
||||
let e="Nigel
|
||||
Galloway"
|
||||
let l= """Name="Nigel Galloway"\n"""
|
||||
printfn "%c\n%s\n%s\n%s\n%s" n i g e l
|
||||
1
Task/Literals-String/Factor/literals-string-1.factor
Normal file
1
Task/Literals-String/Factor/literals-string-1.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
CHAR: a
|
||||
7
Task/Literals-String/Factor/literals-string-10.factor
Normal file
7
Task/Literals-String/Factor/literals-string-10.factor
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
USE: multiline
|
||||
STRING: random-stuff
|
||||
ABC
|
||||
123
|
||||
"x y z
|
||||
;
|
||||
random-stuff print
|
||||
15
Task/Literals-String/Factor/literals-string-11.factor
Normal file
15
Task/Literals-String/Factor/literals-string-11.factor
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
USING: interpolate locals namespaces ;
|
||||
|
||||
"Sally" "name" set
|
||||
"bicycle"
|
||||
"home"
|
||||
|
||||
[let
|
||||
|
||||
"crying" :> a
|
||||
|
||||
[I ${name} crashed her ${1}. Her ${1} broke.
|
||||
${name} ran ${} ${a}.
|
||||
I]
|
||||
|
||||
]
|
||||
5
Task/Literals-String/Factor/literals-string-2.factor
Normal file
5
Task/Literals-String/Factor/literals-string-2.factor
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
CHAR: x ! 120
|
||||
CHAR: \u000032 ! 50
|
||||
CHAR: \u{exclamation-mark} ! 33
|
||||
CHAR: exclamation-mark ! 33
|
||||
CHAR: ugaritic-letter-samka ! 66450
|
||||
1
Task/Literals-String/Factor/literals-string-3.factor
Normal file
1
Task/Literals-String/Factor/literals-string-3.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
"Hello, world!"
|
||||
1
Task/Literals-String/Factor/literals-string-4.factor
Normal file
1
Task/Literals-String/Factor/literals-string-4.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
"Hello, world!" { } like ! { 72 101 108 108 111 44 32 119 111 114 108 100 33 }
|
||||
1
Task/Literals-String/Factor/literals-string-5.factor
Normal file
1
Task/Literals-String/Factor/literals-string-5.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
"Line one\nLine two" print
|
||||
1
Task/Literals-String/Factor/literals-string-6.factor
Normal file
1
Task/Literals-String/Factor/literals-string-6.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
"\"Hello,\" she said." print
|
||||
3
Task/Literals-String/Factor/literals-string-7.factor
Normal file
3
Task/Literals-String/Factor/literals-string-7.factor
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
"2\u{superscript-two} = 4
|
||||
2\u{superscript-three} = 8
|
||||
2\u{superscript-four} = 16" print
|
||||
4
Task/Literals-String/Factor/literals-string-8.factor
Normal file
4
Task/Literals-String/Factor/literals-string-8.factor
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
USE: multiline
|
||||
[[ escape codes \t are literal \\ in here
|
||||
but newlines \u{plus-minus-sign} are still
|
||||
inserted " for each line the string \" spans.]] print
|
||||
8
Task/Literals-String/Factor/literals-string-9.factor
Normal file
8
Task/Literals-String/Factor/literals-string-9.factor
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
USE: multiline
|
||||
HEREDOC: END
|
||||
Everything between the line above
|
||||
and the final line (a user-defined token)
|
||||
is parsed into a string where whitespace
|
||||
is significant.
|
||||
END
|
||||
print
|
||||
2
Task/Literals-String/Forth/literals-string-1.fth
Normal file
2
Task/Literals-String/Forth/literals-string-1.fth
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
char c emit
|
||||
s" string" type
|
||||
3
Task/Literals-String/Forth/literals-string-2.fth
Normal file
3
Task/Literals-String/Forth/literals-string-2.fth
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
: main
|
||||
[char] c emit
|
||||
s" string" type ;
|
||||
2
Task/Literals-String/Forth/literals-string-3.fth
Normal file
2
Task/Literals-String/Forth/literals-string-3.fth
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
'c emit
|
||||
s\" hello\nthere!"
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue